1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

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

This commit is contained in:
Tim Neutkens 2018-12-17 19:17:29 +01:00 committed by GitHub
parent 581e193a72
commit 9a7ebb1cc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 22 deletions

View file

@ -1340,13 +1340,17 @@ module.exports = {
#### 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
next --node-args="--throw-deprecation"
next start --node-args="--inspect"
next build --node-args="-r esm"
NODE_OPTIONS="--throw-deprecation" next
NODE_OPTIONS="-r esm" next
```
`--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

View file

@ -24,7 +24,6 @@ const args = arg({
// Types
'--version': Boolean,
'--help': Boolean,
'--node-args': String,
'--inspect': Boolean,
// Aliases
@ -55,7 +54,7 @@ if (!foundCommand && args['--help']) {
Options
--version, -p Version number
--node-args Node arguments applied to the process
--inspect Enable the Node.js inspector
--help, -h Displays this message
For more information run a command with the --help flag
@ -64,17 +63,12 @@ if (!foundCommand && args['--help']) {
process.exit(0)
}
// Add support for `--node-args` to send Node.js arguments to the spawned process
const nodeArguments = args['--node-args'] && args['--node-args'] !== '' ? args['--node-args'].split(' ') : []
const nodeArguments: string[] = []
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')
}
if (nodeArguments.length > 0) {
console.log(`Passing arguments to Node.js: "${nodeArguments.join(' ')}"`)
}
const command = foundCommand || defaultCommand
const forwardedArgs = args._.filter(arg => arg !== command)

View file

@ -45,14 +45,7 @@ describe('CLI Usage', () => {
const output = await runNextCommand(['build', dir, '--inspect'], {
stdout: true
})
expect(output.stdout).toMatch(/The `--inspect` option is deprecated/)
})
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"/)
expect(output.stdout).toMatch(/Passing "--inspect" to Node\.js/)
})
})
describe('build', () => {