-
Notifications
You must be signed in to change notification settings - Fork 273
/
tsup.config.ts
36 lines (33 loc) · 1.01 KB
/
tsup.config.ts
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
import {createRequire} from 'node:module';
import fs from 'node:fs/promises';
import {defineConfig} from 'tsup';
export default defineConfig({
entry: ['src/create-app.ts'],
outDir: 'dist',
format: 'esm',
clean: true,
sourcemap: false,
dts: false,
minify: true,
splitting: true, // Async/await breaks without splitting
// -- Bundle:
bundle: true,
external: [
'@ast-grep/napi', // Required binary
'react-devtools-core', // Not used but breaks the build otherwise
],
// Needed for some CJS dependencies:
shims: true,
banner: {
js: "import { createRequire as __createRequire } from 'module';globalThis.require = __createRequire(import.meta.url);",
},
async onSuccess() {
// Copy assets to the dist folder
await fs.cp('../cli/dist/assets', './dist/assets', {recursive: true});
// This WASM file is used in a dependency, copy it over:
await fs.copyFile(
createRequire(import.meta.url).resolve('yoga-wasm-web/dist/yoga.wasm'),
'./dist/yoga.wasm',
);
},
});