-
Notifications
You must be signed in to change notification settings - Fork 66
/
dev-build.sh
executable file
·86 lines (77 loc) · 2.22 KB
/
dev-build.sh
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env bash
mkdir -p node_modules/single-file-core
cp -R ../single-file-core/* node_modules/single-file-core
echo "
import { build } from 'npm:esbuild';
await build({
entryPoints: [
'node_modules/single-file-core/single-file.js'
],
bundle: true,
globalName: 'singlefile',
outdir: 'lib/',
platform: 'browser',
sourcemap: false,
minify: false,
format: 'iife',
plugins: [],
});
await build({
entryPoints: [
'node_modules/single-file-core/single-file-bootstrap.js'
],
bundle: true,
globalName: 'singlefileBootstrap',
outdir: 'lib/',
platform: 'browser',
sourcemap: false,
minify: false,
format: 'iife',
plugins: [],
});
await build({
entryPoints: [
'node_modules/single-file-core/single-file-hooks-frames.js'
],
bundle: true,
outdir: 'lib/',
platform: 'browser',
sourcemap: false,
minify: false,
format: 'iife',
plugins: [],
});
await build({
entryPoints: [
'node_modules/single-file-core/vendor/zip/zip.min.js'
],
bundle: true,
globalName: 'zip',
outdir: 'lib/',
platform: 'browser',
sourcemap: false,
minify: false,
format: 'iife',
plugins: [],
});
const SCRIPTS = [
'lib/single-file.js',
'lib/single-file-bootstrap.js',
'lib/zip.min.js'
];
let script = '';
const scripts = SCRIPTS.map(script => Deno.readTextFile(script));
const sources = await Promise.all(scripts);
script += 'const script = ' + JSON.stringify(sources.join(';')) + ';';
const hookScript = await Deno.readTextFile('lib/single-file-hooks-frames.js');
script += 'const hookScript = ' + JSON.stringify(hookScript) + ';';
const zipScript = await Deno.readTextFile('lib/zip.min.js');
script += 'const zipScript = ' + JSON.stringify(zipScript) + ';';
script += 'export { script, zipScript, hookScript };';
await Deno.writeTextFile('lib/single-file-bundle.js', script)
await Promise.all(SCRIPTS.map(script => Deno.remove(script)));
await Deno.remove('lib/single-file-hooks-frames.js');
const version = JSON.parse(await Deno.readTextFile('./deno.json')).version;
await Deno.writeTextFile('lib/version.js', 'export const version = ' + JSON.stringify(version) + ';');
" | deno run --allow-read --allow-write --allow-net --allow-run --allow-env --lock=node_modules/deno.lock.tmp -
rm -rf node_modules