-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathbuild.js
More file actions
29 lines (24 loc) · 658 Bytes
/
build.js
File metadata and controls
29 lines (24 loc) · 658 Bytes
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
// https://janessagarrow.com/blog/typescript-and-esbuild/
const { build } = require("esbuild");
const { dependencies, peerDependencies } = require('./package.json');
const { Generator } = require('npm-dts');
new Generator({
entry: 'index.ts',
output: 'dist/index.d.ts',
}).generate();
const sharedConfig = {
entryPoints: ["src/index.ts"],
bundle: true,
external: Object.keys(dependencies ?? {}).concat(Object.keys(peerDependencies ?? {})),
};
build({
...sharedConfig,
platform: 'node', // for CJS
outfile: "dist/index.cjs",
});
build({
...sharedConfig,
outfile: "dist/index.js",
platform: 'neutral', // for ESM
format: "esm",
});