React Compiler With Meteor 3.4.1

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?

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?

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

We have an example of app in the E2E tests apps that uses react-compiler.

Could you try it?

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

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.

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.