Skip to content

Commit 429e28d

Browse files
authored
chore: defined sqlite3-opfs-async-proxy.js as a separate entrypoint with a non-esm format (#144)
1 parent 3161893 commit 429e28d

File tree

1 file changed

+41
-33
lines changed

1 file changed

+41
-33
lines changed

tsdown.config.ts

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,45 @@
11
import { defineConfig, type UserConfig } from 'tsdown';
2-
import { copyFileSync, rmSync, readFileSync, writeFileSync } from 'node:fs';
2+
import { copyFileSync, rmSync } from 'node:fs';
33

4-
const tsdownConfig: UserConfig = defineConfig({
5-
target: 'es2023',
6-
entry: [
7-
'src/index.js',
8-
'src/node.js',
9-
'src/index.d.ts',
10-
'src/bin/sqlite3-opfs-async-proxy.js',
11-
'src/bin/sqlite3-worker1.mjs',
12-
],
13-
format: ['esm'],
14-
minify: 'dce-only',
15-
outputOptions: {
16-
legalComments: 'inline',
17-
},
18-
onSuccess: () => {
19-
copyFileSync('./src/bin/sqlite3.wasm', './dist/sqlite3.wasm');
20-
copyFileSync(
21-
'./dist/bin/sqlite3-worker1.mjs',
22-
'./dist/sqlite3-worker1.mjs',
23-
);
24-
// Remove "export {};" to make sure sqlite3-opfs-async-proxy.js isn't a module
25-
const proxyContent = readFileSync(
26-
'./dist/bin/sqlite3-opfs-async-proxy.mjs',
27-
'utf-8',
28-
);
29-
writeFileSync(
30-
'./dist/sqlite3-opfs-async-proxy.js',
31-
proxyContent.replace(/export\s*\{\s*}\s*;\s*$/, ''),
32-
);
33-
rmSync('./dist/bin', { recursive: true });
34-
},
35-
});
4+
const tsdownConfig: UserConfig[] = [
5+
defineConfig({
6+
target: 'es2023',
7+
entry: [
8+
'src/index.js',
9+
'src/node.js',
10+
'src/index.d.ts',
11+
'src/bin/sqlite3-worker1.mjs',
12+
],
13+
format: ['esm'],
14+
minify: 'dce-only',
15+
outputOptions: {
16+
legalComments: 'inline',
17+
},
18+
onSuccess: () => {
19+
copyFileSync('./src/bin/sqlite3.wasm', './dist/sqlite3.wasm');
20+
copyFileSync(
21+
'./dist/bin/sqlite3-worker1.mjs',
22+
'./dist/sqlite3-worker1.mjs',
23+
);
24+
},
25+
}),
26+
defineConfig({
27+
target: 'es2023',
28+
entry: ['src/bin/sqlite3-opfs-async-proxy.js'],
29+
format: ['iife'],
30+
minify: 'dce-only',
31+
outputOptions: {
32+
legalComments: 'inline',
33+
},
34+
onSuccess: () => {
35+
copyFileSync(
36+
'./dist/sqlite3-opfs-async-proxy.iife.js',
37+
'./dist/sqlite3-opfs-async-proxy.js',
38+
);
39+
rmSync('./dist/sqlite3-opfs-async-proxy.iife.js');
40+
rmSync('./dist/bin', { recursive: true, force: true });
41+
},
42+
}),
43+
];
3644

3745
export default tsdownConfig;

0 commit comments

Comments
 (0)