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
match non-object exports handling
  • Loading branch information
guybedford committed Jul 30, 2019
commit 5adaeea1656135aa1b4f3818c77bdc7070da50d4
35 changes: 18 additions & 17 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,8 @@ _isMain_ is **true** when resolving the Node.js application entry point.
> 1. Return the result of **PACKAGE_MAIN_RESOLVE**(_packageURL_,
> _pjson_).
> 1. Otherwise,
> 1. If _pjson_ is not **null* and _pjson.exports_ is *falsy*, then
> 1. If _pjson_ is not **null** and _pjson.exports_ is **null** or
> **undefined**, then
> 1. Throw a _Module Not Found_ error.
> 1. If _pjson_ is not **null** and _pjson.exports_ is an Object, then
> 1. Return **PACKAGE_EXPORTS_RESOLVE**(_packageURL_, _packagePath_,
Expand All @@ -750,23 +751,23 @@ _isMain_ is **true** when resolving the Node.js application entry point.

**PACKAGE_EXPORTS_RESOLVE**(_packageURL_, _packagePath_, _pjson_)
> 1. Assert: _pjson_ is not **null**.
> 1. Assert: _pjson.exports_ is an Object.
> 1. Set _packagePath_ to _"./"_ concatenated with _packagePath_.
> 1. If _packagePath_ is a key of _pjson.exports_, then
> 1. Let _target_ be the value of _pjson.exports[packagePath]_.
> 1. If _target_ is not a String, continue the loop.
> 1. Return the URL resolution of the concatenation of _packageURL_ and
> _target_.
> 1. Let _directoryKeys_ be the list of keys of _pjson.exports_ ending in
> _"/"_, sorted by length descending.
> 1. For each key _directory_ in _directoryKeys_, do
> 1. If _packagePath_ starts with _directory_, then
> 1. Let _target_ be the value of _pjson.exports[directory]_.
> 1. If _pjson.exports_ is an Object, then
> 1. Set _packagePath_ to _"./"_ concatenated with _packagePath_.
> 1. If _packagePath_ is a key of _pjson.exports_, then
> 1. Let _target_ be the value of _pjson.exports[packagePath]_.
> 1. If _target_ is not a String, continue the loop.
> 1. Let _subpath_ be the substring of _target_ starting at the index of
> the length of _directory_.
> 1. Return the URL resolution of the concatenation of _packageURL_,
> _target_ and _subpath_.
> 1. Return the URL resolution of the concatenation of _packageURL_ and
> _target_.
> 1. Let _directoryKeys_ be the list of keys of _pjson.exports_ ending in
> _"/"_, sorted by length descending.
> 1. For each key _directory_ in _directoryKeys_, do
> 1. If _packagePath_ starts with _directory_, then
> 1. Let _target_ be the value of _pjson.exports[directory]_.
> 1. If _target_ is not a String, continue the loop.
> 1. Let _subpath_ be the substring of _target_ starting at the index of
> the length of _directory_.
> 1. Return the URL resolution of the concatenation of _packageURL_,
> _target_ and _subpath_.
> 1. Throw a _Module Not Found_ error.

**ESM_FORMAT**(_url_, _isMain_)
Expand Down