Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v13.10.0 proposal #32027

Merged
merged 91 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
db291aa
doc: guide - using valgrind to debug memory leaks
mhdawson Jan 24, 2020
57302f8
src: prefer 3-argument Array::New()
addaleax Feb 13, 2020
eb2dce8
doc: claim ABI version 82 for Electron 10
MarshallOfSound Feb 13, 2020
f87ac90
worker: unroll file extension regexp
addaleax Feb 13, 2020
9e4aad7
doc: fix typos in doc/api/https.md
Jeff-Tian Feb 14, 2020
b177bba
doc: move @Fishrock123 to a previous releaser
Fishrock123 Feb 10, 2020
7f4d6ee
doc: move @Fishrock123 to TSC Emeriti
Fishrock123 Feb 10, 2020
b071758
doc: pronouns for @Fishrock123
Fishrock123 Feb 10, 2020
f952605
doc: move gireeshpunathil to TSC emeritus
gireeshpunathil Feb 13, 2020
60c71dc
test: add known issue test for sync writable callback
jasnell Feb 12, 2020
3969af4
doc: reword possessive form of Node.js in debugger.md
Trott Feb 12, 2020
cb210e6
doc: reword possessive form of Node.js in process.md
Trott Feb 12, 2020
3eaf377
doc: reword possessive form of Node.js in http.md
Trott Feb 12, 2020
672f76d
doc: reword possessive form of Node.js in adding-new-napi-api.md
Trott Feb 12, 2020
98d262e
src: inform callback scopes about exceptions in HTTP parser
addaleax Feb 14, 2020
724bf31
test: remove common.PORT from test-net-timeout
Trott Feb 12, 2020
e76ac1d
test: remove common.PORT from test-net-throttle
Trott Feb 12, 2020
3fbd5ab
test: remove common.PORT from test-tls-server-large-request
Trott Feb 12, 2020
87e9014
test: remove common.PORT from test-net-pause
Trott Feb 12, 2020
bbb6cc7
module: package "exports" error refinements
guybedford Feb 3, 2020
9079bb4
http2: make compat finished match http/1
ronag Nov 13, 2018
3438937
doc: fix notable changes for v13.9.0
codebytere Feb 18, 2020
94a471a
meta: move eljefedelrodeodeljefe to emeritus
Trott Feb 11, 2020
a86cb0e
vm: lazily initialize primordials for vm contexts
joyeecheung Feb 11, 2020
f2389eb
worker: emit runtime error on loop creation failure
HarshithaKP Feb 3, 2020
1933efa
test: remove common.PORT from test-net-write-callbacks.js
Trott Feb 18, 2020
7d5776e
test: remove flaky designation for test-net-connect-options-port
Trott Feb 18, 2020
f858f23
tools: update lint-md task to lint for possessives of Node.js
Trott Feb 19, 2020
091b4bf
doc: add note about ssh key to releases
codebytere Feb 18, 2020
79b1f04
tools: sync gyp code base with node-gyp repo
targos Nov 20, 2019
61a0d8b
meta: move julianduque to emeritus
Trott Feb 19, 2020
d0e94fc
crypto: fix ieee-p1363 for createVerify
tniessen Feb 20, 2020
2046652
doc: fix anchor for ERR_TLS_INVALID_CONTEXT
tniessen Feb 22, 2020
acb3aff
tls: expose SSL_export_keying_material
simllll Feb 15, 2020
aa16d80
doc,crypto: re-document oaepLabel option
bnoordhuis Feb 17, 2020
4fe9e04
test: remove common.PORT from assorted pummel tests
Trott Feb 21, 2020
4dffd04
cli: --perf-prof only works on Linux
codebytere Feb 21, 2020
877ab97
async_hooks: introduce async-context API
vdeturckheim Mar 1, 2019
15cc9b0
doc: update assert.rejects() docs with a validation function example
MadLittleMods Jan 9, 2020
88ccb44
src: move BaseObject subclass dtors/ctors out of node_crypto.h
addaleax Dec 6, 2019
8fa6373
src: allow unique_ptrs with custom deleter in memory tracker
addaleax Oct 1, 2019
a468392
doc: update releases guide re pushing tags
MylesBorins Feb 18, 2020
9f68e14
src: elevate v8 namespaces
HarshithaKP Feb 21, 2020
b30a698
deps: move zlib maintenance info to guides
sam-github Feb 14, 2020
4c6343f
doc: describe how to update zlib
sam-github Feb 14, 2020
c27f0d1
deps: update zlib to upstream d7f3ca9
sam-github Feb 14, 2020
776f379
src: include large pages source unconditionally
Feb 21, 2020
e08fef1
test: add secp224k1 check in crypto-dh-stateless
danbev Feb 21, 2020
f293dcf
tools: add NODE_TEST_NO_INTERNET to the doc builder
joyeecheung Feb 18, 2020
c5acf0a
doc: updated YAML version representation in readline.md
Trott Feb 23, 2020
ae3929e
vm: implement vm.measureMemory() for per-context memory measurement
joyeecheung Feb 7, 2020
6af9e7e
async_hooks: executionAsyncResource matches in hooks
Flarna Feb 16, 2020
f89fb27
test: mark empty udp tests flaky on OS X
sam-github Feb 24, 2020
b74c40e
meta: move not-an-aardvark to emeritus
Trott Feb 24, 2020
918c2b6
test: fix typo in common/index.js
Trott Feb 24, 2020
04eda02
test: add documentation for common.enoughTestCpu
Trott Feb 24, 2020
b9f3bfe
module: disable conditional exports, self resolve warnings
guybedford Feb 18, 2020
f62967c
src: enable `StreamPipe` for generic `StreamBase`s
addaleax Mar 12, 2018
8516602
doc: clarify http2.connect authority details
jasnell Feb 17, 2020
e3258fd
doc: update zlib doc
jasnell Feb 6, 2020
6adbfac
repl: eager-evaluate input in parens
codebytere Feb 25, 2020
49c959d
test: increase timeout in vm-timeout-escape-queuemicrotask
lundibundi Feb 26, 2020
ab8f060
test: fix usage of invalid common properties
lundibundi Feb 24, 2020
f1e7648
test: validate common property usage
lundibundi Feb 24, 2020
ca44071
build: add missing comma in node.gyp
cjihrig Feb 26, 2020
3497370
src: move InternalCallbackScope to StartExecution
codebytere Feb 25, 2020
f71fc90
async_hooks: add store arg in AsyncLocalStorage
puzpuzpuz Feb 24, 2020
d0a0071
stream: invoke buffered write callbacks on error
ronag Nov 22, 2019
6a35b0d
src: don't run bootstrapper in CreateEnvironment
codebytere Feb 22, 2020
9e3e676
module: port source map sort logic from chromium
bcoe Feb 24, 2020
cef5502
test: remove sequential/test-https-keep-alive-large-write.js
rustyconover Jan 27, 2020
b6d33f6
test: change test to not be sensitive to buffer send size
rustyconover Feb 26, 2020
2c0b249
tls: reduce memory copying and number of BIO buffer allocations
rustyconover Jan 24, 2020
4d05508
crypto: turn impossible DH errors into assertions
tniessen Feb 24, 2020
8ad64b8
stream: support passing generator functions into pipeline()
ronag Jan 6, 2020
313ecaa
stream: fix broken pipeline error propagation
ronag Feb 21, 2020
8a2b62e
stream: ensure pipeline always destroys streams
ronag Feb 24, 2020
e6125cd
deps: V8: backport f7771e5b0cc4
mmarchini Feb 26, 2020
91ce69a
meta: move Glen Keane to Collaborator Emeritus
Trott Feb 28, 2020
ded3890
meta: move maclover7 to Emeritus
Trott Feb 28, 2020
c801045
meta: move jbergstroem to emeritus
Trott Feb 28, 2020
3bd8fea
meta: move aqrln to emeritus
Trott Feb 28, 2020
3849474
test: fix flaky test-gc-net-timeout
ronag Feb 22, 2020
9a41ced
build: only lint markdown files that have changed (POSIX-only)
Trott Feb 23, 2020
166579f
doc: add link to sem-ver info
rosaxxny Feb 27, 2020
49864d1
test: fix flaky test-dns-any.js
Trott Feb 29, 2020
cd30dbb
doc: revise --zero-fill-buffers text in buffer.md
Trott Feb 29, 2020
9325634
test: improve disable AsyncLocalStorage test
puzpuzpuz Feb 28, 2020
fbaab7d
deps: openssl: cherry-pick 4dcb150ea30f
AdamMajer Feb 28, 2020
1bca7b6
test: move test-inspector-module to parallel
Trott Feb 29, 2020
f6ffdc2
2020-03-04 Version 13.10.0 (Current)
codebytere Feb 29, 2020
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
module: package "exports" error refinements
PR-URL: #31625
Reviewed-By: Jan Krems <jan.krems@gmail.com>
  • Loading branch information
