Skip to content
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

Revert "fix: build service workers in IIFE format" #11400

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/green-cycles-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: prevent esbuild adding phantom exports to service worker
benmccann marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 0 additions & 5 deletions .changeset/tricky-meals-perform.md

This file was deleted.

9 changes: 5 additions & 4 deletions packages/kit/src/exports/vite/build/build_service_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ export async function build_service_worker(
'service-worker': service_worker_entry_file
},
output: {
// default 'es' format would be nicer
// iife is workaround for https://github.com/vitejs/vite/issues/15379
format: 'iife',
entryFileNames: '[name].js',
// .mjs so that esbuild doesn't incorrectly inject `export` https://github.com/vitejs/vite/issues/15379
entryFileNames: 'service-worker.mjs',
assetFileNames: `${kit.appDir}/immutable/assets/[name].[hash][extname]`,
inlineDynamicImports: true
}
Expand All @@ -95,4 +93,7 @@ export async function build_service_worker(
}
}
});

// rename .mjs to .js to avoid incorrect MIME types with ancient webservers
fs.renameSync(`${out}/client/service-worker.mjs`, `${out}/client/service-worker.js`);
}
Loading