I have been looking for examples on how to setup the react-compiler with Meteor 3.4.1. I’ve tried the rspack configuration but it doesn’t work. Has anyone been able to set it up correctly?
2 Likes
Could you mind sharing your repo with it? What errors are you seeing in your end?
@nachocodoner do you recall if we had an example with React Compiler somewhere?
1 Like
Thank you @grubba for replying. I found that I had a weird issue with my Meteor 3.4.1 upgrade but I did a clean install and now its working perfectly.
I double checked on Meteor’s GitHub and couldn’t find any example with react compiler (might be a good idea for the future for any other person that might want to use it).
1 Like
We have an example of app in the E2E tests apps that uses react-compiler.
Could you try it?
"test-app": "TEST_WATCH=1 meteor test --full-app --driver-package meteortesting:mocha",
"visualize": "meteor --production --extra-packages bundle-visualizer"
},
"dependencies": {
"@babel/runtime": "^7.23.5",
"@modelcontextprotocol/sdk": "^1.17.3",
"@swc/helpers": "^0.5.17",
"bcrypt": "^6.0.0",
"meteor-node-stubs": "^1.2.12",
"react": "^18.3.1",
"react-compiler-runtime": "^19.1.0-rc.2",
"react-dom": "^18.3.1",
"react-router-dom": "^7.0.0",
"s3mini": "^0.4.0"
},
"devDependencies": {
"@babel/plugin-syntax-jsx": "^7.27.1",
"@babel/preset-env": "^7.23.5",
"@babel/preset-react": "^7.23.3",
"babel-plugin-react-compiler": "^19.1.0-rc.2",
"babel-loader": "^9.1.3",
{
test: /\.jsx$/,
use: [
{
loader: 'builtin:swc-loader',
options: { jsc: { parser: { syntax: 'ecmascript', jsx: true } } },
},
{ loader: 'babel-loader' },
],
type: 'javascript/auto',
},
return {
plugins: [
['babel-plugin-react-compiler', ReactCompilerConfig], // must run first!
'@babel/plugin-syntax-jsx',
],
};
};
It was based on the Rspack docs: React - Rspack
Thank you @nachocodoner . I used this as an example at the end, had a couple of tweaks based on the rspack documentation. Just in case it helps anyone, this is the simple setup I organized with typescript:
rspack.config.ts
import { defineConfig } from '@meteorjs/rspack';
import { TsCheckerRspackPlugin } from 'ts-checker-rspack-plugin';
export default defineConfig(() => {
return {
plugins: [new TsCheckerRspackPlugin()],
module: {
rules: [
{
test: /\.(?:jsx|tsx)$/,
exclude: /node_modules|\.meteor\/local/,
use: [
{
loader: 'builtin:swc-loader',
options: {
jsc: { transform: { react: { runtime: 'automatic' } } },
},
},
{
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
},
],
},
],
},
};
});
babel.config.ts
export default {
plugins: ['babel-plugin-react-compiler', '@babel/plugin-syntax-jsx', ['@babel/plugin-syntax-typescript', { isTSX: true }]],
};
package.json - Here make sure you add the following devDependencies:
@babel /plugin-syntax-jsx
@babel /plugin-syntax-typescript
babel-loader
babel-plugin-react-compiler
I previously had the swc.config.ts file but it is no longer needed (you need to add the setup in the builtin:swc-loader options.jsc).
1 Like
Good news. Rspack 2.1 is expected to introduce native React Compiler support , implemented in Rust and designed to fit better with SWC-based pipelines. This should help the Meteor-Rspack pipeline keep its speed while moving beyond the current Babel-based React Compiler setup.
swc-project:main ← swc-project:feat/react-compiler
opened 12:39AM - 04 Jun 26 UTC
**Description:**
Add experimental SWC support for the Rust React Compiler… from facebook/react#36173.
This adds the `swc_ecma_react_compiler` bridge, SWC <-> React Compiler AST/scope conversion, `.swcrc` `jsc.transform.reactCompiler` configuration, diagnostics forwarding, JS/WASM option types, and tests ported from the upstream SWC integration.
**TODO:**
- Wait for the React Compiler Rust crates to be published, then replace the temporary git dependencies with published crate versions.
**BREAKING CHANGE:**
<!--
If this PR introduces a breaking change, it must contain a notice for it to be included in the CHANGELOG. Add description or remove entirely if not breaking.
You may need to update `MIGRATION.md` for the breaking changes.
-->
**Related issue (if exists):**
- facebook/react#36173
On the Meteor-Rspack side, we expect Rspack default support to land in Meteor 3.6 . The PR with the required changes is ready and should be included in a beta soon after the official Meteor 3.5.x release.
meteor:devel ← meteor:rspack-2.0
opened 03:28PM - 22 Apr 26 UTC
Context: https://rspack.rs/blog/announcing-2-0
This PR is an attempt to verif… y and give support for Rspack 2.0.0. Anyone can upgrade their apps to 2.0.0, since we don't limit the Rspack version they can use.
The work on this PR is good to ensure our E2E test coverage is not affected by any breaking changes. But it could also show the opposite: that it is necessary to tweak specific configs in the `@meteorjs/rspack` package config to address Rspack 2.0.0 breaking changes and to make it compatible by default in any Meteor app. This is the most likely case because this is a major update, and while anybody could try to adjust their own configs and overrides, the default Meteor behavior in core may need a revision.
There are many breaking changes to consider, so the latter is the most likely outcome: https://rspack.rs/guide/migration/rspack_1.x (AI skills to help: https://github.com/rstackjs/agent-skills)
This is not definitely for Meteor 3.4.x or Meteor 3.5.
## Pending
All E2E app tests pass on the Rspack 2.0 migration. All edge cases have been adapted for retrocompatibility with Meteor specifics, and the supported projects are covered with E2E. The only one missing is the experimental Angular support. We will wait for them to add Rspack 2.0 support, which is an ongoing process. If it doesn't make it for our Meteor 3.6 release, we will skip the experimental Angular support for some time so as not to block others, and communicate accordingly.
- ~Wait for `@nx/angular-rspack` to have support for Rspack 2.0, https://github.com/nrwl/nx/pull/35682~
Covering in another PR.
## Summary by CodeRabbit
## Release Notes
* **Chores**
* Updated Rspack and related build toolchain dependencies to newer major versions across all project templates and scaffolds
* Improved build configuration compatibility with latest Rspack releases
* Enhanced error logging and diagnostics for dependency installation
* **Tests**
* Updated E2E test applications and adjusted configurations for latest toolchain compatibility
2 Likes