-
Notifications
You must be signed in to change notification settings - Fork 380
Switch from Babel to SWC for faster JavaScript transpilation #677
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
Merged
+1,607
−1,391
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
62ee4f1
Switch from Babel to SWC for faster JavaScript transpilation
justin808 cf7fd99
Add SWC configuration for React Fast Refresh
justin808 ffca3cb
Add package-lock.json to gitignore
justin808 f3d910d
Fix SWC config to preserve class names for Stimulus compatibility
justin808 ce8f58d
Add React automatic runtime to SWC config to match Babel
justin808 c336d81
Add loose: false to SWC config for Stimulus compatibility
justin808 a2654d7
Remove package-lock.json from .gitignore to detect accidental npm usage
justin808 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { env } = require('shakapacker'); | ||
|
||
const customConfig = { | ||
options: { | ||
jsc: { | ||
// Preserve class names for Stimulus controller discovery | ||
keepClassNames: true, | ||
// Use spec-compliant transforms (override Shakapacker's loose: true default) | ||
// This is required for Stimulus controllers to work correctly | ||
loose: false, | ||
transform: { | ||
react: { | ||
// Use automatic runtime (React 17+) - no need to import React | ||
runtime: 'automatic', | ||
// Enable React Fast Refresh in development | ||
refresh: env.isDevelopment && env.runningWebpackDevServer, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
module.exports = customConfig; |
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
Oops, something went wrong.
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.
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.
🧩 Analysis chain
Verify that the SWC dependency versions are current.
The versions of SWC-related packages may be outdated. Please ensure you're using the latest stable versions for optimal performance and security.
Since my knowledge may be outdated, please verify the current versions:
Also applies to: 101-101
🌐 Web query:
💡 Result:
@swc/core — 1.13.1 (latest stable, published Jul 19, 2025). [1]
swc-loader — 0.2.6 (latest stable). [2]
Sources:
[1] Snyk package page for @swc/core.
[2] npm package page for swc-loader.
Update @swc/core to latest stable (1.13.1)
The declared "^1.13.5" isn’t published; change it to "^1.13.1".
🤖 Prompt for AI Agents