guybedford authored and codebytere committed Feb 27, 2020
commit bbb6cc733cccf0e93a5683b21a8cbc08222e267c
20 changes: 20 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,12 @@ An invalid HTTP token was supplied.

An IP address is not valid.

<a id="ERR_INVALID_MODULE_SPECIFIER"></a>
### `ERR_INVALID_MODULE_SPECIFIER`

The imported module string is an invalid URL, package name, or package subpath
specifier.

<a id="ERR_INVALID_OPT_VALUE"></a>
### `ERR_INVALID_OPT_VALUE`

Expand All @@ -1334,6 +1340,12 @@ An invalid or unknown file encoding was passed.

An invalid `package.json` file was found which failed parsing.

<a id="ERR_INVALID_PACKAGE_TARGET"></a>
### `ERR_INVALID_PACKAGE_TARGET`

The `package.json` [exports][] field contains an invalid target mapping value
for the attempted module resolution.

<a id="ERR_INVALID_PERFORMANCE_MARK"></a>
### `ERR_INVALID_PERFORMANCE_MARK`

Expand Down Expand Up @@ -1640,6 +1652,13 @@ A non-context-aware native addon was loaded in a process that disallows them.

A given value is out of the accepted range.

<a id="ERR_PACKAGE_PATH_NOT_EXPORTED"></a>
### `ERR_PACKAGE_PATH_NOT_EXPORTED`

