From 7f346a9d640e3039c67892c9bb3203a0f0fdcc06 Mon Sep 17 00:00:00 2001 From: admirsaheta Date: Fri, 13 Sep 2024 21:04:05 +0200 Subject: [PATCH] add:changeset --- .changeset/spicy-panthers-prove.md | 6 ++++++ packages/web-worker/src/webpack-parts/loader.ts | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changeset/spicy-panthers-prove.md diff --git a/.changeset/spicy-panthers-prove.md b/.changeset/spicy-panthers-prove.md new file mode 100644 index 0000000000..7eb6f352a1 --- /dev/null +++ b/.changeset/spicy-panthers-prove.md @@ -0,0 +1,6 @@ +--- +'@shopify/web-worker': minor +--- + +- Allow `output.chunkFilename` to be a function or string. +- `compiler.options.output.filename` and `compiler.options.output.chunkFilename` now default to `[name].js` when undefined. diff --git a/packages/web-worker/src/webpack-parts/loader.ts b/packages/web-worker/src/webpack-parts/loader.ts index 505ff5ba2f..83f33915ef 100644 --- a/packages/web-worker/src/webpack-parts/loader.ts +++ b/packages/web-worker/src/webpack-parts/loader.ts @@ -78,14 +78,19 @@ export function pitch(this: LoaderContext, request: string) { wrapperContent = cachedContent; } else if (cachedContent == null) { try { - wrapperContent = this.fs.readFileSync(wrapperModule).toString(); - moduleWrapperCache.set(wrapperModule, wrapperContent ?? false); + if (this.fs?.readFileSync) { + wrapperContent = this.fs.readFileSync(wrapperModule).toString(); + moduleWrapperCache.set(wrapperModule, wrapperContent ?? false); + } else { + throw new Error("readFileSync is undefined"); + } } catch (error) { moduleWrapperCache.set(wrapperModule, false); } } } + if (wrapperContent) { plugin.virtualModules.writeModule( virtualModule,