[poll included] Meteor + RSPack + React Router in framework mode is it possible?

Originally from Last 3.4-beta.14 Release, Faster Builds, Smaller Bundles and Modern Setups with the Rspack integration ⚡ - #155 by schlaegerz


Hey! Just in case there is someone else already trying to do this, I’m trying to add the React Router framework to a basic template…

Based on what I’ve searched, for RSpack, I would need to use/add GitHub - rspack-contrib/rsbuild-plugin-react-router: A Rsbuild plugin that provides seamless integration with React Router and have this configuration and it would kinda work:

import { defineConfig } from '@rsbuild/core';
import { pluginReactRouter } from 'rsbuild-plugin-react-router';
import { pluginReact } from '@rsbuild/plugin-react';

export default defineConfig(() => {
  return {
    plugins: [
      pluginReactRouter({
        // Optional: Enable custom server mode
        customServer: false,
        // Optional: Specify server output format
        serverOutput: "commonjs",
        //Optional: enable experimental support for module federation
        federation: false
      }), 
      pluginReact()
    ],
  };
});

I did a small search on the forum, and was never mentioned @rsbuild, I assume we(meteor) do the part of the rsbuild, how could this config be in my meteor case?

atm my config is:

And my repo is here: GitHub - Grubba27/meteor-with-rspack-and-react-router: Meteor with RSPack + React Router

And the error I’m getting is this one:


As a side note, just check the vibe: how people feel about having our React template come with a router configured (similar to what we have for Vue)?

What router do you use in React?
  • React Router
  • Tanstack Router
  • Other(please reply)
0 voters
Would you like the React starter to have a router?
  • Yes
  • No
  • YES and more(tailwing, for example) – please reply with your ideas
0 voters

This is an interesting use case. However, React Router framework mode does not seem to have direct support for Rspack (the engine), only for Rsbuild (a friendly builder on top of the engine).

Rspack = the fast, Webpack-compatible bundler (the engine).
Rsbuild = the nice developer-friendly build tool on top of Rspack (the whole car).

And that’s why you can’t drop something like:

pluginReactRouter()
pluginReact()

into a plain Rspack config, those are Rsbuild plugins, not Rspack plugins.

They only work because Rsbuild has its own plugin system and then generates Rspack config behind the scenes.

If you want that same behavior in pure Rspack, you’d have to get the Rsbuild plugin’s source, see what Rspack settings it creates, and copy that setup manually. Or wait or request that in the official React Router repository to have also a proper rspack engine support.

Anyway, finding a way to use Rsbuild plugins with Rspack is something I would be interested in exploring. There may be ways to automate it. I suggest moving this into a separate forum post to start a focused experimentation process.


Btw, using react-router in NPM library mode is entirely possible. Only this framework mode which gets closer to the bundler requires advanced setup.