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
Apply suggestions from code review
Co-authored-by: Geoffrey Booth <456802+GeoffreyBooth@users.noreply.github.com>
  • Loading branch information
guybedford and GeoffreyBooth authored Sep 28, 2020
commit 2a19db19ecff716b7df8557e848a7291db2c49a0
9 changes: 5 additions & 4 deletions doc/api/packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -839,9 +839,10 @@ until a node_modules folder or the volume root is reached.
node my-app.js # Runs as ES module
```

If no `package.json` is found once the volume root is reached, or if the nearest
parent `package.json` lacks a `"type"` field, or contains `"type": "commonjs"`,
`.js` files are treated as [CommonJS][].
If the nearest parent `package.json` lacks a `"type"` field, or contains
`"type": "commonjs"`, `.js` files are treated as [CommonJS][]. If the volume
root is reached and no `package.json` is found, `.js` files are treated as
[CommonJS][].

`import` statements of `.js` files are treated as ES modules if the nearest
parent `package.json` contains `"type": "module"`.
Expand Down Expand Up @@ -958,7 +959,7 @@ where `import '#dep'` would now get the resolution of the external package
`dep-node-native` (including its exports in turn), and instead get the local
file `./dep-polyfill.js` relative to the package in other environments.

Unlike the exports field, import maps permit mapping to external packages,
Unlike the `"exports"` field, import maps permit mapping to external packages,
providing an important use case for conditional loading scenarios.

Apart from the above, the resolution rules for the imports field are otherwise
Expand Down