diff --git a/readme.md b/readme.md index 5068ac36..34600e12 100644 --- a/readme.md +++ b/readme.md @@ -70,7 +70,7 @@ Outputs the Node.js compact build of `input.js` into `dist/index.js`. --v8-cache Emit a build using the v8 compile cache --license [file] Adds a file containing licensing information to the output --stats-out [file] Emit webpack stats as json to the specified output file - --target [es] ECMAScript target to use for output (default: es2015) + --target [es] ECMAScript or Node.js target to use for output (default: es2015) Learn more: https://webpack.js.org/configuration/target -d, --debug Show debug logs ``` diff --git a/src/cli.js b/src/cli.js index 974c12c6..e2347df8 100755 --- a/src/cli.js +++ b/src/cli.js @@ -38,7 +38,7 @@ Options: --v8-cache Emit a build using the v8 compile cache --license [file] Adds a file containing licensing information to the output --stats-out [file] Emit webpack stats as json to the specified output file - --target [es] ECMAScript target to use for output (default: es2015) + --target [es] ECMAScript or Node.js target to use for output (default: es2015) Learn more: https://webpack.js.org/configuration/target -d, --debug Show debug logs `; diff --git a/src/index.js b/src/index.js index 8ffa3022..bf94f7b1 100644 --- a/src/index.js +++ b/src/index.js @@ -86,8 +86,8 @@ function ncc ( console.log(`ncc: Compiling file ${filename} into ${esm ? 'ESM' : 'CJS'}`); } - if (target && !target.startsWith('es')) { - throw new Error(`Invalid "target" value provided ${target}, value must be es version e.g. es2015`) + if (target && (!target.startsWith('es') || !target.startsWith('node'))) { + throw new Error(`Invalid "target" value provided ${target}, value must be "esX" or "node[[X].Y]" e.g. es2015 or node20`) } const resolvedEntry = resolve.sync(entry);