-
-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: side effects optimize for dynamic reexports (#8125)
- Loading branch information
Showing
20 changed files
with
295 additions
and
124 deletions.
There are no files selected for viewing
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
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
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
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
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
5 changes: 5 additions & 0 deletions
5
...ges/rspack-test-tools/tests/configCases/tree-shaking/side-effects-consume-shared/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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Out } from "./lib/a" | ||
|
||
it("should generate correct export for dynamic reexports (consume shared module)", () => { | ||
expect(Out).toBe(42) | ||
}) |
1 change: 1 addition & 0 deletions
1
...ges/rspack-test-tools/tests/configCases/tree-shaking/side-effects-consume-shared/lib/a.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 @@ | ||
export * from "./b" |
1 change: 1 addition & 0 deletions
1
...ges/rspack-test-tools/tests/configCases/tree-shaking/side-effects-consume-shared/lib/b.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 @@ | ||
export * from "./c" |
1 change: 1 addition & 0 deletions
1
...ges/rspack-test-tools/tests/configCases/tree-shaking/side-effects-consume-shared/lib/c.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 @@ | ||
export const Out = 42; |
3 changes: 3 additions & 0 deletions
3
...ck-test-tools/tests/configCases/tree-shaking/side-effects-consume-shared/lib/package.json
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 @@ | ||
{ | ||
"sideEffects": false | ||
} |
18 changes: 18 additions & 0 deletions
18
...ck-test-tools/tests/configCases/tree-shaking/side-effects-consume-shared/rspack.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,18 @@ | ||
const rspack = require("@rspack/core") | ||
|
||
/**@type {import("@rspack/core").Configuration}*/ | ||
module.exports = { | ||
optimization: { | ||
sideEffects: true, | ||
}, | ||
plugins: [ | ||
new rspack.sharing.ConsumeSharedPlugin({ | ||
consumes: { | ||
"./lib/c.js": { | ||
singleton: true, | ||
eager: true, | ||
} | ||
} | ||
}) | ||
] | ||
}; |
5 changes: 5 additions & 0 deletions
5
packages/rspack-test-tools/tests/configCases/tree-shaking/side-effects-dynamic-cjs/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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Out } from "./lib/a" | ||
|
||
it("should generate correct export for dynamic reexports (dynamic cjs)", () => { | ||
expect(Out).toBe(42) | ||
}) |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/configCases/tree-shaking/side-effects-dynamic-cjs/lib/a.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 @@ | ||
export * from "./b" |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/configCases/tree-shaking/side-effects-dynamic-cjs/lib/b.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 @@ | ||
export * from "./c" |
2 changes: 2 additions & 0 deletions
2
packages/rspack-test-tools/tests/configCases/tree-shaking/side-effects-dynamic-cjs/lib/c.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,2 @@ | ||
let e = exports; | ||
e.Out = 42; |
Oops, something went wrong.
45c0b20
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open
45c0b20
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ran ecosystem CI: Open