mirror of https://github.com/webpack/webpack.git
Fix externals interop within SystemLibraryPlugin.
This commit is contained in:
parent
8dca6f1b59
commit
d3b44c96a0
|
@ -116,6 +116,13 @@ class SystemLibraryPlugin extends AbstractLibraryPlugin {
|
||||||
Template.asString([
|
Template.asString([
|
||||||
"function(module) {",
|
"function(module) {",
|
||||||
Template.indent(`${external} = module;`),
|
Template.indent(`${external} = module;`),
|
||||||
|
Template.indent([
|
||||||
|
"if (!Object.hasOwnProperty.call(module, '__esModule')) {",
|
||||||
|
Template.indent(
|
||||||
|
`Object.defineProperty(${external}, "__esModule", {value: true});`
|
||||||
|
),
|
||||||
|
"}"
|
||||||
|
]),
|
||||||
"}"
|
"}"
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import external3Default from 'external3';
|
||||||
|
|
||||||
/* This test verifies that webpack externals are properly indicated as dependencies to System.
|
/* This test verifies that webpack externals are properly indicated as dependencies to System.
|
||||||
* Also that when System provides the external variables to webpack that the variables get plumbed
|
* Also that when System provides the external variables to webpack that the variables get plumbed
|
||||||
* through correctly and are usable by the webpack bundle.
|
* through correctly and are usable by the webpack bundle.
|
||||||
|
@ -8,4 +10,6 @@ it("should get an external from System", function() {
|
||||||
|
|
||||||
const external2 = require("external2");
|
const external2 = require("external2");
|
||||||
expect(external2).toBe("the external2 value");
|
expect(external2).toBe("the external2 value");
|
||||||
|
|
||||||
|
expect(external3Default).toBe("the external3 default export");
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,10 @@ module.exports = {
|
||||||
beforeExecute: () => {
|
beforeExecute: () => {
|
||||||
System.init({
|
System.init({
|
||||||
external1: "the external1 value",
|
external1: "the external1 value",
|
||||||
external2: "the external2 value"
|
external2: "the external2 value",
|
||||||
|
external3: {
|
||||||
|
default: "the external3 default export",
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
moduleScope(scope) {
|
moduleScope(scope) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
externals: {
|
externals: {
|
||||||
external1: "external1",
|
external1: "external1",
|
||||||
external2: "external2"
|
external2: "external2",
|
||||||
|
external3: "external3"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue