Bradley Farias
b04f2b6618
policy: increase tests via permutation matrix
...
PR-URL: https://github.com/nodejs/node/pull/34404
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-08-05 13:48:59 -05:00
Gus Caplan
dc00a07426
Revert "module: disable cjs snapshotting into esm loader"
...
This reverts commit 1fe39f0b4b .
PR-URL: https://github.com/nodejs/node/pull/34562
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2020-07-30 14:55:45 -05:00
Guy Bedford
1fe39f0b4b
module: disable cjs snapshotting into esm loader
...
PR-URL: https://github.com/nodejs/node/pull/34467
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
2020-07-29 16:29:18 -07:00
Daniele Belardi
ec2ffd6b9d
module: self referential modules in repl or -r
...
Load self referential modules from the repl and using the preload flag
`-r`. In both cases the base path used for resolution is the current
`process.cwd()`. Also fixes an internal cycle bug in the REPL exports
resolution.
PR-URL: https://github.com/nodejs/node/pull/32261
Fixes: https://github.com/nodejs/node/issues/31595
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2020-07-23 07:50:01 -07:00
Myles Borins
da95dd7732
Revert "module: fix check for package.json at volume root"
...
This reverts commit 51af89fe45 .
This has needed to be backed out of both the 14.5.0 and 14.6.0
releases due to creating regressions across multiple projects
including:
* coffeescript
* JSONStream
* gulp
* and more
We should reopen a PR to figure out how to land this in a way
that is non-breaking.
Refs: https://github.com/nodejs/node/pull/33476
PR-URL: https://github.com/nodejs/node/pull/34403
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-07-20 12:08:36 -04:00
Beth Griggs
128ed10fc4
module: update expected module.parent DEP number
...
PR-URL: https://github.com/nodejs/node/pull/34368
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-07-15 11:37:39 -04:00
Michaël Zasso
05539c166a
repl: support --loader option in builtin REPL
...
Fixes: https://github.com/nodejs/node/issues/33435
PR-URL: https://github.com/nodejs/node/pull/33437
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2020-07-14 15:21:26 +02:00
Guy Bedford
1237955d41
module: package "imports" field
...
PR-URL: https://github.com/nodejs/node/pull/34117
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
2020-07-09 19:19:35 -07:00
Fábio Santos
e199fc5534
module: fix error message about importing names from cjs
...
When importing specific names from a CJS module, and renaming them using
`as`, the example fix in the error message erroneously contains the
keyword `as` in the destructuring variable declaration.
Example of this issue:
import { parse as acornParse } from "acorn";
^^^^^
SyntaxError: The requested module 'acorn' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from 'acorn';
const { parse as acornParse } = pkg;
PR-URL: https://github.com/nodejs/node/pull/33882
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-06-19 18:14:27 +02:00
Brian White
c24b74a7ab
lib: improve debuglog() performance
...
PR-URL: https://github.com/nodejs/node/pull/32260
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-30 17:24:43 -04:00
Jan Krems
d12d5ef3ef
module: remove dynamicInstantiate loader hook
...
The dynamicInstantiate loader hook requires that the hooks run in the
same global scope as the code being loaded. We don't want to commit to
this being true in the future. It stops us from sharing hooks between
multiple worker threads or isolating loader hook from the application
code.
Using `getSource` and `getGlobalPreloadCode` the same use cases should
be covered.
PR-URL: https://github.com/nodejs/node/pull/33501
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
2020-05-27 16:38:38 -07:00
bcoe
458677f5ef
errors: print original exception context
...
When --enable-source-maps is set, the error context displayed
above the stack trace now shows original source rather than
transpiled.
PR-URL: https://github.com/nodejs/node/pull/33491
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
2020-05-24 22:03:34 -07:00
Kirill Shatskiy
8f10bb2da5
esm: share package.json cache between ESM and CJS loaders
...
Refs: https://github.com/nodejs/node/issues/30674
PR-URL: https://github.com/nodejs/node/pull/33229
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
2020-05-24 16:22:31 -07:00
Antoine du HAMEL
6443ab9595
module: deprecate module.parent
...
This feature does not work when a module is imported using ECMAScript
modules specification, therefore it is deprecated.
Fixes: https://github.com/nodejs/modules/issues/469
PR-URL: https://github.com/nodejs/node/pull/32217
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2020-05-24 03:38:39 +02:00
Geoffrey Booth
51af89fe45
module: fix check for package.json at volume root
...
Fix package.json files at the volume root so that
when they contain {"type": "module"}, they behave
as documented, like such a package.json file in
any other folder.
Fixes: https://github.com/nodejs/node/issues/33438
PR-URL: https://github.com/nodejs/node/pull/33476
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2020-05-21 22:31:29 -07:00
Bradley Farias
cd4985c488
esm: doc & validate source values for formats
...
PR-URL: https://github.com/nodejs/node/pull/32202
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
2020-05-21 12:59:50 +08:00
Luigi Pinca
b533fb3508
tools: enable no-else-return lint rule
...
Refs: https://github.com/nodejs/node/pull/32644
Refs: https://github.com/nodejs/node/pull/32662
PR-URL: https://github.com/nodejs/node/pull/32667
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-05-16 06:42:16 +02:00
Antoine du Hamel
1cb80d1e05
esm: improve commonjs hint on module not found
...
Adds hint when module specifier is a file URL.
PR-URL: https://github.com/nodejs/node/pull/33220
Fixes: https://github.com/nodejs/node/issues/33219
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2020-05-15 19:09:01 -07:00
Antoine du HAMEL
985e9c5fe5
module: add specific error for dir import
...
PR-URL: https://github.com/nodejs/node/pull/33220
Fixes: https://github.com/nodejs/node/issues/33219
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2020-05-15 19:08:39 -07:00
Matteo Collina
2d5d77306f
Revert "vm: add importModuleDynamically option to compileFunction"
...
This reverts commit 74c393dd93 .
Fixes: https://github.com/nodejs/node/issues/33166
PR-URL: https://github.com/nodejs/node/pull/33364
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2020-05-15 12:14:35 +02:00
Ruben Bridgewater
24bf1adacc
module: do not check circular dependencies for exported proxies
...
In case the exported module is a proxy that has the `getPrototypeOf`
or `setPrototypeOf` trap, skip the circular dependencies check.
It would otherwise be triggered by the check itself.
Fixes: https://github.com/nodejs/node/issues/33334
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33338
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
2020-05-15 01:55:28 +02:00
Ruben Bridgewater
900daedbfe
repl: replace hard coded core module list with actual list
...
This replaces the internally used hard coded Node.js core module
list with the actual internal existent modules. That way all modules
are automatically picked up instead of having to update the list
manually.
This currently only applies to the REPL and to the Node.js `eval`
functionality (User passed `-e` or `--eval` arguments to Node without
`-i` or `--interactive`).
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33282
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-15 01:48:17 +02:00
Gus Caplan
5ae5262f44
src: add support for TLA
...
PR-URL: https://github.com/nodejs/node/pull/30370
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-05-14 12:39:23 -05:00
Myles Borins
2c3c9f5a3f
module: better error for named exports from cjs
...
We do not support importing named exports from a CJS module.
This change decorates the error message for missing named exports in
the case where the module being imported is expected to be CJS by the
ESM loader.
Signed-off-by: Myles Borins <myles.borins@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/33256
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-08 15:35:16 -04:00
Daniele Belardi
8f87d252fa
esm: improve commonjs hint on module not found
...
Run CommonJS resolver only if `error.code` is ERR_MODULE_NOT_FOUND.
Avoid using absolute paths in hint by:
* using a parent-relative path if the specifier is a relative path
* using a `pkg/x.js` format if the specifier is bare (e.g. `pkg/x`)
PR-URL: https://github.com/nodejs/node/pull/31906
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-05-03 11:29:09 -07:00
Guy Bedford
2496db8e09
module: no type module resolver side effects
...
PR-URL: https://github.com/nodejs/node/pull/33086
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
2020-04-29 22:10:35 -07:00
James M Snell
80b9777888
lib: cosmetic change to builtinLibs list for maintainability
...
This is a largely cosmetic change suggested for easier
maintainability of the builtinLibs list. While the
QUIC PR no longer modifies this list, the original version
of the PR did and the fact that all of the entries were
bundled up into the same lines meant that adding one
forced a larger change to all. With this PR, when we
want to add a new built-in, it won't impact any of the
others.
PR-URL: https://github.com/nodejs/node/pull/33106
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-04-29 14:35:10 -07:00
Anna Henningsen
38998d8538
module: do not warn when accessing __esModule of unfinished exports
...
Since this property access is performed by generated code, and not
used for accessing the actual exports of a module (and because
transpilers generally define it as the first key of `module.exports`
when it *is* present), it should be okay to allow it.
Refs: https://github.com/nodejs/node/pull/29935
Fixes: https://github.com/nodejs/node/issues/33046
PR-URL: https://github.com/nodejs/node/pull/33048
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
2020-04-27 19:33:41 +02:00
Gus Caplan
74c393dd93
vm: add importModuleDynamically option to compileFunction
...
Fixes: https://github.com/nodejs/node/issues/31860
PR-URL: https://github.com/nodejs/node/pull/32985
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-04-25 09:49:53 -05:00
Guy Bedford
e767ed0558
module: exports not exported for null resolutions
...
PR-URL: https://github.com/nodejs/node/pull/32838
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2020-04-22 15:48:44 -07:00
Qinhui Chen
6bcf968401
module: fix memory leak when require error occurs
...
Delete useless module in parent module: parent.children array
when error occurs, so that it can be garbage collected.
Fixes: https://github.com/nodejs/node/issues/32836
PR-URL: https://github.com/nodejs/node/pull/32837
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com >
2020-04-17 12:35:00 +03:00
Jan Krems
9129ab1996
module: expose exports conditions to loaders
...
PR-URL: https://github.com/nodejs/node/pull/31303
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
2020-04-03 01:29:39 +02:00
Guy Bedford
534c204e22
module: path-only CJS exports extension searching
...
PR-URL: https://github.com/nodejs/node/pull/32351
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-03-31 20:39:01 -06:00
Jan Krems
07a1fb953e
module: add hook for global preload code
...
PR-URL: https://github.com/nodejs/node/pull/32068
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
2020-03-23 08:39:37 -05:00
Anna Henningsen
605615e5f3
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: https://github.com/nodejs/node/pull/32201
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2020-03-13 17:34:43 +01:00
himself65
517b0470c7
esm: remove unused parameter on module.instantiate
...
PR-URL: https://github.com/nodejs/node/pull/32147
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2020-03-11 17:39:47 +01:00
Guy Bedford
49ad16104f
module: disable conditional exports, self resolve warnings
...
PR-URL: https://github.com/nodejs/node/pull/31845
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
2020-02-26 23:21:56 +02:00
Guy Bedford
58de9b46b8
module: package "exports" error refinements
...
PR-URL: https://github.com/nodejs/node/pull/31625
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2020-02-18 13:34:40 +02:00
Rich Trott
8c18e91c8a
process: remove undocumented now argument from emitWarning()
...
process.emitWarning() "now" option is undocumented and a Boolean trap.
Remove it before people start adopting it.
We only need it in one place internally. Replace it with an
internal-only emitWarningSync() function.
PR-URL: https://github.com/nodejs/node/pull/31643
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-02-07 15:37:36 -10:00
Guy Bedford
0f96dc266f
esm: import.meta.resolve with nodejs: builtins
...
PR-URL: https://github.com/nodejs/node/pull/31032
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-02-03 18:31:02 +02:00
Geoffrey Booth
c692568a09
module: drop support for extensionless main entry points in esm
...
PR-URL: https://github.com/nodejs/node/pull/31415
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-22 23:21:11 -08:00
Geoffrey Booth
04d07ed3ab
module: revert #31021
...
reverses baa3621bb1
PR-URL: https://github.com/nodejs/node/pull/31415
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-22 23:21:02 -08:00
Guy Bedford
c2c3274631
module: fix check exports issue in cjs module loading
...
Refs: https://github.com/nodejs/node/pull/31001#issuecomment-576353389
PR-URL: https://github.com/nodejs/node/pull/31427
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Shelley Vohr <codebytere@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-20 21:32:52 -08:00
Guy Bedford
fc4e413554
module: unflag conditional exports
...
PR-URL: https://github.com/nodejs/node/pull/31001
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-01-15 20:48:52 -05:00
Guy Bedford
405e7b4557
module: logical conditional exports ordering
...
PR-URL: https://github.com/nodejs/node/pull/31008
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2020-01-07 06:14:19 +02:00
Geoffrey Booth
2551a21553
module: loader getSource, getFormat, transform hooks
...
PR-URL: https://github.com/nodejs/node/pull/30986
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
2020-01-07 01:31:05 +02:00
Sebastien Ahkrin
9085c03806
lib: replace Map global by the primordials
...
PR-URL: https://github.com/nodejs/node/pull/31155
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-01-04 14:56:52 -08:00
Sebastien Ahkrin
c9b93e2344
lib: replace use of Error with primordials
...
PR-URL: https://github.com/nodejs/node/pull/31163
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-01-04 14:50:18 -08:00
Sebastien Ahkrin
256c9a43f4
lib: replace Set global by the primordials
...
PR-URL: https://github.com/nodejs/node/pull/31154
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-01-04 12:41:09 -08:00
Thomas
a25a628452
esm: better error message for unsupported URL
...
The default ESM loader supports only file and data URLs.
This PR adds better error message for it.
PR-URL: https://github.com/nodejs/node/pull/31129
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2020-01-03 15:33:16 +01:00