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

Commit

Permalink
move package parsing into package_resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Nov 5, 2018
1 parent a9dadb8 commit e1d83e3
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,7 @@ The algorithm to resolve an ES module specifier is provided through _ESM_RESOLVE
> 1. Let _resolvedURL_ be the URL resolution of _specifier_ to _parentURL_.
> 1. Return the result of **PATH_RESOLVE**(_resolvedURL_).
> 1. Note: _specifier_ is now a bare specifier.
> 1. Let _packageName_ be _undefined_.
> 1. Let _packagePath_ be _undefined_.
> 1. If _name_ does not start with _"@"_ then,
> 1. Set _packageName_ to the substring of _specifier_ until the first _"/"_ separator or the end of the string.
> 1. If _name_ starts with _"@"_ then,
> 1. If _name_ does not contain a _"/"_ separator then,
> 1. Throw a _Invalid Package Name_ error.
> 1. Set _packageName_ to the substring of _specifier_ until the second _"/"_ separator or the end of the string.
> 1. Let _packagePath_ be the substring of _specifier_ from the position at the length of _packageName_ plus one, if any.
> 1. Return the result of **PACKAGE_RESOLVE**(_packageName_, _packagePath_, _parentURL_), or propagating any errors thrown.
> 1. Return the result of **PACKAGE_RESOLVE**(_specifier_).
**PATH_RESOLVE**(_resolvedURL_)
> 1. If the file at _resolvedURL_ exists then,
Expand All @@ -221,9 +212,19 @@ The algorithm to resolve an ES module specifier is provided through _ESM_RESOLVE
> 1. Return _packageMainURL_.
> 1. Throw a _Module Not Found_ error.
**PACKAGE_RESOLVE**(_packageName_, _packagePath_, _parentURL_)
> 1. Assert: _packagePath_ is either empty, or a path without a leading separator.
**PACKAGE_RESOLVE**(_packageSpecifier_)
> 1. Assert: _packageSpecifier_ is a valid bare specifier.
> 1. Let _packageName_ be _undefined_.
> 1. Let _packagePath_ be _undefined_.
> 1. If _packageSpecifier_ does not start with _"@"_ then,
> 1. Set _packageName_ to the substring of _packageSpecifier_ until the first _"/"_ separator or the end of the string.
> 1. If _packageSpecifier_ starts with _"@"_ then,
> 1. If _packageSpecifier_ does not contain a _"/"_ separator then,
> 1. Throw a _Invalid Package Name_ error.
> 1. Set _packageName_ to the substring of _packageSpecifier_ until the second _"/"_ separator or the end of the string.
> 1. Let _packagePath_ be the substring of _packageSpecifier_ from the position at the length of _packageName_ plus one, if any.
> 1. Assert: _packageName_ is a valid package name or scoped package name.
> 1. Assert: _packagePath_ is either empty, or a path without a leading separator.
> 1. Note: Further package name encoding validations can be added here.
> 1. If _packagePath_ is empty and _packageName_ is a Node.js builtin module then,
> 1. Return _"node:${packageName}"_.
Expand Down

0 comments on commit e1d83e3

Please sign in to comment.