The `package.json` [exports][] field does not export the requested subpath.
Because exports are encapsulated, private internal modules that are not exported
cannot be imported through the package resolution, unless using an absolute URL.

<a id="ERR_REQUIRE_ESM"></a>
### `ERR_REQUIRE_ESM`

Expand Down Expand Up @@ -2499,6 +2518,7 @@ such as `process.stdout.on('data')`.
[crypto digest algorithm]: crypto.html#crypto_crypto_gethashes
[domains]: domain.html
[event emitter-based]: events.html#events_class_eventemitter
[exports]: esm.html#esm_package_exports
[file descriptors]: https://en.wikipedia.org/wiki/File_descriptor
[policy]: policy.html
[stream-based]: stream.html
Expand Down
75 changes: 44 additions & 31 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,17 @@ of these top-level routines unless stated otherwise.
_defaultEnv_ is the conditional environment name priority array,
`["node", "import"]`.

The resolver can throw the following errors:
* _Invalid Module Specifier_: Module specifier is an invalid URL, package name
or package subpath specifier.
* _Invalid Package Configuration_: package.json configuration is invalid or
contains an invalid configuration.
* _Invalid Package Target_: Package exports define a target module within the
package that is an invalid type or string target.
* _Package Path Not Exported_: Package exports do not define or permit a target
subpath in the package for the given module.
* _Module Not Found_: The package or module requested does not exist.

