webpack将代码打包成一个立即执行函数。
!function (e, r){
"object" == typeof exports && "object" == typeof module ? module.exports = r(require("rxjs"))
: "function" == typeof define && define.amd ? define(["rxjs"], r)
: "object" == typeof exports ? exports.deepRxjs = r(require("rxjs"))
: e.deepRxjs = r(e.rxjs)
}(this, (function(e){}))
说明
最外层的立即执行函数有两个输入参数:
第1个参数e
被实参化this
第2个参数r
是一个函数,用来导出功能。
这个函数不返回值,根据配置的不同,module.exports
,define
,exports
,e
,为相应的对象添加成员。
r的输入参数e
是导入包,在这里是require("rxjs")
,
You can then ensure that only one instance of angular is loaded from your main module by adding an alias for rxjs
to your webpack config:
import path from 'path'
export default {
resolve: {
alias: {
'rxjs': path.resolve(__dirname, 'node_modules', 'rxjs')
},
},
}
is there any solution for this? In My case, load same package multi times with different path cause the instance of same class check if is instanceof
the class failed.
The same module should be loaded only once...