Skip to content

Commit 38a4537

Browse files
committed
fix: support node[[X].Y] as a target (fixes #1247)
1 parent cc9a025 commit 38a4537

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Outputs the Node.js compact build of `input.js` into `dist/index.js`.
7070
--v8-cache Emit a build using the v8 compile cache
7171
--license [file] Adds a file containing licensing information to the output
7272
--stats-out [file] Emit webpack stats as json to the specified output file
73-
--target [es] ECMAScript target to use for output (default: es2015)
73+
--target [es] ECMAScript or Node.js target to use for output (default: es2015)
7474
Learn more: https://webpack.js.org/configuration/target
7575
-d, --debug Show debug logs
7676
```

src/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Options:
3838
--v8-cache Emit a build using the v8 compile cache
3939
--license [file] Adds a file containing licensing information to the output
4040
--stats-out [file] Emit webpack stats as json to the specified output file
41-
--target [es] ECMAScript target to use for output (default: es2015)
41+
--target [es] ECMAScript or Node.js target to use for output (default: es2015)
4242
Learn more: https://webpack.js.org/configuration/target
4343
-d, --debug Show debug logs
4444
`;

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ function ncc (
8686
console.log(`ncc: Compiling file ${filename} into ${esm ? 'ESM' : 'CJS'}`);
8787
}
8888

89-
if (target && !target.startsWith('es')) {
90-
throw new Error(`Invalid "target" value provided ${target}, value must be es version e.g. es2015`)
89+
if (target && (!target.startsWith('es') || !target.startsWith('node'))) {
90+
throw new Error(`Invalid "target" value provided ${target}, value must be "esX" or "node[[X].Y]" e.g. es2015 or node20`)
9191
}
9292

9393
const resolvedEntry = resolve.sync(entry);

0 commit comments

Comments
 (0)