<details>
<summary>Resolver algorithm specification</summary>

Expand All @@ -1401,7 +1412,7 @@ _defaultEnv_ is the conditional environment name priority array,
> 1. Set _resolvedURL_ to the result of parsing and reserializing
> _specifier_ as a URL.
> 1. Otherwise, if _specifier_ starts with _"/"_, then
> 1. Throw an _Invalid Specifier_ error.
> 1. Throw an _Invalid Module Specifier_ error.
> 1. Otherwise, if _specifier_ starts with _"./"_ or _"../"_, then
> 1. Set _resolvedURL_ to the URL resolution of _specifier_ relative to
> _parentURL_.
Expand All @@ -1411,7 +1422,7 @@ _defaultEnv_ is the conditional environment name priority array,
> **PACKAGE_RESOLVE**(_specifier_, _parentURL_).
> 1. If _resolvedURL_ contains any percent encodings of _"/"_ or _"\\"_ (_"%2f"_
> and _"%5C"_ respectively), then
> 1. Throw an _Invalid Specifier_ error.
> 1. Throw an _Invalid Module Specifier_ error.
> 1. If _resolvedURL_ does not end with a trailing _"/"_ and the file at
> _resolvedURL_ does not exist, then
> 1. Throw a _Module Not Found_ error.
Expand All @@ -1425,22 +1436,22 @@ _defaultEnv_ is the conditional environment name priority array,
> 1. Let _packageName_ be *undefined*.
> 1. Let _packageSubpath_ be *undefined*.
> 1. If _packageSpecifier_ is an empty string, then
> 1. Throw an _Invalid Specifier_ error.
> 1. Throw an _Invalid Module Specifier_ error.
> 1. Otherwise,
> 1. If _packageSpecifier_ does not contain a _"/"_ separator, then
> 1. Throw an _Invalid Specifier_ error.
> 1. Throw an _Invalid Module Specifier_ error.
> 1. Set _packageName_ to the substring of _packageSpecifier_
> until the second _"/"_ separator or the end of the string.
> 1. If _packageName_ starts with _"."_ or contains _"\\"_ or _"%"_, then
> 1. Throw an _Invalid Specifier_ error.
> 1. Throw an _Invalid Module Specifier_ error.
> 1. Let _packageSubpath_ be _undefined_.
> 1. If the length of _packageSpecifier_ is greater than the length of
> _packageName_, then
> 1. Set _packageSubpath_ to _"."_ concatenated with the substring of
> _packageSpecifier_ from the position at the length of _packageName_.
> 1. If _packageSubpath_ contains any _"."_ or _".."_ segments or percent
> encoded strings for _"/"_ or _"\\"_, then
> 1. Throw an _Invalid Specifier_ error.
> 1. Throw an _Invalid Module Specifier_ error.
> 1. Set _selfUrl_ to the result of
> **SELF_REFERENCE_RESOLVE**(_packageName_, _packageSubpath_, _parentURL_).
> 1. If _selfUrl_ isn't empty, return _selfUrl_.
Expand Down Expand Up @@ -1497,7 +1508,7 @@ _defaultEnv_ is the conditional environment name priority array,
> 1. Throw a _Module Not Found_ error.
> 1. If _pjson.exports_ is not **null** or **undefined**, then
> 1. If _exports_ is an Object with both a key starting with _"."_ and a key
> not starting with _"."_, throw an "Invalid Package Configuration" error.
> not starting with _"."_, throw an _Invalid Package Configuration_ error.
> 1. If _pjson.exports_ is a String or Array, or an Object containing no
> keys starting with _"."_, then
> 1. Return **PACKAGE_EXPORTS_TARGET_RESOLVE**(_packageURL_,
Expand All @@ -1506,6 +1517,7 @@ _defaultEnv_ is the conditional environment name priority array,
> 1. Let _mainExport_ be the _"."_ property in _pjson.exports_.
> 1. Return **PACKAGE_EXPORTS_TARGET_RESOLVE**(_packageURL_,
> _mainExport_, _""_).
> 1. Throw a _Package Path Not Exported_ error.
> 1. If _pjson.main_ is a String, then
> 1. Let _resolvedMain_ be the URL resolution of _packageURL_, "/", and
> _pjson.main_.
Expand All @@ -1520,7 +1532,7 @@ _defaultEnv_ is the conditional environment name priority array,

**PACKAGE_EXPORTS_RESOLVE**(_packageURL_, _packagePath_, _exports_)
> 1. If _exports_ is an Object with both a key starting with _"."_ and a key not
> starting with _"."_, throw an "Invalid Package Configuration" error.
> starting with _"."_, throw an _Invalid Package Configuration_ error.
> 1. If _exports_ is an Object and all keys of _exports_ start with _"."_, then
> 1. Set _packagePath_ to _"./"_ concatenated with _packagePath_.
> 1. If _packagePath_ is a key of _exports_, then
Expand All @@ -1536,43 +1548,44 @@ _defaultEnv_ is the conditional environment name priority array,
> of the length of _directory_.
> 1. Return **PACKAGE_EXPORTS_TARGET_RESOLVE**(_packageURL_, _target_,
> _subpath_, _defaultEnv_).
> 1. Throw a _Module Not Found_ error.
> 1. Throw a _Package Path Not Exported_ error.

**PACKAGE_EXPORTS_TARGET_RESOLVE**(_packageURL_, _target_, _subpath_, _env_)

> 1. If _target_ is a String, then
> 1. If _target_ does not start with _"./"_, throw a _Module Not Found_
> error.
> 1. If _subpath_ has non-zero length and _target_ does not end with _"/"_,
> throw a _Module Not Found_ error.
> 1. If _target_ or _subpath_ contain any _"node_modules"_ segments including
> _"node_modules"_ percent-encoding, throw a _Module Not Found_ error.
> 1.If _target_ is a String, then
> 1. If _target_ does not start with _"./"_ or contains any _"node_modules"_
> segments including _"node_modules"_ percent-encoding, throw an
> _Invalid Package Target_ error.
> 1. Let _resolvedTarget_ be the URL resolution of the concatenation of
> _packageURL_ and _target_.
> 1. If _resolvedTarget_ is contained in _packageURL_, then
> 1. Let _resolved_ be the URL resolution of the concatenation of
> _subpath_ and _resolvedTarget_.
> 1. If _resolved_ is contained in _resolvedTarget_, then
> 1. Return _resolved_.
> 1. If _resolvedTarget_ is not contained in _packageURL_, throw an
> _Invalid Package Target_ error.
> 1. If _subpath_ has non-zero length and _target_ does not end with _"/"_,
> throw an _Invalid Module Specifier_ error.
> 1. Let _resolved_ be the URL resolution of the concatenation of
> _subpath_ and _resolvedTarget_.
> 1. If _resolved_ is not contained in _resolvedTarget_, throw an
> _Invalid Module Specifier_ error.
> 1. Return _resolved_.
> 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.
> 1. For each property _p_ of _target_, in object insertion order as,
> 1. If _env_ contains an entry for _p_, then
> 1. Let _targetValue_ be the value of the _p_ property in _target_.
> 1. Let _resolved_ be the result of **PACKAGE_EXPORTS_TARGET_RESOLVE**
> (_packageURL_, _targetValue_, _subpath_, _env_).
> 1. Assert: _resolved_ is a String.
> 1. Return _resolved_.
> 1. Return the result of **PACKAGE_EXPORTS_TARGET_RESOLVE**(
> _packageURL_, _targetValue_, _subpath_, _env_), continuing the
> loop on any _Package Path Not Exported_ error.
> 1. Throw a _Package Path Not Exported_ error.
> 1. Otherwise, if _target_ is an Array, then
> 1. If _target.length is zero, throw an _Invalid Package Target_ error.
> 1. For each item _targetValue_ in _target_, do
> 1. If _targetValue_ is an Array, continue the loop.
> 1. Let _resolved_ be the result of
> **PACKAGE_EXPORTS_TARGET_RESOLVE**(_packageURL_, _targetValue_,
> _subpath_, _env_), continuing the loop on abrupt completion.
> 1. Assert: _resolved_ is a String.
> 1. Return _resolved_.
> 1. Throw a _Module Not Found_ error.
> 1. Return the result of **PACKAGE_EXPORTS_TARGET_RESOLVE**(_packageURL_,
> _targetValue_, _subpath_, _env_), continuing the loop on any
> _Package Path Not Exported_ or _Invalid Package Target_ error.
> 1. Throw the last fallback resolution error.
> 1. Otherwise throw an _Invalid Package Target_ error.

**ESM_FORMAT**(_url_)

Expand Down
29 changes: 28 additions & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
const {
ArrayIsArray,
Error,
JSONStringify,
Map,
MathAbs,
NumberIsInteger,
ObjectDefineProperty,
ObjectKeys,
StringPrototypeSlice,
Symbol,
SymbolFor,
WeakMap,
} = primordials;

const sep = process.platform === 'win32' ? '\\' : '/';

const messages = new Map();
const codes = {};

Expand Down Expand Up @@ -1069,14 +1073,29 @@ E('ERR_INVALID_FILE_URL_PATH', 'File URL path %s', TypeError);
E('ERR_INVALID_HANDLE_TYPE', 'This handle type cannot be sent', TypeError);
E('ERR_INVALID_HTTP_TOKEN', '%s must be a valid HTTP token ["%s"]', TypeError);
E('ERR_INVALID_IP_ADDRESS', 'Invalid IP address: %s', TypeError);
E('ERR_INVALID_MODULE_SPECIFIER', (pkgPath, subpath) => {
assert(subpath !== '.');
return `Package subpath '${subpath}' is not a valid module request for the ` +
`"exports" resolution of ${pkgPath}${sep}package.json`;
}, TypeError);
E('ERR_INVALID_OPT_VALUE', (name, value) =>
`The value "${String(value)}" is invalid for option "${name}"`,
TypeError,
RangeError);
E('ERR_INVALID_OPT_VALUE_ENCODING',
'The value "%s" is invalid for option "encoding"', TypeError);
E('ERR_INVALID_PACKAGE_CONFIG',
'Invalid package config for \'%s\', %s', Error);
`Invalid package config %s${sep}package.json, %s`, Error);
E('ERR_INVALID_PACKAGE_TARGET', (pkgPath, key, subpath, target) => {
if (key === '.') {
return `Invalid "exports" main target ${JSONStringify(target)} defined ` +
`in the package config ${pkgPath}${sep}package.json`;
} else {
return `Invalid "exports" target ${JSONStringify(target)} defined for '${
StringPrototypeSlice(key, 0, -subpath.length || key.length)}' in the ` +
`package config ${pkgPath}${sep}package.json`;
}
}, Error);
E('ERR_INVALID_PERFORMANCE_MARK',
'The "%s" performance mark has not been set', Error);
E('ERR_INVALID_PROTOCOL',
Expand Down Expand Up @@ -1221,6 +1240,14 @@ E('ERR_OUT_OF_RANGE',
msg += ` It must be ${range}. Received ${received}`;
return msg;
}, RangeError);
E('ERR_PACKAGE_PATH_NOT_EXPORTED', (pkgPath, subpath) => {
if (subpath === '.') {
return `No "exports" main resolved in ${pkgPath}${sep}package.json`;
} else {
return `Package subpath '${subpath}' is not defined by "exports" in ${
pkgPath}${sep}package.json`;
}
}, Error);
E('ERR_REQUIRE_ESM',
(filename, parentPath = null, packageJsonPath = null) => {
let msg = `Must use import to load ES Module: ${filename}`;
Expand Down
Loading