Open kayluhb opened 3 months ago
What does your entry worker look like?
The built service worker is meant to be a standalone js file, meaning no exports. But somehow, your entry.worker file gets built with export
still present
The entry worker looks like this
https://gist.github.com/kayluhb/d2e1d0cac8b99d53af45339aa52972e2
@ShafSpecs I had similar problem, check https://github.com/vite-pwa/vite-plugin-pwa/pull/629
Thanks! Would try and replicate it here as well đź‘Ť
@ShafSpecs I had similar problem, check vite-pwa/vite-plugin-pwa#629
@userquin Would building into mjs
format, then simply renaming to js
fix the export issue though? Or do I transform whilst renaming? Looking at his built worker, it's built in a completely different format for some reason:
var __getOwnPropNames = Object.getOwnPropertyNames;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var require_entry_worker = __commonJS({
// ...
});
export default require_entry_worker();
Instead of as a script
Rename the js file to mjs (change the rollup input to the mjs file) before Vite build call, then rename it back to the original (don't forget to change also sourcemap file and reference in the js file): the problem is about using esbuild in Vite minify option (the default): check Vite issue https://github.com/vitejs/vite/issues/15379#issuecomment-1861493128
You can try switching Vite minify option to terser (will require adding the dependency).
Hello!
I'm trying to implement remix-pwa and I'm having an issue with the browser loading the
entry.worker.js
versions:
"@remix-pwa/dev": "^3.0.5", "@remix-pwa/worker-runtime": "^2.1.2", "@remix-run/react": "^2.8.0", "@remix-run/server-runtime": "^2.8.0",
my vite config looks like this
Any ideas on what might be wrong w/ my config?