-
-
Notifications
You must be signed in to change notification settings - Fork 53
fix: treat module
as normal variable in ESM
#1260
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
Conversation
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.
Pull Request Overview
This PR fixes the handling of the module
variable in ES modules by preventing extra parser transformations when ESM syntax is present. The fix ensures that when building libraries in ESM format, the module
variable is treated as a normal variable rather than being transformed by CommonJS-specific parsers.
- Updates JavaScript parser configuration to skip CommonJS exports handling in ESM context
- Adds comprehensive integration tests for
module
variable handling in both ESM and CJS formats - Removes the
"type": "module"
package.json field from a test to ensure proper testing of mixed environments
Reviewed Changes
Copilot reviewed 12 out of 29 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
packages/core/src/config.ts | Adds commonjs.exports: 'skipInEsm' parser option for ESM format |
packages/core/tests/snapshots/config.test.ts.snap | Updates test snapshots to reflect new parser configuration |
tests/integration/parser-javascript/module/ | New test suite with files to verify module variable handling in ESM vs CJS |
tests/integration/parser-javascript/api-plugin/ | New test for API plugin parser behavior |
tests/integration/format/index.test.ts | Updates existing test and adds new test case for module handling |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
✅ Deploy Preview for rslib ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
@codex remove tests/integration/parser-javascript/api-plugin/src/cjsFile.cjs |
Summary
Testing
|
Summary
second (final) step after web-infra-dev/rspack#11744.
forbid extra parser to handle
module
var if ESM syntax is present, common usage and user expectation in package building.Related Links
Checklist