Skip to content

Commit

Permalink
chore(build): refactor out common build options
Browse files Browse the repository at this point in the history
  • Loading branch information
lionralfs committed Dec 28, 2023
1 parent 9f8dbbd commit e88d56b
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,26 @@ build({
define: { 'process.env.VERSION_NUMBER': `'${PACKAGE.version}'` },
}).catch(err => console.error(err) || process.exit(1));

// build for node, esm
build({
const commonBuildOptionsForNode = {
entryPoints: ['./lib/index.ts'],
bundle: true,
outfile: 'node-esm/index.js',
format: 'esm',
platform: 'node',
target: ['node14'],
minify: false,
define: { 'process.env.VERSION_NUMBER': `'${PACKAGE.version}'` },
};

// build for node, esm
build({
...commonBuildOptionsForNode,
outfile: 'node-esm/index.js',
format: 'esm',
external: ['node-fetch'],
}).catch(err => console.error(err) || process.exit(1));

// build for node, commonjs
build({
entryPoints: ['./lib/index.ts'],
bundle: true,
...commonBuildOptionsForNode,
outfile: 'commonjs/index.js',
format: 'cjs',
target: ['node14'],
platform: 'node',
minify: false,
define: { 'process.env.VERSION_NUMBER': `'${PACKAGE.version}'` },
}).catch(err => console.error(err) || process.exit(1));

0 comments on commit e88d56b

Please sign in to comment.