bug report for crxjs/chrome-extension-tools
Imagine 2 files:
entry.js
referenced and load fromservice-script-loader.js
that importsanother.js
- and
another.js
imported toentry.js
.
So this 2 files reference each other, that happens but not an issue since postpone any execution runtime.onInstall
, and it all works on initial vite dev
.
Problems starts when update one of the files. If you update another.js
the entry.js
, the plugin will reload and the following chain of events will happed.
service-script-loader.js
will import un-timestampedentry.js
since loader is only emitted once at the launch ofvite
entry.js
will reference and import timestampedanother.js?t=xxx
sinceentry.js
is dynamically generated.another.js?t=xxx
will import timestampedentry.js?t=xxx
Browser thinks that entry.js
and entry.js?t=xxx
are two different modules and executes the code twice.
I'm not familiar with rollup and vite plugins enough to attempt to fix it myself, but if someone is wiling to give me advice on how to reemit service-script-loader.js
on HRM event, I'm wiling to try.
For now the workaround I use is to add static one line entry point that only import './entry.js'
- run 'vite'
- install the extension
- change ./another to cause
reload
- get some.