Skip to content

Comments

[Rspack][SWC] fix: add support for swc.config.ts in meteor 3.4#14150

Open
sanki92 wants to merge 2 commits intometeor:release-3.4.1from
sanki92:fix-issue-14033-swc-config-ts
Open

[Rspack][SWC] fix: add support for swc.config.ts in meteor 3.4#14150
sanki92 wants to merge 2 commits intometeor:release-3.4.1from
sanki92:fix-issue-14033-swc-config-ts

Conversation

@sanki92
Copy link
Contributor

@sanki92 sanki92 commented Feb 18, 2026

Problem

Meteor's Rspack integration currently only supports .swcrc and swc.config.js for SWC transpiler configuration. TS developers can't use swc.config.ts for type-safe configs, which is a common pattern in modern TS projects.

Solution

Extended the SWC config loader to support .ts files:

• Added TS file handling with automatic transpilation (esbuild primary, regex fallback)
• Maintains priority order: .swcrc > swc.config.js > swc.config.ts
• Added swc.config.ts to Rspack cache dependencies for proper invalidation

Changes Made

npm-packages/meteor-rspack/lib/swc.js

• Extended getMeteorAppSwcrc() to handle .ts extensions
• 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 types

npm-packages/meteor-rspack/rspack.config.js

• Added swc.config.ts path detection
• Included in build dependencies for cache invalidation

Verification

Tested with Meteor TS app:

• Only swc.config.ts present - loads correctly
• Both swc.config.js and swc.config.ts present - swc.config.js takes priority
• All three configs present - .swcrc takes priority

Example swc.config.ts:

import type { Config } from '@swc/core';

const config: Config = {
  jsc: {
    target: 'es2020',
    parser: {
      syntax: 'typescript',
      tsx: true,
      decorators: true,
    },
  },
  sourceMaps: true,
};

export default config;

Fixes #14033

@netlify
Copy link

netlify bot commented Feb 18, 2026

Deploy Preview for v3-migration-docs canceled.

Name Link
🔨 Latest commit 48685ff
🔍 Latest deploy log https://app.netlify.com/projects/v3-migration-docs/deploys/6995b7003f67af000893c16b

@netlify
Copy link

netlify bot commented Feb 18, 2026

Deploy Preview for v3-meteor-api-docs ready!

Name Link
🔨 Latest commit 134b28d
🔍 Latest deploy log https://app.netlify.com/projects/v3-meteor-api-docs/deploys/6997f0ee5b241f0008a13be3
😎 Deploy Preview https://deploy-preview-14150.docs-online.meteor.com
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Member

@nachocodoner nachocodoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');
Copy link
Member

@nachocodoner nachocodoner Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@nachocodoner nachocodoner added this to the Release 3.4.1 milestone Feb 18, 2026
@nachocodoner nachocodoner changed the base branch from devel to release-3.4.1 February 18, 2026 13:08
@nachocodoner nachocodoner changed the title fix: add support for swc.config.ts in meteor 3.4 [Rspack][SWC] fix: add support for swc.config.ts in meteor 3.4 Feb 18, 2026
"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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why meteor-node-stubs was bumped here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

@sanki92 sanki92 force-pushed the fix-issue-14033-swc-config-ts branch from 92de319 to 134b28d Compare February 20, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Meteor 3.4] Cant use swc.config.ts

2 participants