fix: remove default javascript/auto type for JavaScript modules#5955
Closed
chenjiahan wants to merge 1 commit intomainfrom
Closed
fix: remove default javascript/auto type for JavaScript modules#5955chenjiahan wants to merge 1 commit intomainfrom
javascript/auto type for JavaScript modules#5955chenjiahan wants to merge 1 commit intomainfrom
Conversation
✅ Deploy Preview for rsbuild 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 removes the explicit type: 'javascript/auto' configuration from JavaScript module rules to fix ESM/CJS interoperability issues. When Rspack encounters ES modules (.mjs, .mts files or modules with type: "module" in package.json), it automatically sets javascript/esm by default, but the explicit javascript/auto override was breaking the necessary interop runtime for importing CJS modules from ESM contexts.
- Removes the
type: 'javascript/auto'line from the SWC loader rule configuration - Updates all test snapshots to reflect the removal of this configuration
- Allows Rspack to handle JavaScript module type detection automatically
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/plugins/swc.ts | Removes the explicit type: 'javascript/auto' from the JavaScript module rule |
| packages/core/tests/snapshots/*.snap | Updates test snapshots to reflect the removed type configuration |
| packages/plugin-/tests/snapshots/.snap | Updates plugin test snapshots for consistency |
| packages/compat/webpack/tests/snapshots/*.snap | Updates webpack compatibility test snapshots |
JSerFeng
approved these changes
Aug 27, 2025
Member
Author
|
Closed as it is a potential breaking change ( |
2 tasks
2 tasks
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
This PR removes the
type: 'javascript/auto'from the rule for JavaScript modules.When Rspack encounters modules with
type: "module"in package.json or modules with.mjsand.mtsextensions, Rspack will configure these modules withjavascript/esmby default.If Rsbuild sets
javascript/autofor ES modules, this change will break the ESM/CJS interop. For example, when a user writes an.mjsfile and imports a CJS module, interop runtime should be added. However, withjavascript/auto, the interop won't be added.Related Links
Checklist