Lazily create resources for worker

This commit is contained in:
Tim Schaub
2021-12-14 16:54:06 -07:00
parent 35a6825f74
commit 6958ca3101

View File

@@ -43,10 +43,10 @@ async function build(input, {minify = true} = {}) {
name: 'serialize worker and export create function',
renderChunk(code) {
return `
const source = ${JSON.stringify(code)};
const blob = new Blob([source], {type: 'application/javascript'});
const url = URL.createObjectURL(blob);
export function create() {
const source = ${JSON.stringify(code)};
const blob = new Blob([source], {type: 'application/javascript'});
const url = URL.createObjectURL(blob);
return new Worker(url);
}
`;