[英]Webpack library re-export
I have 2 libraries A and B. 我有2个图书馆A和B。
In webpack.conf.js
: 在webpack.conf.js
:
module.exports = {
entry: {
'b': ['./src/MyB.js', './js/a.js']
In a.js
(compiled by webpack) I have: 在a.js
(由webpack编译)中,我有:
var mya =
....
function(module, exports, __webpack_require__) {
var MyA_1 = __webpack_require__(1);
exports.MyA = MyA_1.MyA;
}
In b.js
bundle I end up with: 在b.js
包中,我最终得到:
function(module, exports) {
// here we are in MyB
var a = new MyA(); // this is not found, even if prefixed with mya
},
function(module, exports) {
// a.js code is bundled with b in b.js
var mya = ...
// missing: exports.MyA = mya;
}
And of course MyA is not visible anywhere outside. 当然,MyA在外面的任何地方都不可见。 Any idea how can I achieve this? 知道我该如何实现吗?
Instead of using an array for your entry points, why not use B as your entry, and in it, require
the A library? 为何不使用B作为入口,而不是使用数组作为入口点,而在其中require
A库? Then you can use it, export it, make it global, whatever you need. 然后,您可以使用它,将其导出,使其全局化,无论您需要什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.