-
-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importing a CommonJS node_module in a custom service worker turns it into an ES module #615
Comments
It seems a problem with esbuild: vitejs/vite#15379 EDIT: SvelteKit now builds the service worker using also |
FYI we're reverting that change in favour of telling |
@Rich-Harris good to know it, thx How about |
that wouldn't make sense — this is the output filename. it's purely a signal to |
yeah, forgot it |
I've discovered that creating a custom service worker using the
injectManifest
strategy can lead to an issue when importing anode_module
that is in the CommonJS format. Specifically, the service worker will end up as an ES module, with anexport default
, which will result in an error when registered in the browser. The built asset will look something like this:I've created this minimal reproduction case here.
I've discovered that adding this to the config gets rid of the default export, but I'm not sure if it has other side-effects:
The text was updated successfully, but these errors were encountered: