Skip to content

Commit 6094f31

Browse files
committed
refactor test
1 parent 79d2812 commit 6094f31

2 files changed

Lines changed: 10 additions & 15 deletions

File tree

test/configCases/externals/module-externals-in-async-chunk/index.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
it("Should place externals into its own chunks when externalsType is module", function (done) {
22
var fs = require("fs");
3-
var path = require("path");
4-
var source = fs.readFileSync(__filename, "utf-8");
5-
var source2 = fs.readFileSync(
6-
path.resolve(__dirname, "./async.mjs"),
7-
"utf-8"
8-
);
93

10-
// external
11-
expect(source2).toMatch(/import(.*)from\s*["']fs["']\s*/);
12-
// external2
13-
expect(source2).toMatch(/import(.*)from\s*["']node:fs["']\s*/);
14-
// external3
15-
expect(source).toMatch(/import\(\s*["']fs["']\s*\)/);
16-
expect(source).not.toMatch(/import(.*)from\s*["']fs["']\s*/);
17-
expect(source).not.toMatch(/import(.*)from\s*["']node:fs["']\s*/);
4+
expect(__webpack_modules__["external"]).toBeUndefined();
5+
expect(__webpack_modules__["external2"]).toBeUndefined();
6+
expect(__webpack_modules__["external3"]).toBeDefined();
187

198
import(/* webpackChunkName: 'async' */ "./chunk").then((ns) => {
9+
expect(__webpack_modules__["external"]).toBeDefined();
10+
expect(__webpack_modules__["external2"]).toBeDefined();
2011
expect(ns.readFileSync).toBe(fs.readFileSync);
2112
expect(ns.readFile).toBe(fs.readFile);
2213

test/configCases/externals/module-externals-in-async-chunk/webpack.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ module.exports = {
1111
experiments: {
1212
outputModule: true
1313
},
14-
output: { chunkFilename: "[name].mjs" }
14+
output: { chunkFilename: "[name].mjs" },
15+
optimization: {
16+
moduleIds: "named",
17+
concatenateModules: false
18+
}
1519
};

0 commit comments

Comments
 (0)