Skip to content

Commit a571b9e

Browse files
committed
use module workers
1 parent 3b045a6 commit a571b9e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/editor/src/lib/compile-worker/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { BROWSER } from 'esm-env';
2-
import CompileWorker from './worker?worker';
32
import type { Compiled, File } from '../Workspace.svelte';
43

54
const callbacks = new Map<string, Map<number, (compiled: Compiled) => void>>();
@@ -9,7 +8,9 @@ let worker: Worker;
98
let uid = 1;
109

1110
if (BROWSER) {
12-
worker = new CompileWorker();
11+
worker = new Worker(new URL('./worker.ts'), {
12+
type: 'module'
13+
});
1314

1415
worker.addEventListener('message', (event) => {
1516
const { filename, id, payload } = event.data;

packages/repl/src/lib/Bundler.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import type { CompileOptions } from 'svelte/compiler';
21
import type { BundleResult } from './workers/bundler';
3-
import Worker from './workers/bundler/index.js?worker';
42
import type { BundleMessageData } from './workers/workers';
53
import type { File } from 'editor';
64

@@ -27,7 +25,10 @@ export default class Bundler {
2725
this.hash = `${packages_url}:${svelte_version}`;
2826

2927
if (!workers.has(this.hash)) {
30-
const worker = new Worker();
28+
const worker = new Worker(new URL('./workers/bundler/index.ts', import.meta.url), {
29+
type: 'module'
30+
});
31+
3132
worker.postMessage({ type: 'init', packages_url, svelte_version });
3233
workers.set(this.hash, worker);
3334
}

0 commit comments

Comments
 (0)