crxjs / chrome-extension-tools

Bundling Chrome Extensions can be pretty complex. It doesn't have to be.
https://crxjs.dev/vite-plugin
2.97k stars 191 forks source link

[crx:manifest-post] Content script fileName is undefined: "src/content.ts" #883

Closed abhigyantrips closed 5 months ago

abhigyantrips commented 6 months ago

Build tool

Vite

Where do you see the problem?

Describe the bug

I'm utilizing CRXJS with Vite and SolidStart. I've described the manifest in the Vite config, and the background.ts file is loading normally. The issue is that the content-script.ts file is throwing an error on build.

Reproduction

The code is available at https://github.com/abhigyantrips/tab-closer/tree/feat/solidjs-rewrite. All mentioned files are available in src/. The error is faced on cloning the project and running npm run build (after npm install :P).

Logs

⚙  Building your app...
removing F:/tab-closer/.vinxi/build/ssr

📦 Compiling ssr router...
vinxi building router ssr in http mode
vite v5.2.11 building SSR bundle for production...
"mergeRefs" is imported from external module "@solid-primitives/refs" but never used in "node_modules/@kobalte/utils/dist/index.js".
✓ 118 modules transformed.
.vinxi/build/ssr/service-worker-loader.js               0.05 kB
.vinxi/build/ssr/assets/content.ts-loader-iUh_24Np.js   0.34 kB
.vinxi/build/ssr/manifest.json                          0.93 kB
.vinxi/build/ssr/.vite/manifest.json                    2.32 kB
.vinxi/build/ssr/public/assets/icon-on-128.png          5.78 kB
.vinxi/build/ssr/assets/ssr-CxdLN8pU.css               24.82 kB
.vinxi/build/ssr/popup.js                               0.14 kB
.vinxi/build/ssr/assets/popup.tsx-BZSiFoYh.js           0.14 kB
.vinxi/build/ssr/assets/content.ts-BERceQR4.js          0.18 kB
.vinxi/build/ssr/assets/background.ts-B2ktewxN.js       0.32 kB
.vinxi/build/ssr/settings.js                            0.61 kB
.vinxi/build/ssr/assets/settings.tsx-R0cjdkUR.js        0.61 kB
.vinxi/build/ssr/_...404_.js                            1.46 kB
.vinxi/build/ssr/assets/routing-SYe4eumR.js             7.61 kB
.vinxi/build/ssr/ssr.js                                22.18 kB
✓ built in 5.08s
✔ build done                                                                                                   11:12:29 pm

📦 Compiling client router...
vinxi building router client in client mode
vite v5.2.11 building for production...
virtual:#vinxi/handler/client (1:78): "default" is not exported by "src/entry-client.tsx", imported by "virtual:#vinxi/handler/client".
✓ 169 modules transformed.
x Build failed in 3.06s

 ERROR  [crx:manifest-post] Content script fileName is undefined: "src/content.ts"                              11:12:32 pm  

  at /F:/tab-closer/node_modules/@crxjs/vite-plugin/dist/index.mjs:1654:27
  at Array.map (<anonymous>)
  at /F:/tab-closer/node_modules/@crxjs/vite-plugin/dist/index.mjs:1650:24
  at Array.map (<anonymous>)
  at Object.generateBundle (/F:/tab-closer/node_modules/@crxjs/vite-plugin/dist/index.mjs:1647:66)
  at /F:/tab-closer/node_modules/rollup/dist/es/shared/node-entry.js:19778:40
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

 ERROR  [crx:manifest-post] Content script fileName is undefined: "src/content.ts"

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (8) x64 Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
    Memory: 1.31 GB / 7.79 GB
  Binaries:
    Node: 21.1.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.21 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.5.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (123.0.2420.97)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @crxjs/vite-plugin: ^2.0.0-beta.23 => 2.0.0-beta.23

Severity

blocking all usage of RPCE

abhigyantrips commented 6 months ago

Man, the lack of support or any form of communication channel for this library is disappointing.

CRXJS is being advertised everywhere as the best way to start building extensions with Vite, and yet every single blog/doc - even the library itself - is extremely outdated. With the fairly large userbase I would've atleast expected a Discord forum where you can easily discuss with authors and other devs but the most I can do here is leave a rant on an issue that will possibly never be resolved. See y'all.

Toumash commented 6 months ago

@abhigyantrips the code is unavailable. No way to reproduce it. If nothing changes the issue is gonna be closed. You mentioned content-script.ts yet the error is actually about content.ts

abhigyantrips commented 5 months ago

Thank you for pointing that out, the error was about src/content.ts because I'd tried renaming the file to see if that sorted the issue (nope). I apologize for the confusion in the issue, but I can confirm that the manifest.ts file listed the correct filepath.

It was three weeks ago, though. I've since then shifted the extension to Plasmo which is well-updated and fulfilling my requirements. I was actually able to publish the dang thing!

(Also I'll close this issue since it's now irrelevant.)