From 5f052a34572f439894ade2c6ef37bae573a96b16 Mon Sep 17 00:00:00 2001 From: Justin Bailey Date: Mon, 18 Dec 2023 17:42:23 -0600 Subject: [PATCH] fix: build service workers in IIFE format (#11129) --- .changeset/tricky-meals-perform.md | 5 +++++ packages/kit/src/exports/vite/build/build_service_worker.js | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 .changeset/tricky-meals-perform.md diff --git a/.changeset/tricky-meals-perform.md b/.changeset/tricky-meals-perform.md new file mode 100644 index 000000000000..029af8321852 --- /dev/null +++ b/.changeset/tricky-meals-perform.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: build service workers in IIFE format diff --git a/packages/kit/src/exports/vite/build/build_service_worker.js b/packages/kit/src/exports/vite/build/build_service_worker.js index 919f6be6646e..8bb292dc68c6 100644 --- a/packages/kit/src/exports/vite/build/build_service_worker.js +++ b/packages/kit/src/exports/vite/build/build_service_worker.js @@ -70,6 +70,9 @@ 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', assetFileNames: `${kit.appDir}/immutable/assets/[name].[hash][extname]`, inlineDynamicImports: true