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
Apply suggestions from code review
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Co-authored-by: Jan Olaf Krems <jan.krems@gmail.com>
  • Loading branch information
3 people authored Aug 5, 2020
commit acbe3ee460e24e46d7d64dd729d7fa99783e8844
2 changes: 1 addition & 1 deletion doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ conditions.

Any custom comma-separated string condition names are permitted.

The default Node.js conditions of `"node"`, `"default"`, `"import"` and
The default Node.js conditions of `"node"`, `"default"`, `"import"`, and
`"require"` will always apply as defined.

### `--cpu-prof`
Expand Down
4 changes: 2 additions & 2 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,14 +504,14 @@ conditions behave analogously to nested JavaScript `if` statements.
#### Resolving custom conditions

When running Node.js, custom comma-separated conditions can be set with the
Comment thread
guybedford marked this conversation as resolved.
Outdated
`--conditions` or `-m` flag:
`--conditions` or `-u` 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
the existing `"node"`, `"default"`, `"import"`, and `"require"` conditions as
appropriate.

#### Self-referencing a package using its name
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const manifest = getOptionValue('--experimental-policy') ?
null;
const { compileFunction } = internalBinding('contextify');
const userConditions = getOptionValue('--conditions') &&
getOptionValue('--conditions').split(',');
StringPrototypeSplit(getOptionValue('--conditions'), ',');

// Whether any user-provided CJS modules had been loaded (executed).
// Used for internal assertions.
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/modules/esm/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const { Module: CJSModule } = require('internal/modules/cjs/loader');

const packageJsonReader = require('internal/modules/package_json_reader');
const userConditions = getOptionValue('--conditions') &&
getOptionValue('--conditions').split(',');
StringPrototypeSplit(getOptionValue('--conditions'), ',');
const DEFAULT_CONDITIONS = ObjectFreeze(['node', 'import', ...userConditions]);
const DEFAULT_CONDITIONS_SET = new SafeSet(DEFAULT_CONDITIONS);

Expand Down
2 changes: 1 addition & 1 deletion src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ DebugOptionsParser::DebugOptionsParser() {

EnvironmentOptionsParser::EnvironmentOptionsParser() {
AddOption("--conditions",
"set the conditional exports conditions",
"additional user conditions for conditional exports and imports",
&EnvironmentOptions::conditions,
kAllowedInEnvironment);
AddAlias("-u", "--conditions");
Expand Down