-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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: Fix wrong cjs detection of auto-cjs
pass
#60118
Merged
Merged
Conversation
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
kdy1
requested review from
timneutkens,
ijjk,
shuding,
huozhi and
a team
as code owners
January 2, 2024 14:33
Stats from current PRDefault BuildGeneral
Client Bundles (main, webpack)
Legacy Client Bundles (polyfills)
Client Pages
Client Build Manifests
Rendered Page Sizes
Edge SSR bundle Size
Middleware size
Next Runtimes
|
Tests Passed |
huozhi
approved these changes
Jan 2, 2024
huozhi
added a commit
that referenced
this pull request
Jan 3, 2024
Previously in #58967 we set all the module type as `'es6'` to let swc parse app router code as ESM and output as ESM due to the incorrect detection of CJS module by auto-cjs plugin, but this is not accurate when the external library bundle is CJS. The problem is when swc compiling modern syntax for example private properties in CJS bundle but emitted the swc helpers with ESM imports. We had a auto-cjs swc plugin to determine if the file is using CJS or not, @kdy1 fixed the bug of it so now we can use the default module type, and let the plugin to determine its module type, to make sure we're emitting the right helpers. Closes NEXT-1942 Based on #60118
agustints
pushed a commit
to agustints/next.js
that referenced
this pull request
Jan 6, 2024
### What? Make `auto-cjs` pass consider shadowing of `module`, so it can ignore `module.exports = foo` in nested scopes. ### Why? It's problematic for many tasks ### How? Closes PACK-2074
agustints
pushed a commit
to agustints/next.js
that referenced
this pull request
Jan 6, 2024
…el#60169) Previously in vercel#58967 we set all the module type as `'es6'` to let swc parse app router code as ESM and output as ESM due to the incorrect detection of CJS module by auto-cjs plugin, but this is not accurate when the external library bundle is CJS. The problem is when swc compiling modern syntax for example private properties in CJS bundle but emitted the swc helpers with ESM imports. We had a auto-cjs swc plugin to determine if the file is using CJS or not, @kdy1 fixed the bug of it so now we can use the default module type, and let the plugin to determine its module type, to make sure we're emitting the right helpers. Closes NEXT-1942 Based on vercel#60118
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Make
auto-cjs
pass consider shadowing ofmodule
, so it can ignoremodule.exports = foo
in nested scopes.Why?
It's problematic for many tasks
How?
Closes PACK-2074