fix: Vite 8 (Rolldown) compatibility for content scripts#1149
Conversation
Made-with: Cursor
|
|
@Toumash can you look at this? I can update the failed tests if you're ready to merge it |
|
I'm not sure if it's the same issue or not (I've haven't dug into it yet), but I also had an issue where I had a content script and service_worker script both named I'm using Vite 8. |
|
@Toumash ping |
| source: worldMainIds.has(script.id) | ||
| ? createProMainLoader({ | ||
| fileName: `./${fileName.split('/').at(-1)}`, | ||
| fileName: `../${fileName}`, |
There was a problem hiding this comment.
i'm not sure about the subdirectory why would it need a different behavior than a line below
: createProLoader({ fileName }),There was a problem hiding this comment.
It just works this way. If you want to see something like createProMainLoader({ fileName }) I can change createProMainLoader
Summary
Two fixes for Vite 8 (Rolldown) compatibility when building Chrome extensions with content scripts:
Duplicate refIds:
this.emitFile({ type: "chunk", name: basename(file) })returns the samerefIdfor different files with the same basename (e.g.seller/content.tsx,cmp/content.tsx,marketplace/content.tsx). Only the first script gets itsfileNameresolved; the rest fail withContent script fileName is undefined.Wrong MAIN world loader path: The loader uses
./${fileName.split("/").at(-1)}which loses the subdirectory, producing a broken path.