Skip to content

Commit 6d104b8

Browse files
committed
add test
1 parent e094bf3 commit 6d104b8

File tree

8 files changed

+54
-0
lines changed

8 files changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import loadModule from "./shared"
2+
3+
it("should not have a.add from entry-a + entry-b", () => {
4+
return loadModule().then(module => {
5+
const { arg } = module;
6+
expect(arg).toBe(42)
7+
expect(typeof __webpack_modules__["./util2.js"]).toBe("function")
8+
expect(require.cache["./util2.js"]).toBe(undefined); // not loaded on __webpack_require__.c["./util2.js"]
9+
});
10+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
it("should have util2.js in util chunk", () => {
2+
return import("./shared")
3+
.then(({ default: loadModule }) => loadModule())
4+
.then((module) => {
5+
let arg = module.arg;
6+
expect(arg).toBe(42)
7+
expect(typeof __webpack_modules__["./util2.js"]).toBe("function")
8+
expect(typeof require.cache["./util2.js"]).toBe("object"); // loaded on __webpack_require__.c["./util2.js"]
9+
return arg
10+
})
11+
.then(arg => {
12+
return import("./util1").then(module => {
13+
let res = module.f(arg);
14+
expect(res).toBe(84);
15+
})
16+
})
17+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default () => import("./util")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
findBundle: function (i, options) {
3+
return ["a.js", "b.js"];
4+
}
5+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { arg } from './util1'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const arg = 42
2+
export { f } from "./util2"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const f = a => a * 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/** @type {import("../../../../").Configuration} */
2+
module.exports = {
3+
entry: {
4+
a: "./entry-a",
5+
b: "./entry-b"
6+
},
7+
optimization: {
8+
sideEffects: true,
9+
providedExports: true,
10+
usedExports: true,
11+
concatenateModules: false,
12+
moduleIds: "named"
13+
},
14+
output: {
15+
filename: "[name].js"
16+
}
17+
};

0 commit comments

Comments
 (0)