-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
46 lines (40 loc) · 1.01 KB
/
build.js
File metadata and controls
46 lines (40 loc) · 1.01 KB
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
import {exec} from 'child_process';
import {build} from 'esbuild';
import {mkdir, readFile, rm, writeFile} from 'fs/promises';
import {promisify} from 'util';
const execAsync = promisify(exec);
await rm('dist', {recursive: true, force: true});
await mkdir('dist', {recursive: true});
await build({
entryPoints: ['src/index.ts'],
bundle: true,
minify: true,
platform: 'node',
format: 'esm',
outfile: 'dist/index.js',
target: 'node18',
external: [
'prompts',
'prettier',
'typescript',
'handlebars',
'ts-blank-space',
],
});
await execAsync(
'npx dts-bundle-generator -o dist/index.d.ts src/index.ts --no-banner',
);
const pkg = JSON.parse(await readFile('package.json', 'utf-8'));
delete pkg.devDependencies;
delete pkg.scripts;
delete pkg.private;
pkg.main = './index.js';
pkg.types = './index.d.ts';
pkg.exports = {
'.': {
import: './index.js',
types: './index.d.ts',
},
};
await writeFile('dist/package.json', JSON.stringify(pkg, null, 2));
console.log('✅ Built tinycreate');