-
Notifications
You must be signed in to change notification settings - Fork 27.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(turbopack): Fix tree shaking with import * as R
#74725
Changes from all commits
9e37ce2
19c02f9
31ba1d3
5e4ef95
0fadca5
bd52c66
104f0d6
78d6bbc
0f55020
f1e9cb0
3a3ca98
8fc6664
186648a
53d652b
511cdf2
c208b3b
3ed348c
791f674
58595c4
e87f367
c18824b
b489f16
c127e81
3b46d42
2bfaca1
9865c46
be973cd
c845528
2d63498
f7fa8b8
e456bd4
2b6064a
35f7d12
7bbf5c0
f2bec0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as R from 'ramda'; | ||
|
||
console.log((0, R.pipe)('a', 'b', 'c')); | ||
kdy1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
console.log(R.pipe('a', 'b', 'c')); | ||
|
||
|
||
it('should import only pipe.js', () => { | ||
const modules = Object.keys(__turbopack_modules__); | ||
expect(modules).toContainEqual( | ||
expect.stringMatching(/input\/node_modules\/ramda\/pipe/) | ||
); | ||
expect(modules).not.toContainEqual( | ||
expect.stringMatching(/input\/node_modules\/ramda\/index/) | ||
); | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"treeShakingMode": "reexports-only" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Why only in this mode? Wouldn't this also be benefitial even when splitting into fragments?
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.
I think it will go to a different code path, namely
follow_reexports_with_side_effects
.next.js/turbopack/crates/turbopack-ecmascript/src/tree_shake/asset.rs
Lines 219 to 268 in d0d7352
In the full module fragment tree shaking mode
import *
will not createNone
forOption<ModulePart>
. The line producingNone
is located atnext.js/turbopack/crates/turbopack-ecmascript/src/references/mod.rs
Line 633 in d0d7352
ReexportsOnly
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.
I see, I don't think we have a test for the other tree shaking mode though. Could you add that, seems like we already have something similar going on for
mui-utils
which runs the same code fromside-effects-optimization/mui-utils
but just with a different config