【问题标题】:There is no import of NPM package. How is it being used?没有导入 NPM 包。它是如何使用的?
【发布时间】:2022-02-15 22:50:22
【问题描述】:

mediacms-vjs-plugin 是 Video.js 的自定义插件。

MediaCmsVjsPlugin.js 源文件开头为:

import { version as VERSION } from '../package.json';

import 'mediacms-vjs-plugin-font-icons/dist/mediacms-vjs-icons.css';
import './styles.scss';

可以看出,videojs 中没有import。但是,videojs 在整个代码中都被使用,例如:


function generatePlugin() {
    const videojsComponent = videojs.getComponent('Component');
    const videojsClickableComponent = videojs.getComponent('ClickableComponent');
    const videojsComponentButton = videojs.getComponent('Button');

    const __MediaCMSComponent__ = videojs.extend(videojsComponent, {
    

不先导入videojs怎么可能使用它?

它的package.json 文件将videojs 指定为对等依赖项

  "peerDependencies": {
    "video.js": "^7.12.3"
  },

难道只要有对等依赖,我们就不必显式地导入它了吗?

【问题讨论】:

    标签: javascript node.js npm video.js


    【解决方案1】:

    由于它是一个插件,它很可能是在您的项目中已经有 videojs 并且您在导入插件之前将其导入某个地方的假设下编写的。

    【讨论】:

      猜你喜欢
      • 2020-12-10
      • 1970-01-01
      • 2021-10-06
      • 1970-01-01
      • 2020-04-22
      • 2018-10-22
      • 2023-02-06
      • 2020-03-06
      • 1970-01-01
      相关资源
      最近更新 更多