-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
39 additions
and
52 deletions.
There are no files selected for viewing
32 changes: 14 additions & 18 deletions
32
test/configCases/output-module/iife-entry-module-with-others/index.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 |
---|---|---|
@@ -1,20 +1,16 @@ | ||
import { value as v1 } from "./module1"; | ||
const v2 = require("./module2") | ||
const module3Inc = require("./module3") | ||
import { value as value1 } from './module1' | ||
const value2 = require('./module2') | ||
const value3 = require('./module3') | ||
|
||
const index_value = 10; | ||
let value = 42; | ||
let value = 42 | ||
let src_value = 43 | ||
let src_src_value = 44 | ||
|
||
function inc() { | ||
value++; | ||
} | ||
|
||
it("single inlined module should not be wrapped in IIFE", () => { | ||
expect(value).toBe(42); | ||
expect(v1).toBe(undefined); | ||
expect(v2).toBe(undefined); | ||
expect(module3Inc).toBe(undefined); | ||
inc(); | ||
expect(value).toBe(43); | ||
expect(index_value).toBe(10); | ||
}); | ||
it('inlined module should not leak to non-inlined modules', () => { | ||
expect(value1).toBe(undefined) | ||
expect(value).toBe(42) | ||
expect(src_value).toBe(43) | ||
expect(src_src_value).toBe(44) | ||
expect(value2).toBe("undefined") // should not touch leaked `value` variable | ||
expect(value3).toBe("undefined") // should not touch leaked `src_value` variable | ||
}) |
4 changes: 2 additions & 2 deletions
4
test/configCases/output-module/iife-entry-module-with-others/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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
let value; | ||
let value | ||
|
||
export { value }; | ||
export { value } |
4 changes: 1 addition & 3 deletions
4
test/configCases/output-module/iife-entry-module-with-others/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 |
---|---|---|
@@ -1,3 +1 @@ | ||
let value | ||
|
||
module.exports = value | ||
module.exports = typeof value |
4 changes: 1 addition & 3 deletions
4
test/configCases/output-module/iife-entry-module-with-others/module3.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 |
---|---|---|
@@ -1,3 +1 @@ | ||
let inc | ||
|
||
module.exports = inc | ||
module.exports = typeof src_value |
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 |
---|---|---|
@@ -1 +1 @@ | ||
module.exports = 'foo' | ||
module.exports = 42; |
15 changes: 14 additions & 1 deletion
15
test/configCases/output-module/iife-innter-strict/index.mjs
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 |
---|---|---|
@@ -1 +1,14 @@ | ||
import foo from './foo.cjs' | ||
import foo from './foo.cjs'; | ||
|
||
let answer | ||
|
||
try { | ||
delete Object.prototype; // will throw error in strict mode | ||
answer = 'no'; | ||
} catch { | ||
answer = 'yes'; | ||
} | ||
|
||
it("multiple inlined modules should be wrapped in IIFE to isolate from other inlined modules and chunk modules", () => { | ||
expect(answer).toBe("yes"); // the code should throw in strict mode | ||
}); |
16 changes: 0 additions & 16 deletions
16
test/configCases/output-module/iife-multiple-entry-modules/index-1.js
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
test/configCases/output-module/iife-multiple-entry-modules/index-2.js
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
test/configCases/output-module/iife-multiple-entry-modules/index1.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,4 @@ | ||
|
||
it("multiple inlined modules should be wrapped in IIFE to isolate from other inlined modules and chunk modules", () => { | ||
expect(typeof value).toBe("undefined"); // `value` in index2 should not leak to index1 | ||
}); |
1 change: 1 addition & 0 deletions
1
test/configCases/output-module/iife-multiple-entry-modules/index2.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: 0 additions & 3 deletions
3
test/configCases/output-module/iife-multiple-entry-modules/module1.js
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
test/configCases/output-module/iife-multiple-entry-modules/module2.js
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
test/configCases/output-module/iife-multiple-entry-modules/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