Skip to content

Commit 6fe0bac

Browse files
authored
Merge pull request webpack#13754 from StyleT/feature/custom_externals_for_systemjs_target
fix: fixed work of the non-system type externals for "system" library target
2 parents e29eee1 + 768bb00 commit 6fe0bac

4 files changed

Lines changed: 41 additions & 1 deletion

File tree

lib/library/SystemLibraryPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class SystemLibraryPlugin extends AbstractLibraryPlugin {
7272
render(source, { chunkGraph, moduleGraph, chunk }, { options, compilation }) {
7373
const modules = chunkGraph
7474
.getChunkModules(chunk)
75-
.filter(m => m instanceof ExternalModule);
75+
.filter(m => m instanceof ExternalModule && m.externalType === "system");
7676
const externals = /** @type {ExternalModule[]} */ (modules);
7777

7878
// The name this bundle should be registered as with System
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This test verifies that the System.register context is made available to webpack bundles
2+
3+
it("should correctly handle externals of different type", function() {
4+
expect(require("rootExt")).toEqual("works");
5+
expect(require("varExt")).toEqual("works");
6+
expect(require("windowExt")).toEqual("works");
7+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const System = require("../../../helpers/fakeSystem");
2+
3+
module.exports = {
4+
target: 'web',
5+
beforeExecute: () => {
6+
System.init();
7+
},
8+
moduleScope(scope) {
9+
scope.window.windowExt = 'works';
10+
scope.rootExt = 'works';
11+
scope.varExt = 'works';
12+
scope.System = System;
13+
},
14+
afterExecute: () => {
15+
System.execute("(anonym)");
16+
}
17+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** @type {import("../../../../types").Configuration} */
2+
module.exports = {
3+
output: {
4+
libraryTarget: "system"
5+
},
6+
target: "web",
7+
node: {
8+
__dirname: false,
9+
__filename: false
10+
},
11+
externals: {
12+
rootExt: "root rootExt",
13+
varExt: "var varExt",
14+
windowExt: "window windowExt"
15+
}
16+
};

0 commit comments

Comments
 (0)