Skip to content

Commit 4145e1e

Browse files
committed
Inline browser worker dependencies to avoid chunk copying issues
1 parent 384b718 commit 4145e1e

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

packages/sdk/rollup.config.mts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const WORKERS: Record<string, string> = {
4040

4141
export default defineConfig([
4242
workersNodejs(),
43-
workersBrowser(),
43+
...workersBrowser(),
4444
nodejs(),
4545
nodejsTypes(),
4646
browser(),
@@ -250,18 +250,17 @@ function workersNodejs(): RollupOptions {
250250

251251
/**
252252
* All worker bundles for browser - ESM format for use with web-worker {type: 'module'}
253+
* Each worker is built as a self-contained bundle with all dependencies inlined.
254+
* This avoids issues with webpack/karma not copying associated chunk files.
253255
*/
254-
function workersBrowser(): RollupOptions {
255-
return {
256-
input: Object.fromEntries(
257-
Object.entries(WORKERS).map(([name, path]) => [name, `./dist/browser/src/${path}.js`])
258-
),
256+
function workersBrowser(): RollupOptions[] {
257+
return Object.entries(WORKERS).map(([name, path]) => ({
258+
input: `./dist/browser/src/${path}.js`,
259259
context: 'self',
260260
output: {
261261
format: 'es',
262-
dir: './dist/workers',
263-
entryFileNames: '[name].browser.mjs',
264-
chunkFileNames: '[name]-[hash].browser.mjs',
262+
file: `./dist/workers/${name}.browser.mjs`,
263+
inlineDynamicImports: true,
265264
sourcemap: true,
266265
},
267266
plugins: [
@@ -277,5 +276,5 @@ function workersBrowser(): RollupOptions {
277276
],
278277
external: [],
279278
onwarn,
280-
}
279+
}))
281280
}

0 commit comments

Comments
 (0)