Skip to content
Closed
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
doc reorder
  • Loading branch information
guybedford committed Aug 5, 2020
commit 0180f8648527f64a4a00f4bc1daffeb1660ba52d
24 changes: 13 additions & 11 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,6 @@ 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 All @@ -512,6 +501,19 @@ a nested conditional does not have any mapping it will continue checking
the remaining conditions of the parent condition. In this way nested
conditions behave analogously to nested JavaScript `if` statements.

#### Executing 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:
Comment thread
guybedford marked this conversation as resolved.
Outdated

```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
Comment thread
guybedford marked this conversation as resolved.
Outdated
appropriate.

#### Self-referencing a package using its name

Within a package, the values defined in the package’s
Expand Down