-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildWorker.js
62 lines (53 loc) · 1.72 KB
/
buildWorker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import * as esbuild from 'esbuild';
import sveltePlugin from 'esbuild-svelte';
import { writeFileSync, mkdirSync } from 'fs';
// Build the worker
async function buildInitialUpdateWorker() {
const result = await esbuild.build({
entryPoints: ['worker/initialUpdate.js'],
conditions: ['svelte'],
bundle: true,
platform: 'node',
target: 'node22',
format: 'esm',
outfile: './src/lib/worker/initialUpdate.js',
write: false,
plugins: [sveltePlugin()],
});
// Ensure dist directory exists
mkdirSync('src/lib/worker/initialUpdate', { recursive: true });
writeFileSync('src/lib/worker/initialUpdate/worker.js', result.outputFiles[0].contents);
}
async function buildToHTMLWorker() {
const result = await esbuild.build({
entryPoints: ['worker/toHTML.js'],
conditions: ['svelte'],
bundle: true,
platform: 'node',
target: 'node22',
format: 'esm',
outfile: './src/lib/worker/toHTML.js',
write: false,
plugins: [sveltePlugin()],
});
// Ensure dist directory exists
mkdirSync('src/lib/worker/toHTML', { recursive: true });
writeFileSync('src/lib/worker/toHTML/worker.js', result.outputFiles[0].contents);
}
async function buildYoutubeClipURL() {
const result = await esbuild.build({
entryPoints: ['worker/youtubeClipURL.js'],
bundle: true,
platform: 'node',
target: 'node22',
format: 'esm',
outfile: './src/lib/worker/youtubeClipURL.js',
write: false,
});
// Ensure dist directory exists
mkdirSync('src/lib/worker/youtubeClipURL', { recursive: true });
writeFileSync('src/lib/worker/youtubeClipURL/worker.js', result.outputFiles[0].contents);
}
buildInitialUpdateWorker().catch(() => process.exit(1));
buildToHTMLWorker().catch(() => process.exit(1));
buildYoutubeClipURL().catch(() => process.exit(1));