Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for multiple inlined modules
- Loading branch information
Showing
5 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
test/configCases/output-module/multiple-inlined-module/index-1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { value as v1 } from "./module1"; | ||
const v2 = require("./module2") | ||
|
||
var value = 42; | ||
|
||
function inc() { | ||
value++; | ||
} | ||
|
||
it("multiple inlined modules should be wrapped in IIFE to isolate from other inlined modules and chunk modules", () => { | ||
expect(value).toBe(42); | ||
expect(v1).toBe(undefined); | ||
expect(v2).toBe(undefined); | ||
inc(); | ||
expect(value).toBe(43); | ||
}); |
1 change: 1 addition & 0 deletions
1
test/configCases/output-module/multiple-inlined-module/index-2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var value = 42; |
3 changes: 3 additions & 0 deletions
3
test/configCases/output-module/multiple-inlined-module/module1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let value; | ||
|
||
export { value }; |
3 changes: 3 additions & 0 deletions
3
test/configCases/output-module/multiple-inlined-module/module2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let value | ||
|
||
module.exports = value |
14 changes: 14 additions & 0 deletions
14
test/configCases/output-module/multiple-inlined-module/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
entry: ["./index-1.js", "./index-2.js"], | ||
output: { | ||
module: true | ||
}, | ||
optimization: { | ||
concatenateModules: true | ||
}, | ||
experiments: { | ||
outputModule: true | ||
}, | ||
target: "es2020" | ||
}; |