Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
c72a678
doc: add missing link for v13.11.0 changelog
MylesBorins Mar 12, 2020
397cbca
meta: move inactive collaborators to emeriti
Trott Mar 8, 2020
19fee76
doc: add Ruben to TSC
mhdawson Mar 11, 2020
cd0982a
lib: change var to let/const
himself65 Mar 2, 2020
2262e7c
test: fix test-tls-env-extra-ca-file-load
ebickle Mar 3, 2020
d497f26
src: refactor to more safe method
gengjiawen Mar 4, 2020
08edf53
test: `buffer.write` with longer string scenario
HarshithaKP Mar 6, 2020
435341a
lib: use spread operator on cluster
himself65 Mar 6, 2020
2069c4e
build: disable libstdc++ debug containers globally
bnoordhuis Jan 3, 2020
53fd0d8
util: use a global symbol for `util.promisify.custom`
ExE-Boss Feb 7, 2020
5080734
doc: expand fs.watch caveats
bzoz Mar 10, 2020
1ecd407
repl: align preview with the actual executed code
BridgeAR Feb 24, 2020
ed83a1c
test: refactor and simplify test-repl-preview
BridgeAR Mar 9, 2020
597bcb5
doc: update conditional exports recommendations
guybedford Mar 4, 2020
e83dcde
worker: allow URL in Worker constructor
aduh95 Feb 6, 2020
c0af3ac
test: use portable EOL
HarshithaKP Mar 5, 2020
d2fea9f
http2: rename counter in `mapToHeaders` inner loop
mkrawczuk Feb 28, 2020
fd80c21
test: add new scenario for async-local storage
HarshithaKP Mar 4, 2020
ae90bcc
deps: V8: cherry-pick f9257802c1c0
mmarchini Mar 10, 2020
fa1fa31
util: text decoding allows SharedArrayBuffer
bfarias-godaddy Mar 11, 2020
3e9012a
esm: port loader code to JS
addaleax Mar 7, 2020
09ca76b
test: verify that WASI errors are rethrown
cjihrig Mar 9, 2020
bee1261
deps: upgrade to libuv 1.35.0
cjihrig Mar 11, 2020
963ce08
tools: update to [email protected]
Trott Mar 14, 2020
fbcf602
test: make test-memory-usage predictable
mmarchini Mar 12, 2020
7fc5e6d
src: fix warn_unused_result compiler warning
cjihrig Mar 13, 2020
df1d4f7
test: workaround for V8 8.1 inspector pause issue
mmarchini Mar 12, 2020
c00ce7b
src: find .text section using dl_iterate_phdr
Mar 13, 2020
1950c08
src: unconditionally include report feature
cjihrig Mar 13, 2020
96ad768
build: remove node_report option in node.gyp
cjihrig Mar 13, 2020
074c3c1
build: make --without-report a no-op
cjihrig Mar 13, 2020
76781bd
test: remove common.skipIfReportDisabled()
cjihrig Mar 13, 2020
cd388b2
doc,lib,src,test: make --experimental-report a nop
cjihrig Mar 13, 2020
2e1fb2b
doc: update stability of report features
cjihrig Mar 13, 2020
59a21e2
n-api: fix comment on expected N-API version
mhdawson Mar 12, 2020
5adaf10
tools: update [email protected]
Trott Mar 14, 2020
b5b7bf5
src,cli: support compact (one-line) JSON reports
sam-github Mar 13, 2020
11ed1e6
deps,doc: move openssl maintenance guide to doc
sam-github Mar 11, 2020
71a2fa2
errors: drop pronouns from ERR_WORKER_PATH message
cjihrig Mar 15, 2020
1476182
src: handle NULL env scenario
himself65 Mar 12, 2020
05fd160
test: use Promise.all() in test-hash-seed
Trott Mar 14, 2020
ef32069
http: don't emit 'finish' after 'error'
ronag Mar 14, 2020
36ba54e
lib: add option to disable __proto__
devsnek Mar 15, 2020
b875346
doc: complete n-api version matrix
Mar 16, 2020
d2ce8e9
doc: fix some 404 links
watson Mar 11, 2020
dedd219
tools: fixup icutrim.py use of string and bytes objects
jmercier-lbi Feb 6, 2020
7904ecd
deps: update to uvwasi 0.0.6
cjihrig Mar 15, 2020
1c4a112
src: clean up stream_base.h and stream-base-inl.h
jasnell Mar 16, 2020
569e555
doc: update security release process
sam-github Feb 7, 2020
f873d87
src: prefer OnScopeLeave over shared_ptr<void>
addaleax Mar 13, 2020
3825afe
deps: upgrade to c-ares v1.16.0
addaleax Mar 13, 2020
79fdc6b
cli: allow --huge-max-old-generation-size in NODE_OPTIONS
addaleax Mar 13, 2020
4d173ea
test: uv_tty_init returns EBADF on IBM i
dmabupt Mar 18, 2020
243d0d4
src: add debug option to report large page stats
Mar 17, 2020
8ea5ffc
build: expand ASAN acronym in configure help
sam-github Mar 17, 2020
e16964e
deps: minor ICU fixes: maint docs/tool, downloader
srl295 Mar 18, 2020
2cb9f7a
deps: update to ICU 66.1
srl295 Mar 18, 2020
11650c6
src: update comment for SetImmediate()
addaleax Mar 16, 2020
bd55a9a
src: avoid Isolate::GetCurrent() for platform implementation
addaleax Mar 14, 2020
85bdb42
Revert "build: add asan check in Github action"
mmarchini Mar 11, 2020
bdcc11f
test: replace Map with Array in cluster-net-listen tests
Trott Mar 18, 2020
2e28783
test: replace countdown with Promise.all() in cluster-net-listen tests
Trott Mar 19, 2020
7356c43
module: add hook for global preload code
hybrist Mar 3, 2020
3878d8d
deps: upgrade openssl sources to 1.1.1e
hassaanp Mar 17, 2020
d719f87
deps: adjust openssl configuration for 1.1.1e
hassaanp Mar 18, 2020
d640426
deps: update archs files for OpenSSL-1.1.1e
hassaanp Mar 18, 2020
fcf9b46
test: discard data received by client
hassaanp Mar 19, 2020
76a7386
test: end tls connection with some data
sam-github Mar 20, 2020
2fe351f
src: delete CallbackInfo when cleared from cleanup hook
addaleax Mar 21, 2020
2bcf535
src: simplify IsolateData shortcut accesses
addaleax Mar 21, 2020
6f06cf0
src: delete BaseObjectWeakPtr data when pointee is gone
addaleax Mar 20, 2020
2f73e6e
test: use mustCall in place of countdown in timers test
Trott Mar 22, 2020
fbdc4f5
deps: upgrade npm to 6.14.1
isaacs Feb 27, 2020
eef4721
deps: update npm to 6.14.3
MylesBorins Mar 19, 2020
8201704
deps: remove *.pyc files from deps/npm
bnoordhuis Mar 20, 2020
6387cf8
deps: update term-size with signed version
rvagg Jan 30, 2020
f8a020e
build: macOS package notarization
rvagg Jan 22, 2020
99f260f
doc: official macOS builds now on 10.15 + Xcode 11
rvagg Mar 4, 2020
471a5d8
doc: add note re term-size commit on top of npm
rvagg Mar 21, 2020
23ba088
stream: don't emit 'finish' after 'error'
ronag Mar 14, 2020
4ca3030
doc: import clarifications with links to MDN
aldeed Mar 18, 2020
81183ca
build: annotate markdown lint failures in pull requests
richardlau Mar 20, 2020
bbea3f2
doc: improve wording in esm.md
Trott Mar 22, 2020
dfcc3e8
doc: improve wording in vm.md
Trott Mar 22, 2020
07e4131
test: refactoring / cleanup on child-process tests
jasnell Mar 23, 2020
99a7636
doc: fix lint warning in doc/api/esm.md
richardlau Mar 24, 2020
b5e4adf
doc: add new TSC members
mhdawson Mar 24, 2020
0185e3a
stream: add pipeline test for destroy of returned stream
ronag Mar 22, 2020
b7a8878
stream: fix pipeline with dest in objectMode
ronag Mar 21, 2020
28e298f
report: handle on-fatalerror better
HarshithaKP Mar 16, 2020
e9e12b8
src: use single ObjectTemplate for TextDecoder
addaleax Mar 22, 2020
94952b4
src: enhance C++ sprintf utility
himself65 Mar 20, 2020
6693b40
doc: simplify and correct example descriptions in net.md
Trott Mar 24, 2020
3e002c3
doc: update async_hooks.md
Doc999tor Mar 20, 2020
9fda912
doc: trim wording in n-api.md text about exceptions
Trott Mar 24, 2020
6168bd5
doc: remove unnecessary "obvious(ly)" modifiers in esm.md
Trott Mar 24, 2020
40a9289
doc: remove extraneous sentence in events.md
Trott Mar 24, 2020
deab08b
deps: upgrade npm to 6.14.4
ruyadorno Mar 26, 2020
56da8df
stream: emit 'pause' on unpipe
ronag Mar 24, 2020
f6a339f
2020-03-26 Version 13.12.0 (Current)
MylesBorins Mar 24, 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
esm: port loader code to JS
There is no reason for this to be in C++. Using JavaScript means that
the code is more accessible to more developers, which is important
for any Node.js feature. This also simplifies the code significantly
in some areas. On the technical side, this potentially also enables
making some of the file system operations that are involved
asynchronous.

