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

unable to run the dev script command #875

Closed hyusetiawan closed 5 months ago

hyusetiawan commented 8 months ago

Build tool

Rollup

Where do you see the problem?

Describe the bug

I actually don't know if the build tool is vite or rollup, the error stack here shows both vite and rollup. But whenever I run the vite command for the dev server to start, it will show the error stack, copy pasted below. Interestingly the file it's complaining can be different whenever I run the vite command.

This issue causes the build to stop and the chrome extension uses the last proper build. After trying by re-running the dev server 10-13 times, it can sometimes not show this error and it will work as it should.

Reproduction

I just run pnpm dev and the underlying command is vite

Logs

> vite --force

Forced re-optimization of dependencies

  VITE v5.1.6  ready in 235 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
1:02:20 PM [crx] files start dist
1:02:21 PM [vite] ✨ optimized dependencies changed. reloading
1:02:21 PM [crx] error from file writer:
Error: Could not load /node_modules-.vite-deps-dayjs_plugin_localizedFormat.js-wEJ5i.js (imported by ../../../../../common-date.ts-d3EUj.js): There is a new version of the pre-bundle for "/Users/wahyu/Projects/halosignal/apps/node_modules/.vite/deps/dayjs_plugin_localizedFormat.js?v=847a1ecd", a page reload is going to ask for it.
    at throwOutdatedRequest (file:///Users/wahyu/Projects/halosignal/apps/node_modules/.pnpm/vite@5.1.6_@types+node@20.11.27/node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:48786:17)
    at Context.load (file:///Users/wahyu/Projects/halosignal/apps/node_modules/.pnpm/vite@5.1.6_@types+node@20.11.27/node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:48742:25)
    at Object.load (file:///Users/wahyu/Projects/halosignal/apps/node_modules/.pnpm/vite@5.1.6_@types+node@20.11.27/node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:50927:64)
    at loadAndTransform (file:///Users/wahyu/Projects/halosignal/apps/node_modules/.pnpm/vite@5.1.6_@types+node@20.11.27/node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:53670:46)
    at doTransform (file:///Users/wahyu/Projects/halosignal/apps/node_modules/.pnpm/vite@5.1.6_@types+node@20.11.27/node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:53639:20)
    at async Object.load (file:///Users/wahyu/Projects/halosignal/apps/node_modules/.pnpm/@crxjs+vite-plugin@1.0.14_vite@5.1.6/node_modules/@crxjs/vite-plugin/dist/index.mjs:255:29)
    at async file:///Users/wahyu/Projects/halosignal/apps/node_modules/.pnpm/rollup@2.79.1/node_modules/rollup/dist/es/shared/rollup.js:21919:98
    at async Queue.work (file:///Users/wahyu/Projects/halosignal/apps/node_modules/.pnpm/rollup@2.79.1/node_modules/rollup/dist/es/shared/rollup.js:22858:32)

System Info

System:
    OS: macOS 14.3.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 71.63 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.5.0 - /opt/homebrew/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.2.4 - /opt/homebrew/bin/npm
    pnpm: 8.15.4 - ~/Library/pnpm/pnpm
  Browsers:
    Brave Browser: 108.1.46.144
    Chrome: 122.0.6261.129
    Edge: 122.0.2365.80
    Safari: 17.3.1
  npmPackages:
    @crxjs/vite-plugin: ^1.0.14 => 1.0.14
    vite: ^5.1.6 => 5.1.6

Severity

blocking all usage of RPCE

flazouh commented 6 months ago

Got the same issue.

Toumash commented 6 months ago

@hyusetiawan please provide a working reproduction. It looks like the issue is connected with dayjs

hyusetiawan commented 5 months ago

I forgot how I resolved this, closing as there is no concrete next step