crxjs / chrome-extension-tools

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

"Could not resolve entry module (../../../../../@vite/client)." error when running `vite build --watch` #323

Open DetachHead opened 2 years ago

DetachHead commented 2 years ago

Build tool

Vite

Where do you see the problem?

Describe the bug

>npx vite build --watch 
vite v2.9.5 building for production...

watching for file changes...

build started...
✓ 2 modules transformed.
Could not resolve entry module (../../../../../@vite/client).

Reproduction

//vite.config.ts
import { chromeExtension } from 'rollup-plugin-chrome-extension'
import { defineConfig } from 'vite'
import manifest from './src/manifest.json'

export default defineConfig(() => {
    return {
        plugins: [chromeExtension({ manifest })],
    }
})

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (6) x64 Intel(R) Core(TM) i5-8600 CPU @ 3.10GHz
    Memory: 1.58 GB / 15.78 GB
  Binaries:
    Node: 18.0.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.7.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 99.0.4844.84
    Edge: Spartan (44.19041.1266.0), Chromium (99.0.1150.55)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    rollup-plugin-chrome-extension: ^4.0.1-24 => 4.0.1-24
    vite: ^2.9.5 => 2.9.5

nb: using rollup-plugin-chrome-extension patched with #322

Severity

blocking all usage of RPCE

jacksteamdev commented 2 years ago

@DetachHead We're not supporting vite build --watch right now. The development build is highly specialized for the Vite development server, so it's kind of a big feature.

What's your use case where you can't use the normal Vite dev server?

DetachHead commented 2 years ago

I'm developing a chrome extension, using web-ext to automatically reload the extension on change. Unfortunately that means I can't use the dev server since it needs to watch the dist directory for changes then reinstall the extension from there whenever there's a change

punithbm commented 2 years ago

@jacksteamdev we are also having a similar scenario that @DetachHead is facing. Are there any plans to add support for vite build --watch anytime soon?

jacksteamdev commented 2 years ago

@crxjs/vite-plugin@2.0.0-beta.1 features a complete rewrite of the code that caused this bug. I haven't tested it extensively, but it may work: https://www.npmjs.com/package/@crxjs/vite-plugin/v/2.0.0-beta.1

milahu commented 1 year ago

it may work

it works : )