Skip to content

Commit

Permalink
🔨 Improve the build script
Browse files Browse the repository at this point in the history
  • Loading branch information
siguici committed Aug 17, 2024
1 parent 832745a commit 6837e6d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import pkg from '../package.json';
import { fs, path, zlib } from '../src/';
import tsconfig from '../tsconfig.json';

export type Target = BuildOptions['target'] | 'default';
export type Format = BuildOptions['format'];
export type Platform = BuildOptions['platform'];
type Target = BuildOptions['target'] | 'default';
type Format = BuildOptions['format'];

const entryPoints = globbySync(tsconfig.include, {
gitignore: true,
Expand All @@ -17,11 +16,12 @@ const defaultFormat =
pkg.type && pkg.type.toLowerCase() === 'module' ? 'esm' : 'cjs';
const outdir = tsconfig.compilerOptions.outDir;
const target = tsconfig.compilerOptions.target || 'default';
const minify = !tsconfig.compilerOptions.pretty;
const watch = process.argv.includes('--watch');
const dtsdir = tsconfig.compilerOptions.declarationDir || outdir;

bunify(entryPoints, dtsdir);
build(entryPoints, outdir, target, [undefined, 'cjs', 'esm'], true, watch);
build(entryPoints, outdir, target, [undefined, 'cjs', 'esm'], minify, watch);

const files = fs.readdirSync(outdir);
for (const file of files) {
Expand Down Expand Up @@ -61,7 +61,6 @@ function getBuildOptions(
return {
...options,
platform: 'node',
bundle: true,
minify,
format: format ?? defaultFormat,
sourcemap: !minify,
Expand Down

0 comments on commit 6837e6d

Please sign in to comment.