PR-URL: #32201
Reviewed-By: Bradley Farias <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
  • Loading branch information
addaleax authored and MylesBorins committed Mar 24, 2020
commit 3e9012a3da59b11050cb0395469624cf96df4181
59 changes: 43 additions & 16 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1074,29 +1074,50 @@ 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`;
E('ERR_INVALID_MODULE_SPECIFIER', (pkgPath, subpath, base = undefined) => {
if (subpath === undefined) {
return `Invalid package name '${pkgPath}' imported from ${base}`;
} else if (base === undefined) {
assert(subpath !== '.');
return `Package subpath '${subpath}' is not a valid module request for ` +
`the "exports" resolution of ${pkgPath}${sep}package.json`;
} else {
return `Package subpath '${subpath}' is not a valid module request for ` +
`the "exports" resolution of ${pkgPath} imported from ${base}`;
}
}, 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 %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 ` +
E('ERR_INVALID_PACKAGE_CONFIG', (path, message, hasMessage = true) => {
if (hasMessage)
return `Invalid package config ${path}${sep}package.json, ${message}`;
else
return `Invalid JSON in ${path} imported from ${message}`;
}, Error);
E('ERR_INVALID_PACKAGE_TARGET',
(pkgPath, key, subpath, target, base = undefined) => {
if (key === null) {
if (subpath !== '') {
return `Invalid "exports" target ${JSONStringify(target)} defined ` +
`for '${subpath}' in the package config ${pkgPath} imported from ` +
base;
} else {
return `Invalid "exports" main target ${target} defined in the ` +
`package config ${pkgPath} imported from ${base}.`;
}
} else 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 ` +
} 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);
}
}, Error);
E('ERR_INVALID_PERFORMANCE_MARK',
'The "%s" performance mark has not been set', Error);
E('ERR_INVALID_PROTOCOL',
Expand Down Expand Up @@ -1207,6 +1228,9 @@ E('ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK',
'The ES Module loader may not return a format of \'dynamic\' when no ' +
'dynamicInstantiate function was provided', Error);
E('ERR_MISSING_OPTION', '%s is required', TypeError);
E('ERR_MODULE_NOT_FOUND', (path, base, type = 'package') => {
return `Cannot find ${type} '${path}' imported from ${base}`;
}, Error);
E('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times', Error);
E('ERR_NAPI_CONS_FUNCTION', 'Constructor must be a function', TypeError);
E('ERR_NAPI_INVALID_DATAVIEW_ARGS',
Expand Down Expand Up @@ -1241,12 +1265,15 @@ E('ERR_OUT_OF_RANGE',
msg += ` It must be ${range}. Received ${received}`;
return msg;
}, RangeError);
E('ERR_PACKAGE_PATH_NOT_EXPORTED', (pkgPath, subpath) => {
E('ERR_PACKAGE_PATH_NOT_EXPORTED', (pkgPath, subpath, base = undefined) => {
if (subpath === '.') {
return `No "exports" main resolved in ${pkgPath}${sep}package.json`;
} else {
} else if (base === undefined) {
return `Package subpath '${subpath}' is not defined by "exports" in ${
pkgPath}${sep}package.json`;
} else {
return `Package subpath '${subpath}' is not defined by "exports" in ${
pkgPath} imported from ${base}`;
}
}, Error);
E('ERR_REQUIRE_ESM',
Expand Down
15 changes: 5 additions & 10 deletions lib/internal/modules/esm/get_format.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
'use strict';

const { StringPrototypeStartsWith } = primordials;
const { extname } = require('path');
const { getOptionValue } = require('internal/options');

const experimentalJsonModules = getOptionValue('--experimental-json-modules');
const experimentalSpeciferResolution =
getOptionValue('--experimental-specifier-resolution');
const experimentalWasmModules = getOptionValue('--experimental-wasm-modules');
const { getPackageType } = internalBinding('module_wrap');
const { getPackageType } = require('internal/modules/esm/resolve');
const { URL, fileURLToPath } = require('internal/url');
const { ERR_UNKNOWN_FILE_EXTENSION } = require('internal/errors').codes;

// const TYPE_NONE = 0;
// const TYPE_COMMONJS = 1;
const TYPE_MODULE = 2;

const extensionFormatMap = {
'__proto__': null,
'.cjs': 'commonjs',
Expand All @@ -37,8 +33,8 @@ if (experimentalWasmModules)
if (experimentalJsonModules)
extensionFormatMap['.json'] = legacyExtensionFormatMap['.json'] = 'json';

function defaultGetFormat(url, context, defaultGetFormat) {
if (url.startsWith('nodejs:')) {
function defaultGetFormat(url, context, defaultGetFormatUnused) {
if (StringPrototypeStartsWith(url, 'nodejs:')) {
return { format: 'builtin' };
}
const parsed = new URL(url);
Expand All @@ -55,8 +51,7 @@ function defaultGetFormat(url, context, defaultGetFormat) {
const ext = extname(parsed.pathname);
let format;
if (ext === '.js') {
format = getPackageType(parsed.href) === TYPE_MODULE ?
'module' : 'commonjs';
format = getPackageType(parsed.href) === 'module' ? 'module' : 'commonjs';
} else {
format = extensionFormatMap[ext];
}
Expand Down
Loading