Skip to content

Commit

Permalink
Validate bundle type
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jun 3, 2020
1 parent 10d97e7 commit d10b756
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion scripts/build.js
Expand Up @@ -5,9 +5,24 @@ const yargs = require('yargs');

const exec = promisify(childProcess.exec);

const validBundles = [
// legacy build using commonJS modules
'cjs',
// modern build
'es',
// legacy build using ES6 modules
'esm',
];

async function run(argv) {
const { bundle, outDir: relativeOutDir, verbose } = argv;

if (validBundles.indexOf(bundle) === -1) {
throw new TypeError(
`Unrecognized bundle '${bundle}'. Did you mean one of "${validBundles.join('", "')}"?`,
);
}

const env = {
NODE_ENV: 'production',
BABEL_ENV: bundle,
Expand Down Expand Up @@ -51,7 +66,7 @@ yargs
builder: (command) => {
return command
.positional('bundle', {
description: '"cjs" | "esm" | "es"',
description: `Valid bundles: "${validBundles.join('" | "')}"`,
type: 'string',
})
.option('out-dir', { default: './build', type: 'string' })
Expand Down

0 comments on commit d10b756

Please sign in to comment.