Unverified Commit 9a7ebb1c authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Remove node-args in favor of NODE_OPTIONS environment variable (#5910)

parent 581e193a
...@@ -1340,13 +1340,17 @@ module.exports = { ...@@ -1340,13 +1340,17 @@ module.exports = {
#### Configuring next process script #### Configuring next process script
You can pass any node arguments to `next` cli command. You can pass any node arguments to `next` CLI command.
```bash ```bash
next --node-args="--throw-deprecation" NODE_OPTIONS="--throw-deprecation" next
next start --node-args="--inspect" NODE_OPTIONS="-r esm" next
next build --node-args="-r esm" ```
`--inspect` is a special case since it binds to a port and can't double-bind to the child process the `next` CLI creates.
```
next start --inspect
``` ```
### Customizing webpack config ### Customizing webpack config
......
...@@ -24,7 +24,6 @@ const args = arg({ ...@@ -24,7 +24,6 @@ const args = arg({
// Types // Types
'--version': Boolean, '--version': Boolean,
'--help': Boolean, '--help': Boolean,
'--node-args': String,
'--inspect': Boolean, '--inspect': Boolean,
// Aliases // Aliases
...@@ -55,7 +54,7 @@ if (!foundCommand && args['--help']) { ...@@ -55,7 +54,7 @@ if (!foundCommand && args['--help']) {
Options Options
--version, -p Version number --version, -p Version number
--node-args Node arguments applied to the process --inspect Enable the Node.js inspector
--help, -h Displays this message --help, -h Displays this message
For more information run a command with the --help flag For more information run a command with the --help flag
...@@ -64,17 +63,12 @@ if (!foundCommand && args['--help']) { ...@@ -64,17 +63,12 @@ if (!foundCommand && args['--help']) {
process.exit(0) process.exit(0)
} }
// Add support for `--node-args` to send Node.js arguments to the spawned process const nodeArguments: string[] = []
const nodeArguments = args['--node-args'] && args['--node-args'] !== '' ? args['--node-args'].split(' ') : []
if (args['--inspect']) { if (args['--inspect']) {
console.log('The `--inspect` option is deprecated in favor of `--node-args`') console.log('Passing "--inspect" to Node.js')
nodeArguments.push('--inspect') nodeArguments.push('--inspect')
} }
if (nodeArguments.length > 0) {
console.log(`Passing arguments to Node.js: "${nodeArguments.join(' ')}"`)
}
const command = foundCommand || defaultCommand const command = foundCommand || defaultCommand
const forwardedArgs = args._.filter(arg => arg !== command) const forwardedArgs = args._.filter(arg => arg !== command)
......
...@@ -45,14 +45,7 @@ describe('CLI Usage', () => { ...@@ -45,14 +45,7 @@ describe('CLI Usage', () => {
const output = await runNextCommand(['build', dir, '--inspect'], { const output = await runNextCommand(['build', dir, '--inspect'], {
stdout: true stdout: true
}) })
expect(output.stdout).toMatch(/The `--inspect` option is deprecated/) expect(output.stdout).toMatch(/Passing "--inspect" to Node\.js/)
})
test('--node-args', async () => {
const output = await runNextCommand(['build', dir, '--node-args=--inspect'], {
stdout: true
})
expect(output.stdout).toMatch(/Passing arguments to Node\.js: "--inspect"/)
}) })
}) })
describe('build', () => { describe('build', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment