forked from duckdb/duckdb-wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundle.mjs
137 lines (122 loc) · 3.29 KB
/
bundle.mjs
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import esbuild from 'esbuild';
import path from 'path';
import mkdir from 'make-dir';
import { fileURLToPath } from 'url';
import fs from 'fs';
// Bundling node is a bit problematic right now.
// The web worker ponyfill is commonjs (dynamic require) and prevents us from releasing an async node module.
function printErr(err) {
if (err) return console.log(err);
}
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const dist = path.resolve(__dirname, 'dist');
mkdir.sync(dist);
// -------------------------------
// Copy WASM files
fs.copyFile(
path.resolve(__dirname, '../../node_modules/sql.js/dist/sql-wasm.wasm'),
path.resolve(dist, 'sql-wasm.wasm'),
printErr,
);
// -------------------------------
// ESM
const TARGET = 'es2020';
const EXTERNALS = ['web-worker', 'react-native-fetch-blob', 'apache-arrow'];
console.log('[ ESBUILD ] internal.js');
esbuild.build({
entryPoints: ['./src/suite_internal.ts'],
outfile: 'dist/internal.js',
platform: 'node',
format: 'cjs',
target: TARGET,
bundle: true,
minify: false,
sourcemap: true,
external: EXTERNALS,
});
console.log('[ ESBUILD ] system-sort-int.js');
esbuild.build({
entryPoints: ['./src/suite_system_sort_int.ts'],
outfile: 'dist/system-sort-int.js',
platform: 'node',
format: 'cjs',
target: TARGET,
bundle: true,
minify: false,
sourcemap: true,
external: EXTERNALS,
});
console.log('[ ESBUILD ] system-sum-int.js');
esbuild.build({
entryPoints: ['./src/suite_system_sum_int.ts'],
outfile: 'dist/system-sum-int.js',
platform: 'node',
format: 'cjs',
target: TARGET,
bundle: true,
minify: false,
sourcemap: true,
external: EXTERNALS,
});
console.log('[ ESBUILD ] system-sum-csv.js');
esbuild.build({
entryPoints: ['./src/suite_system_sum_csv.ts'],
outfile: 'dist/system-sum-csv.js',
platform: 'node',
format: 'cjs',
target: TARGET,
bundle: true,
minify: false,
sourcemap: true,
external: EXTERNALS,
});
console.log('[ ESBUILD ] system-regex.js');
esbuild.build({
entryPoints: ['./src/suite_system_regex.ts'],
outfile: 'dist/system-regex.js',
platform: 'node',
format: 'cjs',
target: TARGET,
bundle: true,
minify: false,
sourcemap: true,
external: EXTERNALS,
});
console.log('[ ESBUILD ] system-join-2.js');
esbuild.build({
entryPoints: ['./src/suite_system_join_2.ts'],
outfile: 'dist/system-join-2.js',
platform: 'node',
format: 'cjs',
target: TARGET,
bundle: true,
minify: false,
sourcemap: true,
external: EXTERNALS,
});
console.log('[ ESBUILD ] system-join-3.js');
esbuild.build({
entryPoints: ['./src/suite_system_join_3.ts'],
outfile: 'dist/system-join-3.js',
platform: 'node',
format: 'cjs',
target: TARGET,
bundle: true,
minify: false,
sourcemap: true,
external: EXTERNALS,
});
for (const sys of ['arquero', 'duckdb', 'lovefield', 'sqljs']) {
console.log(`[ ESBUILD ] system-tpch-${sys}.js`);
esbuild.build({
entryPoints: [`./src/suite_system_tpch_${sys}.ts`],
outfile: `dist/system-tpch-${sys}.js`,
platform: 'node',
format: 'cjs',
target: TARGET,
bundle: true,
minify: false,
sourcemap: true,
external: EXTERNALS,
});
}