Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
-m alias, docs
  • Loading branch information
guybedford committed Aug 5, 2020
commit ed6923507f9664044eac688a490843f247a84109
4 changes: 2 additions & 2 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ $ node --completion-bash > node_bash_completion
$ source node_bash_completion
```

### `--conditions=conditionA,conditionB`
### `-m`, `--conditions=conditionA,conditionB`
<!-- YAML
added: REPLACEME
-->
Expand Down Expand Up @@ -1247,7 +1247,7 @@ node --require "./a.js" --require "./b.js"

Node.js options that are allowed are:
<!-- node-options-node start -->
* `--conditions`
* `--conditions`, `-m`
* `--diagnostic-dir`
* `--disable-proto`
* `--enable-fips`
Expand Down
11 changes: 11 additions & 0 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,17 @@ order to support packages with conditional exports. For this reason, using
`"node"` and `"default"` condition branches is usually preferable to using
`"node"` and `"browser"` condition branches.

When running Node.js, custom comma-separated conditions can be set with the
`--conditions` or `-m` flag:

```bash
node --conditions=development main.js
```

which would then resolve the `"development"` condition in exports, along with
the existing `"node"`, `"default"`, `"import"` and `"require"` conditions as
appropriate.

#### Nested conditions

In addition to direct mappings, Node.js also supports nested condition objects.
Expand Down
2 changes: 1 addition & 1 deletion doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Aborting instead of exiting causes a core file to be generated for analysis.
.It Fl -completion-bash
Print source-able bash completion script for Node.js.
.
.It Fl -conditions Ar string
.It Fl m , Fl -conditions Ar string
Use custom conditional exports conditions
.Ar string
.
Expand Down
1 change: 1 addition & 0 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
"set the conditional exports conditions",
Comment thread
guybedford marked this conversation as resolved.
Outdated
&EnvironmentOptions::conditions,
kAllowedInEnvironment);
AddAlias("-m", "--conditions");
AddOption("--diagnostic-dir",
"set dir for all output files"
" (default: current working directory)",
Expand Down