[英]Imported dependency requires another dependency to be first available in scope
I'm trying to import a library that extends another one , here's my first approach:我正在尝试导入一个扩展另一个库的库,这是我的第一种方法:
import * as PIXI from 'pixi.js';
import 'pixi-layers'; // extends PIXI classes
I get an Uncaught ReferenceError: PIXI is not defined
on runtime when pixi-layers
tries to Object.assign
on a PIXI class.当
pixi-layers
尝试在Object.assign
上分配 Object.assign 时,我得到一个未捕获的Uncaught ReferenceError: PIXI is not defined
on runtime。
I suppose this is related to how webpack's hoisting, I've tried to use:我想这与我尝试使用的 webpack 的提升方式有关:
module.exports = {
// ...
plugins: [
new webpack.ProvidePlugin({
PIXI: 'pixi.js',
}),
],
};
PIXI remains unavailable to pixi-layers
, how can I bundle pixi-layers
and make sure it can actually work with the PIXI object? PIXI 对
pixi-layers
仍然不可用,我如何捆绑pixi-layers
并确保它实际上可以与 PIXI object 一起使用?
Turns out providing PIXI as a plugin through the webpack config file was the solution, I just has this same config file compile in the wrong location (paths are hard).结果证明通过 webpack 配置文件将 PIXI 作为插件提供是解决方案,我只是在错误的位置编译了相同的配置文件(路径很难)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.