Skip to content

Commit

Permalink
update build script
Browse files Browse the repository at this point in the history
  • Loading branch information
r3wt committed Mar 30, 2021
1 parent e9e4a6e commit 35b90fe
Showing 1 changed file with 8 additions and 27 deletions.
35 changes: 8 additions & 27 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const { build } = require('esbuild');
const pkg = require('./package.json');

// build esnext
build({
const modulesToBuild = [pkg.module,pkg.main];

Promise.all(modulesToBuild.map(moduleName=>build({
entryPoints: [pkg.source],
format: 'esm',
outfile: pkg.module,
Expand All @@ -12,31 +13,11 @@ build({
logLevel: 'info',
sourcemap: true,
external: ['react', 'react-dom']
})
}).then(()=>console.log('`%s` built successfully',moduleName))))
.then(() => {
console.log('build succeeded');
console.log('all modules built successfully');
})
.catch((err) => {
console.warn('build failed', err);
.catch((errors) => {
console.warn('one or more module builds failed', errors);
process.exit(1);
});

// build commonjs
build({
entryPoints: [pkg.source],
format: 'cjs',
outfile: pkg.main,
tsconfig: './tsconfig.json',
minify: true,
bundle: true,
logLevel: 'info',
sourcemap: true,
external: ['react', 'react-dom']
})
.then(() => {
console.log('build succeeded');
})
.catch((err) => {
console.warn('build failed', err);
process.exit(1)
});
});

0 comments on commit 35b90fe

Please sign in to comment.