Skip to content
This repository was archived by the owner on Apr 16, 2020. It is now read-only.

Commit f6e1a43

Browse files
committed
doc: fixup describing "main" as package entry point
1 parent 8de9da0 commit f6e1a43

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

doc/api/esm.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ For completeness there is also `--type=commonjs`, for explicitly running a `.js`
4949
file as CommonJS. This is the default behavior if `--type` or `-m` is
5050
unspecified.
5151

52-
The `--type=module` or `-m` flags can also be used to configure Node.js to treat as
53-
an ES module input sent in via `--eval` or `--print` (or `-e` or `-p`) or piped
54-
to Node.js via `STDIN`.
52+
The `--type=module` or `-m` flags can also be used to configure Node.js to treat
53+
as an ES module input sent in via `--eval` or `--print` (or `-e` or `-p`) or
54+
piped to Node.js via `STDIN`.
5555

5656
```sh
5757
node --experimental-modules --type=module --eval \
@@ -151,8 +151,9 @@ package scope:
151151

152152
## Package Entry Points
153153

154-
When a `package.json` contains `"type": "module"`, its `"main"` field defines
155-
the ES module entry point for the package.
154+
The `package.json` `"main"` field defines the entry point for a package,
155+
whether the package is included into CommonJS via `require` or into an ES
156+
module via `import`.
156157

157158
<!-- eslint-skip -->
158159
```js
@@ -177,6 +178,9 @@ CommonJS.
177178
As with `import` statements, for ES module usage the value of `"main"` must be
178179
a full path including extension: `"./index.mjs"`, not `"./index"`.
179180

181+
If the `package.json` `"type"` field is omitted, a `.js` file in `"main"` will
182+
be interpreted as CommonJS.
183+
180184
> Currently a package can define _either_ a CommonJS entry point **or** an ES
181185
> module entry point; there is no way to specify separate entry points for
182186
> CommonJS and ES module usage. This means that a package entry point can be

0 commit comments

Comments
 (0)