[英]Webpack library re-export
我有2個圖書館A和B。
在webpack.conf.js
:
module.exports = {
entry: {
'b': ['./src/MyB.js', './js/a.js']
在a.js
(由webpack編譯)中,我有:
var mya =
....
function(module, exports, __webpack_require__) {
var MyA_1 = __webpack_require__(1);
exports.MyA = MyA_1.MyA;
}
在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;
}
當然,MyA在外面的任何地方都不可見。 知道我該如何實現嗎?
為何不使用B作為入口,而不是使用數組作為入口點,而在其中require
A庫? 然后,您可以使用它,將其導出,使其全局化,無論您需要什么。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.