wxt icon indicating copy to clipboard operation
wxt copied to clipboard

Rolldown support

Open ducan-ne opened this issue 8 months ago • 11 comments

Any plan to support rolldown? It getting more and more traction and it'd be great if wxt support it https://www.npmjs.com/package/rolldown-vite

ducan-ne avatar May 19 '25 18:05 ducan-ne

Vite itself will switch to Rolldown sometime in the near future. There isn't really any advantage in WXT trying to support it before its fully stable with Vite.

ColinMelendez avatar May 23 '25 04:05 ColinMelendez

Vite itself will switch to Rolldown sometime in the near future. There isn't really any advantage in WXT trying to support it before its fully stable with Vite.

That, you can however do a override to swap out vite with rolldown yourself to test using pnpm for example

Timeraa avatar May 23 '25 07:05 Timeraa

Vite itself will switch to Rolldown sometime in the near future. There isn't really any advantage in WXT trying to support it before its fully stable with Vite.

That, you can however do a override to swap out vite with rolldown yourself to test using pnpm for example

I suppose preparing for it doesn’t hurt, especially with regard to the custom Vite plugins in WXT. 😁

TheAlexLichter avatar Jun 05 '25 10:06 TheAlexLichter

@Timeraa tried this out, there is one problem: https://discord.com/channels/1212416027611365476/1224507127863967784/1380229842338975744

[plugin wxt:multipage-move] Error: This plugin assigns to bundle variable. This is discouraged by Rollup and is not supported by Rolldown. This will be ignored.
    at Object.set (file:///Users/timeraa/Developer/PreMiD/Extension-alphaBeta/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/src-C1CX2gm4.mjs:3377:18)
    at PluginContextImpl.writeBundle (file:///Users/timeraa/Developer/PreMiD/Extension-alphaBeta/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/wxt/dist/core/builders/vite/plugins/multipageMove.mjs:40:31)

Here's the rolldown code that throws the error:

https://github.com/rolldown/rolldown/blob/0a985f3e76de2626cba33fe96a4efb4a0ef70c2f/packages/rolldown/src/utils/transform-to-rollup-output.ts#L169

Additionally, there are some custom transforms, loads, and resolves that can take advantage of the new filter pattern.

This happens because I edit with the bundle before files are written to the output directory so I can control where HTML files are written to. But I guess that's discouraged... So we need to find a different way of controlling the output path for HTML files.

https://github.com/wxt-dev/wxt/blob/bfc8866b69d0b52afb92d29601c1cf99f9f06f8b/packages/wxt/src/core/builders/vite/plugins/multipageMove.ts#L63-L68

aklinker1 avatar Jun 05 '25 19:06 aklinker1

Actually, we could try just removing these lines, or moving this logic to the generateBundle hook. We update the bundle for two reasons:

  1. the bundle analysis display the right path
  2. The build output that shows files is correct (maybe, I might read the files off the disk for this, I can't remember)

So first thing we should try is moving this logic into the generateBundle hook.

aklinker1 avatar Jun 05 '25 19:06 aklinker1

OK, looks like HTML files aren't in the bundle until writeBundle. So that won't work :/

aklinker1 avatar Jun 05 '25 19:06 aklinker1

OK, I think I got something working...

aklinker1 avatar Jun 05 '25 20:06 aklinker1

Yup, I have a workaround working for the wxt:multipage-move plugin. See #1715. Will add other optimizations to that PR as well.

aklinker1 avatar Jun 05 '25 20:06 aklinker1

I've broken out the other optimizations into separate issues, they weren't as simple as I thought.

aklinker1 avatar Jun 06 '25 15:06 aklinker1

+1. we're using rolldown-vite in our web app which lives in a monorepo with our chrome extension. we'd love to move to WXT for the extension and being able to use the same version of vite throughout the repo would really simplify the migration.

just-toby avatar Aug 28 '25 18:08 just-toby

You can use it today! There are just a few warnings and performance optimizations we're working on fixing, but it does work on the latest version of WXT

aklinker1 avatar Sep 09 '25 13:09 aklinker1