Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Bedford <guybedford@gmail.com>2020-08-12 04:40:05 +0300
committerGuy Bedford <guybedford@gmail.com>2020-09-18 04:56:17 +0300
commit2d868fe822af00c65c9487546e0f313ef3d04564 (patch)
treed8df246cbf2f4e79f066dc7f9f5c6e4e92ff421a /doc/api/esm.md
parentc9506a8f3e9bc5c679151feb39198023154464ab (diff)
module: exports pattern support
PR-URL: https://github.com/nodejs/node/pull/34718 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'doc/api/esm.md')
-rw-r--r--doc/api/esm.md49
1 files changed, 35 insertions, 14 deletions
diff --git a/doc/api/esm.md b/doc/api/esm.md
index 9a4d65d25f7..3f163225f1d 100644
--- a/doc/api/esm.md
+++ b/doc/api/esm.md
@@ -976,7 +976,8 @@ The resolver can throw the following errors:
> 1. Set _mainExport_ to _exports_\[_"."_\].
> 1. If _mainExport_ is not **undefined**, then
> 1. Let _resolved_ be the result of **PACKAGE_TARGET_RESOLVE**(
-> _packageURL_, _mainExport_, _""_, **false**, _conditions_).
+> _packageURL_, _mainExport_, _""_, **false**, **false**,
+> _conditions_).
> 1. If _resolved_ is not **null** or **undefined**, then
> 1. Return _resolved_.
> 1. Otherwise, if _exports_ is an Object and all keys of _exports_ start with
@@ -1010,29 +1011,43 @@ _isImports_, _conditions_)
> 1. If _matchKey_ is a key of _matchObj_, and does not end in _"*"_, then
> 1. Let _target_ be the value of _matchObj_\[_matchKey_\].
> 1. Let _resolved_ be the result of **PACKAGE_TARGET_RESOLVE**(
-> _packageURL_, _target_, _""_, _isImports_, _conditions_).
+> _packageURL_, _target_, _""_, **false**, _isImports_, _conditions_).
> 1. Return the object _{ resolved, exact: **true** }_.
-> 1. Let _expansionKeys_ be the list of keys of _matchObj_ ending in _"/"_,
-> sorted by length descending.
+> 1. Let _expansionKeys_ be the list of keys of _matchObj_ ending in _"/"_
+> or _"*"_, sorted by length descending.
> 1. For each key _expansionKey_ in _expansionKeys_, do
+> 1. If _expansionKey_ ends in _"*"_ and _matchKey_ starts with but is
+> not equal to the substring of _expansionKey_ excluding the last _"*"_
+> character, then
+> 1. Let _target_ be the value of _matchObj_\[_expansionKey_\].
+> 1. Let _subpath_ be the substring of _matchKey_ starting at the
+> index of the length of _expansionKey_ minus one.
+> 1. Let _resolved_ be the result of **PACKAGE_TARGET_RESOLVE**(
+> _packageURL_, _target_, _subpath_, **true**, _isImports_,
+> _conditions_).
+> 1. Return the object _{ resolved, exact: **true** }_.
> 1. If _matchKey_ starts with _expansionKey_, then
> 1. Let _target_ be the value of _matchObj_\[_expansionKey_\].
> 1. Let _subpath_ be the substring of _matchKey_ starting at the
> index of the length of _expansionKey_.
> 1. Let _resolved_ be the result of **PACKAGE_TARGET_RESOLVE**(
-> _packageURL_, _target_, _subpath_, _isImports_, _conditions_).
+> _packageURL_, _target_, _subpath_, **false**, _isImports_,
+> _conditions_).
> 1. Return the object _{ resolved, exact: **false** }_.
> 1. Return the object _{ resolved: **null**, exact: **true** }_.
-**PACKAGE_TARGET_RESOLVE**(_packageURL_, _target_, _subpath_, _internal_,
-_conditions_)
+**PACKAGE_TARGET_RESOLVE**(_packageURL_, _target_, _subpath_, _pattern_,
+_internal_, _conditions_)
> 1. If _target_ is a String, then
-> 1. If _subpath_ has non-zero length and _target_ does not end with _"/"_,
-> throw an _Invalid Module Specifier_ error.
+> 1. If _pattern_ is **false**, _subpath_ has non-zero length and _target_
+> does not end with _"/"_, throw an _Invalid Module Specifier_ error.
> 1. If _target_ does not start with _"./"_, then
> 1. If _internal_ is **true** and _target_ does not start with _"../"_ or
> _"/"_ and is not a valid URL, then
+> 1. If _pattern_ is **true**, then
+> 1. Return **PACKAGE_RESOLVE**(_target_ with every instance of
+> _"*"_ replaced by _subpath_, _packageURL_ + _"/"_)_.
> 1. Return **PACKAGE_RESOLVE**(_target_ + _subpath_,
> _packageURL_ + _"/"_)_.
> 1. Otherwise, throw an _Invalid Package Target_ error.
@@ -1044,8 +1059,12 @@ _conditions_)
> 1. Assert: _resolvedTarget_ is contained in _packageURL_.
> 1. If _subpath_ split on _"/"_ or _"\\"_ contains any _"."_, _".."_ or
> _"node_modules"_ segments, throw an _Invalid Module Specifier_ error.
-> 1. Return the URL resolution of the concatenation of _subpath_ and
-> _resolvedTarget_.
+> 1. If _pattern_ is **true**, then
+> 1. Return the URL resolution of _resolvedTarget_ with every instance of
+> _"*"_ replaced with _subpath_.
+> 1. Otherwise,
+> 1. Return the URL resolution of the concatenation of _subpath_ and
+> _resolvedTarget_.
> 1. Otherwise, if _target_ is a non-null Object, then
> 1. If _exports_ contains any index property keys, as defined in ECMA-262
> [6.1.7 Array Index][], throw an _Invalid Package Configuration_ error.
@@ -1054,7 +1073,8 @@ _conditions_)
> then
> 1. Let _targetValue_ be the value of the _p_ property in _target_.
> 1. Let _resolved_ be the result of **PACKAGE_TARGET_RESOLVE**(
-> _packageURL_, _targetValue_, _subpath_, _internal_, _conditions_).
+> _packageURL_, _targetValue_, _subpath_, _pattern_, _internal_,
+> _conditions_).
> 1. If _resolved_ is equal to **undefined**, continue the loop.
> 1. Return _resolved_.
> 1. Return **undefined**.
@@ -1062,8 +1082,9 @@ _conditions_)
> 1. If _target.length is zero, return **null**.
> 1. For each item _targetValue_ in _target_, do
> 1. Let _resolved_ be the result of **PACKAGE_TARGET_RESOLVE**(
-> _packageURL_, _targetValue_, _subpath_, _internal_, _conditions_),
-> continuing the loop on any _Invalid Package Target_ error.
+> _packageURL_, _targetValue_, _subpath_, _pattern_, _internal_,
+> _conditions_), continuing the loop on any _Invalid Package Target_
+> error.
> 1. If _resolved_ is **undefined**, continue the loop.
> 1. Return _resolved_.
> 1. Return or throw the last fallback resolution **null** return or error.