fix: should treat mjs and mts files as strict ES modules#818
Merged
Conversation
✅ Deploy Preview for rstest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for treating .mjs and .mts files as strict ES modules by configuring Rspack to use the javascript/esm module type for these file extensions.
Key changes:
- Added a module rule in the Rspack configuration to handle
.mjsand.mtsfiles with thejavascript/esmtype - Added an e2e test to verify that
.mjsfiles are properly handled - Updated snapshot tests to reflect the new module rule in the configuration
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
packages/core/src/core/plugins/basic.ts |
Adds a new module rule to treat .mjs and .mts files as strict ES modules using the javascript/esm type |
packages/core/tests/core/__snapshots__/rsbuild.test.ts.snap |
Updates snapshots to include the new module rule configuration across all test scenarios |
e2e/build/moduleType.test.mjs |
Adds a new e2e test file to verify that .mjs files are treated as ES modules |
e2e/build/src/swc.js |
Adds a test fixture file using CommonJS syntax to test module interoperability |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Use rspack default behavior, treat mjs and mts files as strict ES modules.
https://rspack.rs/config/module-rules#rulestype
Related Links
web-infra-dev/rsbuild#5955
Checklist