[Rspack][SWC] fix: add support for swc.config.ts in meteor 3.4#14150
[Rspack][SWC] fix: add support for swc.config.ts in meteor 3.4#14150sanki92 wants to merge 2 commits intometeor:release-3.4.1from
Conversation
✅ Deploy Preview for v3-migration-docs canceled.
|
✅ Deploy Preview for v3-meteor-api-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
nachocodoner
left a comment
There was a problem hiding this comment.
In packages/babel-compiler/babel-compiler.js, there is also code around .swcrc/swc.config.js file usage. This is used by the Meteor bundler with modern:true in Meteor 3.3, not only by the Rspack integration that came later. It should also support swc.config.ts in the Meteor bundler, along with Meteor Rspack that you already cover.
Again, thanks to this proactivity on helping us to fix these issues.
|
|
||
| if (file.endsWith('.ts')) { | ||
| try { | ||
| const esbuild = require('esbuild'); |
There was a problem hiding this comment.
why do you use esbuild here?
We already benefit from @swc/core (builtin in Rspack), why don't use swc here to transform this file?
There was a problem hiding this comment.
Ahh you're right, my bad, didn't think to check what Rspack already had bundled. I was focused on getting the TS parsing working and just reached for esbuild. Makes way more sense to use what's already there.
And yeah, completely missed that babel-compiler needed this too. I was only testing through the Rspack path. Fixed now, but let me know if you see anything else.
| "author": "Ben Newman <ben@meteor.com>", | ||
| "description": "Stub implementations of Node built-in modules, a la Browserify", | ||
| "version": "1.2.24", | ||
| "version": "1.2.26", |
There was a problem hiding this comment.
Why meteor-node-stubs was bumped here?
There was a problem hiding this comment.
My branch accidentally included those commits because I branched from devel, and when you changed the PR base to release-3.4.1, it picked up the extra commits.
Just cleaned it up, Should be good now, Sorry for the inconvenience :)
92de319 to
134b28d
Compare
Problem
Meteor's Rspack integration currently only supports
.swcrcandswc.config.jsfor SWC transpiler configuration. TS developers can't useswc.config.tsfor type-safe configs, which is a common pattern in modern TS projects.Solution
Extended the SWC config loader to support
.tsfiles:• Added TS file handling with automatic transpilation (esbuild primary, regex fallback)
• Maintains priority order:
.swcrc>swc.config.js>swc.config.ts• Added
swc.config.tsto Rspack cache dependencies for proper invalidationChanges Made
npm-packages/meteor-rspack/lib/swc.js• Extended
getMeteorAppSwcrc()to handle.tsextensions• Added TS transpilation with esbuild (falls back to regex if unavailable)
• Strips TS syntax: imports, types, interfaces, decorators
• Converts ES modules to CommonJS
• Updated
getMeteorAppSwcConfig()to check for all three config typesnpm-packages/meteor-rspack/rspack.config.js• Added
swc.config.tspath detection• Included in build dependencies for cache invalidation
Verification
Tested with Meteor TS app:
• Only
swc.config.tspresent - loads correctly• Both
swc.config.jsandswc.config.tspresent -swc.config.jstakes priority• All three configs present -
.swcrctakes priorityExample
swc.config.ts:Fixes #14033