Overall wasm refactoring & improvements

This commit is contained in:
2024-08-21 19:48:58 -06:00
parent 0fccae1049
commit 1f4175dc21
11 changed files with 326 additions and 170 deletions

View File

@@ -1,15 +1,33 @@
import {defineConfig} from 'tsup';
import fs from 'node:fs/promises';
export default defineConfig({
entry: ['src/main.ts', 'src/worker.ts'],
clean: true,
dts: true,
format: 'esm',
sourcemap: true,
splitting: false,
target: ['es2022', 'chrome89', 'edge89', 'firefox89', 'safari15', 'node14.8'],
async onSuccess() {
await fs.copyFile('pkg/objdiff_core_bg.wasm', 'dist/objdiff_core_bg.wasm');
export default defineConfig([
// Build main library
{
entry: ['src/main.ts'],
clean: true,
dts: true,
format: 'esm',
outDir: 'dist',
skipNodeModulesBundle: true,
sourcemap: true,
splitting: false,
target: 'es2022',
},
// Build web worker
{
entry: ['src/worker.ts'],
clean: true,
dts: true,
format: 'esm', // type: 'module'
minify: true,
outDir: 'dist',
sourcemap: true,
splitting: false,
target: 'es2022',
// https://github.com/egoist/tsup/issues/278
async onSuccess() {
await fs.copyFile('pkg/objdiff_core_bg.wasm', 'dist/objdiff_core_bg.wasm');
}
}
});
]);