Antoine du Hamel
4df59bc727
module: add some typings to internal/modules/esm/resolve
...
PR-URL: https://github.com/nodejs/node/pull/39504
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2021-08-16 16:34:20 -04:00
Antoine du Hamel
e13162de09
module: refine enrichCJSError
...
PR-URL: https://github.com/nodejs/node/pull/39507
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-08-02 09:14:54 +02:00
Guy Bedford
93eff3f5a6
esm: refine ERR_REQUIRE_ESM errors
...
PR-URL: https://github.com/nodejs/node/pull/39175
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-07-29 11:56:44 +01:00
bcoe
ac05a0a8a3
errors: don't throw TypeError on missing export
...
Logic in module_job.js assumes detailed stack trace from node_errors.cc
which is not populated when --enable-source-maps is set.
Fixes #38790
PR-URL: https://github.com/nodejs/node/pull/39017
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
2021-07-11 09:43:54 +02:00
bcoe
eddde6c31a
errors: don't rekey on primitive type
...
If an error is thrown before a module is loaded, we attempt to cache
source map against error object, rather than module object. We
can't do this if the error is a primitive type
Fixes #38945
PR-URL: https://github.com/nodejs/node/pull/39025
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-06-21 21:48:23 -04:00
Antoine du Hamel
ded83350a0
lib: make primordials Promise methods safe
...
`catch` and `finally` methods on %Promise.prototype% looks up the `then`
property of the instance, making it at risk of prototype pollution.
PR-URL: https://github.com/nodejs/node/pull/38650
Backport-PR-URL: https://github.com/nodejs/node/pull/38878
Refs: https://tc39.es/ecma262/#sec-promise.prototype.catch
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2021-06-14 08:17:31 +02:00
Antoine du Hamel
92ed1c6cce
module: fix legacy node specifier resolution to resolve "main" field
...
PR-URL: https://github.com/nodejs/node/pull/38979
Fixes: https://github.com/nodejs/node/issues/32103
Fixes: https://github.com/nodejs/node/issues/38739
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2021-06-13 19:38:01 -07:00
bl-ue
08ad2f6c18
lib: fix typos
...
PR-URL: https://github.com/nodejs/node/pull/38846
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Khaidi Chu <i@2333.moe >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
2021-06-01 08:18:49 -04:00
Antoine du Hamel
4c4902748c
module: add support for URL to import.meta.resolve
...
PR-URL: https://github.com/nodejs/node/pull/38587
Refs: https://github.com/nodejs/node/pull/38585
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-05-17 09:11:35 +02:00
Antoine du Hamel
fcac2e0363
lib: harden lint checks for globals
...
PR-URL: https://github.com/nodejs/node/pull/38419
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
2021-04-29 13:45:43 +02:00
Antoine du Hamel
7b2bad4005
module: clarify CJS global-like variables not defined error message
...
Fixes: https://github.com/nodejs/node/issues/33741
PR-URL: https://github.com/nodejs/node/pull/37852
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2021-04-13 19:06:48 +02:00
Antoine du Hamel
23d2c54bab
lib: add globalThis to primordials
...
PR-URL: https://github.com/nodejs/node/pull/38211
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-04-13 18:33:57 +02:00
Bradley Farias
8dd06850ae
esm: use correct URL for error decoration
...
PR-URL: https://github.com/nodejs/node/pull/37854
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2021-04-12 16:47:57 -05:00
Antoine du Hamel
46062a0d2c
module: improve error message for invalid data URL
...
Fixes: https://github.com/nodejs/node/issues/37647
PR-URL: https://github.com/nodejs/node/pull/37701
Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2021-04-03 20:06:05 +02:00
Antoine du Hamel
3cc9aec988
module: runtime deprecate subpath folder mappings
...
PR-URL: https://github.com/nodejs/node/pull/37215
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2021-03-20 19:14:14 +01:00
Antoine du Hamel
9fab73c73b
module: runtime deprecate "main" index and extension lookups
...
PR-URL: https://github.com/nodejs/node/pull/37206
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2021-03-19 12:38:20 +01:00
069b5df4f6
module: add support for node:‑prefixed require(…) calls
...
Fixes: https://github.com/nodejs/node/issues/36098
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com >
Co-authored-by: Guy Bedford <guybedford@gmail.com >
Co-authored-by: Darshan Sen <raisinten@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/37246
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2021-03-19 12:34:58 +01:00
marsonya
b079960b18
lib: fix typo in internal/modules/esm/module_job.js
...
PR-URL: https://github.com/nodejs/node/pull/37773
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com >
2021-03-19 12:26:04 +01:00
Antoine du Hamel
f34d8de65a
lib: remove use of array destructuring
...
PR-URL: https://github.com/nodejs/node/pull/36818
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-03-03 19:53:24 +01:00
Antoine du Hamel
83cce8717f
lib: use <array>.push and <array>.unshift instead of <array>.concat
...
Using `push` and `unshift` methods is more performant than reassigning a
new array created with `concat`.
PR-URL: https://github.com/nodejs/node/pull/37239
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-02-26 11:11:22 +01:00
Antoine du Hamel
76a073b67e
module: runtime deprecate invalid package.json main entries
...
PR-URL: https://github.com/nodejs/node/pull/37204
Fixes: https://github.com/nodejs/node/issues/26588
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2021-02-24 11:27:48 +01:00
Rich Trott
b461a1b125
doc,lib: prepare for stricter multi-line array linting
...
We're about to turn on a requirement for dangling commas.
PR-URL: https://github.com/nodejs/node/pull/37088
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-02-19 09:55:35 -08:00
Antoine du Hamel
bb2d85f23e
module: improve support of data: URLs
...
Add support for loading modules using percent-encoded URLs.
PR-URL: https://github.com/nodejs/node/pull/37392
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com >
2021-02-18 20:10:49 +01:00
Antoine du Hamel
674614b3f5
module: remove module.createRequireFromPath
...
PR-URL: https://github.com/nodejs/node/pull/37201
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-02-15 07:03:08 -08:00
zhangyongsheng
aecd5ebf49
module: only set cache when finding module succeeds
...
PR-URL: https://github.com/nodejs/node/pull/36642
Fixes: https://github.com/nodejs/node/issues/36638
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-02-12 22:08:40 +08:00
Darshan Sen
fdd7a87b8a
module: use optional chaining in cjs/loader.js
...
PR-URL: https://github.com/nodejs/node/pull/37238
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-02-08 16:39:55 -08:00
ExE Boss and Antoine du Hamel
3aba6fef07
repl: add auto‑completion for dynamic import calls
...
Refs: https://github.com/nodejs/node/issues/33238
Refs: https://github.com/nodejs/node/pull/33282
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/37178
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-02-06 05:12:59 -08:00
Gus Caplan
bf2f2b74fa
vm: add importModuleDynamically option to compileFunction
...
This reverts commit 2d5d77306f .
See: https://github.com/nodejs/node/pull/32985
See: https://github.com/nodejs/node/pull/33364
See: https://github.com/nodejs/node/issues/33166
Fixes: https://github.com/nodejs/node/issues/31860
PR-URL: https://github.com/nodejs/node/pull/35431
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org >
2021-02-05 09:16:33 -06:00
cjihrig
d0a92e2c32
esm: update to correct deprecation code
...
https://github.com/nodejs/node/pull/36918 landed with references
to DEP0150, which is already used for a different deprecation.
This commit updates the code to use DEP0151.
PR-URL: https://github.com/nodejs/node/pull/37147
Refs: https://github.com/nodejs/node/pull/36918
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-30 11:37:22 -05:00
Guy Bedford
255d6337cd
esm: deprecate legacy main lookup for modules
...
PR-URL: https://github.com/nodejs/node/pull/36918
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-01-30 16:31:49 +02:00
Antoine du Hamel
88153dc175
module: simplify tryStatSync with throwIfNoEntry option
...
PR-URL: https://github.com/nodejs/node/pull/36971
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-18 11:04:14 -08:00
Antoine du Hamel
983e9222ca
lib: expose primordials object
...
Expose the internal `primordials` object to help with Node.js core
development.
```console
$ node --expose-internals -r internal/test/binding lib/fs.js
(node:5299) internal/test/binding: These APIs are for internal testing
only. Do not use them.
(Use `node --trace-warnings ...` to show where the warning was created)
```
PR-URL: https://github.com/nodejs/node/pull/36872
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-18 11:43:32 +01:00
Guy Bedford
2e909c4fcc
module: fix Windows folder exports deprecation warning
...
PR-URL: https://github.com/nodejs/node/pull/36859
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2021-01-12 14:45:51 +01:00
Antoine du Hamel
5f2bb885f8
module: refactor to avoid unsafe array iteration
...
PR-URL: https://github.com/nodejs/node/pull/36680
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-01-06 11:30:18 +01:00
Antoine du Hamel
0b6d3070a1
lib: add primordials.SafeArrayIterator
...
PR-URL: https://github.com/nodejs/node/pull/36532
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-28 00:08:44 +01:00
Antoine du Hamel
3604fadacf
module: refactor to use more primordials
...
PR-URL: https://github.com/nodejs/node/pull/36348
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-04 06:19:12 -08:00
James M Snell
8ff2501a04
module: add isPreloading indicator
...
Adds a `module.isPreloading` property that is `true` only during the
preload (`-r`) phase of Node.js bootstrap. This provides modules an
easy, non-hacky way of knowing if they are being loaded during preload.
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/36263
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-11-30 08:26:46 -08:00
Antoine du Hamel
829786088a
esm: refactor to use more primordials
...
PR-URL: https://github.com/nodejs/node/pull/36019
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-11-14 14:46:06 +00:00
Antoine du Hamel
2c77fe192e
module: refactor to use more primordials
...
PR-URL: https://github.com/nodejs/node/pull/36024
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2020-11-09 19:05:31 +00:00
Guy Bedford
a5f99b8d20
deps: upgrade to cjs-module-lexer@1.0.0
...
PR-URL: https://github.com/nodejs/node/pull/35928
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-11-02 10:24:04 -08:00
Guy Bedford
c9acb9e5b3
module: runtime deprecate subpath folder mappings
...
PR-URL: https://github.com/nodejs/node/pull/35747
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-10-30 12:12:56 -04:00
Michaël Zasso
11f1ad939f
module: only try to enrich CJS syntax errors
...
It is guaranteed that V8 throws a syntax error when `import` or `export`
is used outside of ESM.
Fixes: https://github.com/nodejs/node/issues/35687
PR-URL: https://github.com/nodejs/node/pull/35691
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2020-10-19 18:41:10 +00:00
Antoine du Hamel
aaf225a2a0
module: add setter for module.parent
...
PR-URL: https://github.com/nodejs/node/pull/35522
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-10-17 00:49:56 +02:00
Guy Bedford
ab0af50ef8
module: cjs-module-lexer@0.4.1 big endian fix
...
PR-URL: https://github.com/nodejs/node/pull/35634
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org >
2020-10-14 16:15:32 -04:00
Guy Bedford
f3ce2811dd
module: use Wasm CJS lexer when available
...
PR-URL: https://github.com/nodejs/node/pull/35583
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
2020-10-12 04:24:41 -07:00
Guy Bedford
5e605c0dd9
module: fix builtin reexport tracing
...
PR-URL: https://github.com/nodejs/node/pull/35500
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-10-04 10:30:13 -07:00
Guy Bedford
726143e683
module: refine module type mismatch error cases
...
PR-URL: https://github.com/nodejs/node/pull/35426
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2020-09-30 20:46:01 -07:00
Michaël Zasso
a8806535d9
lib: use Object static properties from primordials
...
PR-URL: https://github.com/nodejs/node/pull/35380
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Ricky Zhou <0x19951125@gmail.com >
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com >
2020-09-30 17:52:35 +02:00
Guy Bedford
ee9e3e75aa
esm: use "node:" namespace for builtins
...
PR-URL: https://github.com/nodejs/node/pull/35387
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2020-09-29 18:20:28 -07:00
Guy Bedford
1e8cb08edc
module: named exports for CJS via static analysis
...
PR-URL: https://github.com/nodejs/node/pull/35249
Reviewed-By: Mary Marchini <oss@mmarchini.me >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
2020-09-28 18:27:25 -07:00