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

Commit 884041d

Browse files
committed
docs: fixup describing "main" as package entry point
1 parent 8de9da0 commit 884041d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

doc/api/esm.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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)