chore: update swc-loader configuration to detect syntax automatically#421
Merged
chenjiahan merged 1 commit intomainfrom Apr 10, 2026
Merged
chore: update swc-loader configuration to detect syntax automatically#421chenjiahan merged 1 commit intomainfrom
chenjiahan merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates multiple Rspack example configurations to rely on builtin:swc-loader’s automatic syntax detection, reducing the need to hardcode SWC parser syntax per file type.
Changes:
- Replace explicit
jsc.parser.syntax(and related JSX/TSX flags) withdetectSyntax: 'auto'in many example configs. - Broaden SWC rule
testpatterns to cover additional JS/TS module extensions (e.g.,mjs/cjs/mts/cts) and addexclude: /node_modules/in several examples. - Simplify some configs by merging previously separate TS/TSX SWC rules into a single rule.
Reviewed changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| rspack/vue/rspack.config.js | Switch SWC rule to wider extension coverage and detectSyntax: 'auto'. |
| rspack/vanilla-extract-css/rspack.config.js | Use detectSyntax: 'auto' and adjust SWC test for more extensions. |
| rspack/type-reexports-presence/rspack.config.mjs | Replace explicit TS parser syntax with detectSyntax: 'auto'. |
| rspack/ts-checker-rspack-plugin/rspack.config.js | Replace explicit TS parser syntax with detectSyntax: 'auto' (plus minor quote style change). |
| rspack/svgr/rspack.config.js | Broaden SWC test, add exclude, and enable detectSyntax: 'auto'. |
| rspack/svelte/rspack.config.js | Replace explicit TS parser syntax with detectSyntax: 'auto'. |
| rspack/styled-components/rspack.config.js | Broaden SWC test, add exclude, and enable detectSyntax: 'auto'. |
| rspack/source-map-with-vscode-debugging/rspack.config.js | Broaden SWC test, add exclude, and enable detectSyntax: 'auto'. |
| rspack/react/rspack.config.js | Broaden SWC test, add exclude, and enable detectSyntax: 'auto'. |
| rspack/react-with-sass/rspack.config.js | Broaden SWC test, add exclude, and enable detectSyntax: 'auto'. |
| rspack/react-with-less/rspack.config.js | Broaden SWC test, add exclude, and enable detectSyntax: 'auto'. |
| rspack/react-with-extract-css/rspack.config.js | Broaden SWC test, add exclude, and enable detectSyntax: 'auto'. |
| rspack/react-ssr-esm/rspack.config.server.js | Expand SWC test, add exclude, and add detectSyntax: 'auto' options. |
| rspack/react-ssr-esm/rspack.config.client.js | Expand SWC test, add exclude, and add detectSyntax: 'auto' options. |
| rspack/react-refresh/rspack.config.js | Replace TSX parser config with detectSyntax: 'auto' and broaden test/add exclude. |
| rspack/react-refresh-esm/rspack.config.js | Replace TSX parser config with detectSyntax: 'auto' and broaden test/add exclude. |
| rspack/react-compiler-babel/rspack.config.js | Replace explicit ecmascript parser config with detectSyntax: 'auto' and broaden JS test. |
| rspack/react-compiler-babel-ts/rspack.config.js | Replace explicit TS/TSX parser config with detectSyntax: 'auto' and broaden JS/TS test. |
| rspack/preact/rspack.config.js | Broaden SWC test, add exclude, and enable detectSyntax: 'auto'. |
| rspack/preact-refresh/rspack.config.js | Broaden SWC test, add exclude, and enable detectSyntax: 'auto' (remove explicit parser config). |
| rspack/polyfill/rspack.config.js | Broaden SWC test and enable detectSyntax: 'auto'. |
| rspack/nestjs/rspack.config.js | Add detectSyntax: 'auto' and remove explicit TS parser syntax while keeping decorator settings. |
| rspack/monaco-editor-ts-react/rspack.config.js | Merge TS/TSX SWC rules into one, broaden test, add exclude, and enable detectSyntax: 'auto'. |
| rspack/module-federation-v1/lib2/rspack.config.js | Broaden test and replace explicit parser config with detectSyntax: 'auto'. |
| rspack/module-federation-v1/lib1/rspack.config.js | Broaden test and replace explicit parser config with detectSyntax: 'auto'. |
| rspack/module-federation-v1/app/rspack.config.js | Broaden test and replace explicit parser config with detectSyntax: 'auto'. |
| rspack/module-federation-v1.5/lib2/rspack.config.js | Broaden test and replace explicit parser config with detectSyntax: 'auto'. |
| rspack/module-federation-v1.5/lib1/rspack.config.js | Broaden test and replace explicit parser config with detectSyntax: 'auto'. |
| rspack/module-federation-v1.5/app/rspack.config.js | Broaden test and replace explicit parser config with detectSyntax: 'auto'. |
| rspack/license-webpack-plugin/rspack.config.js | Broaden SWC test, add exclude, and enable detectSyntax: 'auto'. |
| rspack/inline-enum/rspack.config.mjs | Replace explicit TS parser syntax with detectSyntax: 'auto'. |
| rspack/inline-const/rspack.config.mjs | Add detectSyntax: 'auto' and remove explicit TS parser syntax from jsc. |
| rspack/inline-const-enum/rspack.config.mjs | Add detectSyntax: 'auto' and remove explicit TS parser syntax from jsc. |
| rspack/express/rspack.config.js | Add detectSyntax: 'auto' and remove explicit TS parser syntax while keeping decorator settings. |
| rspack/emotion/rspack.config.js | Broaden SWC test, add exclude, and enable detectSyntax: 'auto'. |
| rspack/cra/rspack.config.js | Broaden SWC test, add exclude, and enable detectSyntax: 'auto'. |
| rspack/cra-ts/rspack.config.js | Broaden SWC test, add exclude, enable detectSyntax: 'auto', and remove redundant TS-only rule. |
| rspack/builtin-swc-loader/rspack.config.mjs | Broaden SWC test and enable detectSyntax: 'auto'. |
| rspack/basic-ts/rspack.config.mjs | Broaden SWC test and replace explicit TS parser syntax with detectSyntax: 'auto'. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.