rolldown: [Bug]: Remix support

Discussed in https://github.com/rolldown/rolldown/discussions/3868

<div type='discussions-op-text'>

Originally posted by zaaack March 16, 2025 Add these config cause remix project broken,

   esbuild: false,
  experimental: {
     enableNativePlugin: true,
  },
error log

$ pnpm build

server@ build /home/z/my-remix-starter remix vite:build

vite v6.2.1 building for production… The built-in minifier is still under development. Setting “minify: true” is not recommended for production use. ✓ 66 modules transformed. ✗ Build failed in 193ms Build failed with 3 errors: [plugin remix] /home/z/my-remix-starter/app/root.tsx?remix-build-client-route:25:8 Error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you use tsconfig.json, make sure to not set jsx to preserve. 23 | <ScrollRestoration /> 24 | <Scripts /> 25 | </> | ^ 26 | ); 27 | // return ( at TransformPluginContext.formatLog (file:///home/z/my-remix-starter/node_modules/.pnpm/vite@https+++pkg.pr.new+vitejs+rolldown-vite+vite@c90496e@types+node@22.13.10_esbuild@0.17.6_fxj4mtsvfzgibfkolutqnhel5y/node_modules/vite/dist/node/chunks/dep-D3pz0UHr.js:45999:41) at TransformPluginContext.error (file:///home/z/my-remix-starter/node_modules/.pnpm/vite@https+++pkg.pr.new+vitejs+rolldown-vite+vite@c90496e@types+node@22.13.10_esbuild@0.17.6_fxj4mtsvfzgibfkolutqnhel5y/node_modules/vite/dist/node/chunks/dep-D3pz0UHr.js:45996:16) at TransformPluginContext.transform (file:///home/z/my-remix-starter/node_modules/.pnpm/vite@https+++pkg.pr.new+vitejs+rolldown-vite+vite@c90496e@types+node@22.13.10_esbuild@0.17.6_fxj4mtsvfzgibfkolutqnhel5y/node_modules/vite/dist/node/chunks/dep-D3pz0UHr.js:43898:14) at EnvironmentPluginContainer.transform (file:///home/z/my-remix-starter/node_modules/.pnpm/vite@https+++pkg.pr.new+vitejs+rolldown-vite+vite@c90496e_@types+node@22.13.10_esbuild@0.17.6_fxj4mtsvfzgibfkolutqnhel5y/node_modules/vite/dist/node/chunks/dep-D3pz0UHr.js:45786:18) at getRouteModuleExports (/home/z/my-remix-starter/node_modules/.pnpm/@remix-run+dev@2.16.0_@remix-run+react@2.16.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_typ_nqmrhs457ahbljv2gtrangiacq/node_modules/@remix-run/dev/dist/vite/plugin.js:235:21) at TransformPluginContextImpl.transform (/home/z/my-remix-starter/node_modules/.pnpm/@remix-run+dev@2.16.0_@remix-run+react@2.16.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_typ_nqmrhs457ahbljv2gtrangiacq/node_modules/@remix-run/dev/dist/vite/plugin.js:798:29) at plugin (file:///home/z/my-remix-starter/node_modules/.pnpm/rolldown@1.0.0-beta.3-commit.e170e6e_@oxc-project+runtime@0.56.5_typescript@5.6.3/node_modules/rolldown/dist/shared/src-CTS_IQ3m.mjs:1395:16) at plugin.<computed> (file:///home/z/my-remix-starter/node_modules/.pnpm/rolldown@1.0.0-beta.3-commit.e170e6e_@oxc-project+runtime@0.56.5_typescript@5.6.3/node_modules/rolldown/dist/shared/src-CTS_IQ3m.mjs:1923:12) [plugin remix] /home/z/my-remix-starter/app/routes/admin.$/route.tsx?remix-build-client-route:17:42 Error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you use tsconfig.json, make sure to not set jsx to preserve. 15 | },[]) 16 | return ( 17 | <div id=“admin-root”>Loading…</div> | ^ 18 | ); 19 | } at TransformPluginContext.formatLog (file:///home/z/my-remix-starter/node_modules/.pnpm/vite@https+++pkg.pr.new+vitejs+rolldown-vite+vite@c90496e@types+node@22.13.10_esbuild@0.17.6_fxj4mtsvfzgibfkolutqnhel5y/node_modules/vite/dist/node/chunks/dep-D3pz0UHr.js:45999:41) at TransformPluginContext.error (file:///home/z/my-remix-starter/node_modules/.pnpm/vite@https+++pkg.pr.new+vitejs+rolldown-vite+vite@c90496e@types+node@22.13.10_esbuild@0.17.6_fxj4mtsvfzgibfkolutqnhel5y/node_modules/vite/dist/node/chunks/dep-D3pz0UHr.js:45996:16) at TransformPluginContext.transform (file:///home/z/my-remix-starter/node_modules/.pnpm/vite@https+++pkg.pr.new+vitejs+rolldown-vite+vite@c90496e@types+node@22.13.10_esbuild@0.17.6_fxj4mtsvfzgibfkolutqnhel5y/node_modules/vite/dist/node/chunks/dep-D3pz0UHr.js:43898:14) at EnvironmentPluginContainer.transform (file:///home/z/my-remix-starter/node_modules/.pnpm/vite@https+++pkg.pr.new+vitejs+rolldown-vite+vite@c90496e_@types+node@22.13.10_esbuild@0.17.6_fxj4mtsvfzgibfkolutqnhel5y/node_modules/vite/dist/node/chunks/dep-D3pz0UHr.js:45786:18) at getRouteModuleExports (/home/z/my-remix-starter/node_modules/.pnpm/@remix-run+dev@2.16.0_@remix-run+react@2.16.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_typ_nqmrhs457ahbljv2gtrangiacq/node_modules/@remix-run/dev/dist/vite/plugin.js:235:21) at TransformPluginContextImpl.transform (/home/z/my-remix-starter/node_modules/.pnpm/@remix-run+dev@2.16.0_@remix-run+react@2.16.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_typ_nqmrhs457ahbljv2gtrangiacq/node_modules/@remix-run/dev/dist/vite/plugin.js:798:29) at plugin (file:///home/z/my-remix-starter/node_modules/.pnpm/rolldown@1.0.0-beta.3-commit.e170e6e_@oxc-project+runtime@0.56.5_typescript@5.6.3/node_modules/rolldown/dist/shared/src-CTS_IQ3m.mjs:1395:16) at plugin.<computed> (file:///home/z/my-remix-starter/node_modules/.pnpm/rolldown@1.0.0-beta.3-commit.e170e6e_@oxc-project+runtime@0.56.5_typescript@5.6.3/node_modules/rolldown/dist/shared/src-CTS_IQ3m.mjs:1923:12) [plugin remix] /home/z/my-remix-starter/app/routes/index/route.tsx?remix-build-client-route:13:28 Error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you use tsconfig.json, make sure to not set jsx to preserve. 11 | return ( 12 | <div> 13 | <h1>Hello World!</h1> | ^ 14 | </div> 15 | ); at TransformPluginContext.formatLog (file:///home/z/my-remix-starter/node_modules/.pnpm/vite@https+++pkg.pr.new+vitejs+rolldown-vite+vite@c90496e@types+node@22.13.10_esbuild@0.17.6_fxj4mtsvfzgibfkolutqnhel5y/node_modules/vite/dist/node/chunks/dep-D3pz0UHr.js:45999:41) at TransformPluginContext.error (file:///home/z/my-remix-starter/node_modules/.pnpm/vite@https+++pkg.pr.new+vitejs+rolldown-vite+vite@c90496e@types+node@22.13.10_esbuild@0.17.6_fxj4mtsvfzgibfkolutqnhel5y/node_modules/vite/dist/node/chunks/dep-D3pz0UHr.js:45996:16) at TransformPluginContext.transform (file:///home/z/my-remix-starter/node_modules/.pnpm/vite@https+++pkg.pr.new+vitejs+rolldown-vite+vite@c90496e@types+node@22.13.10_esbuild@0.17.6_fxj4mtsvfzgibfkolutqnhel5y/node_modules/vite/dist/node/chunks/dep-D3pz0UHr.js:43898:14) at EnvironmentPluginContainer.transform (file:///home/z/my-remix-starter/node_modules/.pnpm/vite@https+++pkg.pr.new+vitejs+rolldown-vite+vite@c90496e@types+node@22.13.10_esbuild@0.17.6_fxj4mtsvfzgibfkolutqnhel5y/node_modules/vite/dist/node/chunks/dep-D3pz0UHr.js:45786:18) at getRouteModuleExports (/home/z/my-remix-starter/node_modules/.pnpm/@remix-run+dev@2.16.0_@remix-run+react@2.16.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_typ_nqmrhs457ahbljv2gtrangiacq/node_modules/@remix-run/dev/dist/vite/plugin.js:235:21) at TransformPluginContextImpl.transform (/home/z/my-remix-starter/node_modules/.pnpm/@remix-run+dev@2.16.0_@remix-run+react@2.16.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_typ_nqmrhs457ahbljv2gtrangiacq/node_modules/@remix-run/dev/dist/vite/plugin.js:798:29) at plugin (file:///home/z/my-remix-starter/node_modules/.pnpm/rolldown@1.0.0-beta.3-commit.e170e6e_@oxc-project+runtime@0.56.5_typescript@5.6.3/node_modules/rolldown/dist/shared/src-CTS_IQ3m.mjs:1395:16) at plugin.<computed> (file:///home/z/my-remix-starter/node_modules/.pnpm/rolldown@1.0.0-beta.3-commit.e170e6e_@oxc-project+runtime@0.56.5_typescript@5.6.3/node_modules/rolldown/dist/shared/src-CTS_IQ3m.mjs:1923:12)

at normalizeErrors (file:///home/z/my-remix-starter/node_modules/.pnpm/rolldown@1.0.0-beta.3-commit.e170e6e_@oxc-project+runtime@0.56.5_typescript@5.6.3/node_modules/rolldown/dist/shared/src-CTS_IQ3m.mjs:807:18)
at handleOutputErrors (file:///home/z/my-remix-starter/node_modules/.pnpm/rolldown@1.0.0-beta.3-commit.e170e6e_@oxc-project+runtime@0.56.5_typescript@5.6.3/node_modules/rolldown/dist/shared/src-CTS_IQ3m.mjs:995:34)
at transformToRollupOutput (file:///home/z/my-remix-starter/node_modules/.pnpm/rolldown@1.0.0-beta.3-commit.e170e6e_@oxc-project+runtime@0.56.5_typescript@5.6.3/node_modules/rolldown/dist/shared/src-CTS_IQ3m.mjs:989:2)
at RolldownBuild.write (file:///home/z/my-remix-starter/node_modules/.pnpm/rolldown@1.0.0-beta.3-commit.e170e6e_@oxc-project+runtime@0.56.5_typescript@5.6.3/node_modules/rolldown/dist/shared/src-CTS_IQ3m.mjs:2655:10)
at buildEnvironment (file:///home/z/my-remix-starter/node_modules/.pnpm/vite@https+++pkg.pr.new+vitejs+rolldown-vite+vite@c90496e_@types+node@22.13.10_esbuild@0.17.6_fxj4mtsvfzgibfkolutqnhel5y/node_modules/vite/dist/node/chunks/dep-D3pz0UHr.js:49712:16)
at viteBuild (/home/z/my-remix-starter/node_modules/.pnpm/@remix-run+dev@2.16.0_@remix-run+react@2.16.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_typ_nqmrhs457ahbljv2gtrangiacq/node_modules/@remix-run/dev/dist/vite/build.js:212:5)
at build (/home/z/my-remix-starter/node_modules/.pnpm/@remix-run+dev@2.16.0_@remix-run+react@2.16.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_typ_nqmrhs457ahbljv2gtrangiacq/node_modules/@remix-run/dev/dist/vite/build.js:236:3)
at Object.viteBuild (/home/z/my-remix-starter/node_modules/.pnpm/@remix-run+dev@2.16.0_@remix-run+react@2.16.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_typ_nqmrhs457ahbljv2gtrangiacq/node_modules/@remix-run/dev/dist/cli/commands.js:184:5)
at Object.run (/home/z/my-remix-starter/node_modules/.pnpm/@remix-run+dev@2.16.0_@remix-run+react@2.16.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_typ_nqmrhs457ahbljv2gtrangiacq/node_modules/@remix-run/dev/dist/cli/run.js:252:7) {

errors: [Getter/Setter] }  ELIFECYCLE  Command failed with exit code 1.

</div>

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 36 (24 by maintainers)

Commits related to this issue

Most upvoted comments

Is still happening with React-Router (7.3.5), if we need a repro I can setup one.

Related to https://github.com/vitejs/rolldown-vite/issues/100#issuecomment-2774442401

We need to make native plugins runnable within the pluginContainer on the Node side, which might take some time to implement. Without enabling native plugins, this issue should not be encountered.

I have measured the differences between nativeTransformPlugin and oxcPlugin as follows: [info] nativeTransformPlugin: 1.50s [info] oxc: 1.45s

Interesting,

Due to potential processor-related issues, the results may not be entirely accurate. Currently, nativeTransformPlugin is faster than oxcPlugin again.

[info] nativeTransformPlugin: 1.41s [info] oxc: 1.45s

Ok, so let 's use option two, align with https://github.com/vitejs/rolldown-vite/blob/fa33494473d41956fa16ae441d9a4be98bd192d0/packages/vite/src/node/plugins/oxc.ts?plain=1#L297-L396

I have measured the differences between nativeTransformPlugin and oxcPlugin as follows: [info] nativeTransformPlugin: 1.50s [info] oxc: 1.45s

Interesting,

Due to potential processor-related issues, the results may not be entirely accurate. Currently, nativeTransformPlugin is faster than oxcPlugin again.

[info] nativeTransformPlugin: 1.41s
[info] oxcPlugin: 1.45s

Here is the result on my computer after remove vite-react-plugin,

diff --git a/vite.config.ts b/vite.config.ts
index 3d573f3..8a71733 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -2,7 +2,7 @@ import react from "@vitejs/plugin-react";
 import { defineConfig } from "vite";
 
 export default defineConfig({
-  plugins: [react()],
+  // plugins: [react()],
   build: {
     outDir: `dist/vite${process.env.enableNativePlugin? 'NativePlugin': ''}`,
   },

[info] vite: 3.75s [info] viteNativePlugin: 1.55s [info] esbuild: 0.88s [info] rsbuild: 3.20s

I have measured the differences between nativeTransformPlugin and oxcPlugin as follows:

[info] nativeTransformPlugin: 1.50s [info] oxc: 1.45s

Interesting,

@IWANABETHATGUY here is an example project for perfomance compare: https://github.com/zaaack/rolldown-perf

Result:

Task: perf [info] vite: 6.45s [info] viteNativePlugin: 3.51s [info] esbuild: 1.07s [info] rsbuild: 5.90s

You don’t need react plugin anymore if you use rolldown-vite

I have measured the differences between nativeTransformPlugin and oxcPlugin as follows (need to hack internal logic):

[info] nativeTransformPlugin: 1.50s
[info] oxcPlugin: 1.45s

If we only look at nativeTransformPlugin, perhaps we should test it this way? Are we only replacing nativeTransformPlugin with oxcPlugin as mentioned above?

task('vite:enableNativePlugin', async (ctx) => {
  let now = performance.now()
  await ctx.env('enableNativePlugin=true').exec('vite build')
  PerfResult.viteNativePlugin = performance.now() - now
})

task('vite:esbuild', async (ctx) => {
  let now = performance.now()
  await ctx.env('enableNativePlugin=true esbuild=true').exec('vite build')
  PerfResult.esbuild = performance.now() - now
})
[info] vite: 3.97s
[info] viteNativePlugin: 1.56s
[info] esbuild: 1.46s
[info] rsbuild: 2.60s