summaryrefslogtreecommitdiff
path: root/lib/internal/modules/esm
Commit message (Collapse)AuthorAgeFilesLines
* esm: do not use `'beforeExit'` on the main threadAntoine du Hamel2023-05-141-17/+4
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/47964 Fixes: https://github.com/nodejs/node/issues/47929 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
* src: throw DataCloneError on transfering untransferable objectsChengzhong Wu2023-05-051-4/+12
| | | | | | | | | | | | The HTML StructuredSerializeWithTransfer algorithm defines that when an untransferable object is in the transfer list, a DataCloneError is thrown. An array buffer that is already transferred is also considered as untransferable. PR-URL: https://github.com/nodejs/node/pull/47604 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
* tools: fix jsdoc lintMoshe Atlow2023-05-023-8/+0
| | | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/47789 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Mestery <mestery@protonmail.com>
* esm: rename `URLCanParse` to be consistentAntoine du Hamel2023-04-242-5/+5
| | | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/47668 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* lib: improve esm resolve performanceYagiz Nizipli2023-04-231-22/+16
| | | | | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/46652 Refs: https://github.com/nodejs/performance/issues/39 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Erick Wendel <erick.workspace@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
* loader: use default loader as cascaded loader in the in loader workerJoyee Cheung2023-04-214-5/+18
| | | | | | | | | | | | Use the default loader as the cascaded loader in the loader worker. Otherwise we spawn loader workers in the loader workers indefinitely. PR-URL: https://github.com/nodejs/node/pull/47620 Fixes: https://github.com/nodejs/node/issues/47566 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
* esm: remove support for deprecated hooksAntoine du Hamel2023-04-191-37/+0
| | | | | | | | | | | Those have been deprecated for a while, it's time. PR-URL: https://github.com/nodejs/node/pull/47580 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* esm: initialize `import.meta` on evalAntoine du Hamel2023-04-191-0/+1
| | | | | | PR-URL: https://github.com/nodejs/node/pull/47551 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me>
* esm: propagate `process.exit` from the loader thread to the main threadAntoine du Hamel2023-04-192-0/+17
| | | | | PR-URL: https://github.com/nodejs/node/pull/47548 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me>
* esm: avoid accessing lazy getters for urlsYagiz Nizipli2023-04-151-15/+25
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/47542 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
* esm: avoid try/catch when validating urlsYagiz Nizipli2023-04-152-16/+12
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/47541 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
* esm: move hook execution to separate threadJacob Smith2023-04-138-213/+733
| | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/44710 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> Co-authored-by: Geoffrey Booth <webadmin@geoffreybooth.com> Co-authored-by: Michaël Zasso <targos@protonmail.com>
* module: do less CJS module loader initialization at run timeJoyee Cheung2023-04-052-6/+3
| | | | | | | | | | | | | | | | | | This patch: - Builds the set of modules that can be required by users with/without the `node:` prefix at snapshot building time. We only modify it when `--expose-internals` but the default set is now in the snapshot. At run time the CJS module loader only creates a frozen array out of it. - `BuiltinModule.canBeRequiredWithoutScheme()` is now enough to determine if an id can be required without `node:` without an additional call to `BuiltinModule.canBeRequiredByUsers()` - Replace the pending-to-deprecate methods on `Module` with an internal implementation that only queries the CLI flags when being invoked. So we can install these methods in the snapshot. PR-URL: https://github.com/nodejs/node/pull/47194 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
* src: bootstrap prepare stack trace callback in shadow realmChengzhong Wu2023-04-042-2/+2
| | | | | | | | | | | Bootstrap per-realm callbacks like `prepare_stack_trace_callback` in the ShadowRealm. This enables stack trace decoration in the ShadowRealm. PR-URL: https://github.com/nodejs/node/pull/47107 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* esm: skip file: URL conversion to path when possibleAntoine du Hamel2023-04-012-8/+31
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/46305 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: James M Snell <jasnell@gmail.com>
* esm: fix import assertion warningAntoine du Hamel2023-03-071-2/+2
| | | | | | | | | Refs: https://github.com/nodejs/node/pull/46901#discussion_r1122242913 PR-URL: https://github.com/nodejs/node/pull/46971 Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
* lib: enforce use of trailing commasAntoine du Hamel2023-03-065-7/+7
| | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/46881 Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me>
* url: use private properties for brand checkYagiz Nizipli2023-03-031-2/+2
| | | | | | PR-URL: https://github.com/nodejs/node/pull/46904 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
* esm: add a runtime warning when using import assertionsAntoine du Hamel2023-03-031-0/+13
| | | | | | | | PR-URL: https://github.com/nodejs/node/pull/46901 Refs: https://github.com/nodejs/node/issues/46830 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me>
* lib: enforce use of trailing commas for functionsAntoine du Hamel2023-02-1410-33/+33
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/46629 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
* esm: mark `importAssertions` as requiredAntoine du Hamel2023-01-121-6/+2
| | | | | | | | We already always specify a value, and failing to do so would likely be a bug. PR-URL: https://github.com/nodejs/node/pull/46164 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
* esm: allow resolve to return import assertionsGeoffrey Booth2023-01-122-19/+38
| | | | | | PR-URL: https://github.com/nodejs/node/pull/46153 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jacob Smith <jacob@frende.me>
* tools: add `prefer-proto` ruleJordan Harband2023-01-105-11/+6
| | | | | | | | | | | | | | | | fixup: add support for `Object.create(null)` fixup: extend to any 1-argument Object.create call fixup: add tests PR-URL: https://github.com/nodejs/node/pull/46083 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
* esm: move hooks handling into separate classGeoffrey Booth2022-12-203-596/+737
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/45869 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* tools: add `ArrayPrototypeConcat` to the list of primordials to avoidAntoine du Hamel2022-12-171-6/+6
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/44445 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
* esm: leverage loaders when resolving subsequent loadersMaël Nison2022-12-171-3/+1
| | | | | | PR-URL: https://github.com/nodejs/node/pull/43772 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
* modules: move callbacks and conditions into modules/esm/utils.jsJoyee Cheung2022-12-165-39/+119
| | | | | | | | | | | | | | | | | This moves the following utils into modules/esm/utils.js: - Code related to default conditions - The callbackMap (which is now created in the module instead of hanging off the module_wrap binding, since the C++ land does not need it). - Per-isolate module callbacks These are self-contained code that can be included into the built-in snapshot. PR-URL: https://github.com/nodejs/node/pull/45849 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
* modules: move modules/cjs/helpers.js to modules/helpers.jsJoyee Cheung2022-12-161-1/+1
| | | | | | | | | The helpers are actually shared by the two loaders, so move them under modules/ directly. PR-URL: https://github.com/nodejs/node/pull/45849 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
* bootstrap: lazy load non-essential modulesJoyee Cheung2022-12-096-23/+27
| | | | | | | | | | | | | | | | | | | | | It turns out that even with startup snapshots, there is a non-trivial overhead for loading internal modules. This patch makes the loading of the non-essential modules lazy again. Caveat: we have to make some of the globals lazily-loaded too, so the WPT runner is updated to test what the state of the global scope is after the globals are accessed (and replaced with the loaded value). PR-URL: https://github.com/nodejs/node/pull/45659 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Tierney Cyren <hello@bnb.im>
* watch: watch for missing dependenciesMoshe Atlow2022-11-132-1/+4
| | | | | | PR-URL: https://github.com/nodejs/node/pull/45348 Reviewed-By: Ruy Adorno <ruyadorno@google.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
* esm: add JSDoc property descriptions for loaderRich Trott2022-11-121-7/+7
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/45370 Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jacob Smith <jacob@frende.me>
* esm: add JSDoc property descriptions for fetchRich Trott2022-11-121-3/+3
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/45370 Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jacob Smith <jacob@frende.me>
* lib: fix JSDoc issuesRich Trott2022-11-072-17/+43
| | | | | | | | | | | | | | | | | | | | | | | | Updating ESLint and dependencies will start flagging a few additional JSDoc issues. One or two of these are simple fixes. The ESM stuff requires throwing explicitly in JSDoc'ed functions rather than calling another function to throw. I think this makes the code easier to understand--you don't need to know that a particular function that starts with `throwsIf` *might* throw but something that starts with `throwsAnythingElse` will always throw. Instead, it's right there in the code. This also might make it easier to improve stack traces if that's something we'd like to do at some point. PR-URL: https://github.com/nodejs/node/pull/45243 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
* esm: protect ESM loader from prototype pollutionAntoine du Hamel2022-10-272-6/+7
| | | | | | | | | | | | | In a previous commit, the loader implementation was modified to be protected against most prototype pollution, but was kept vulnerable to `Array.prototype` pollution. This commit fixes that, the tradeoff is that it modifies the `ESMLoader.prototype.import` return type from an `Array` to an array-like object. Refs: https://github.com/nodejs/node/pull/45044 PR-URL: https://github.com/nodejs/node/pull/45175 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
* lib: add lint rule to protect against `Object.prototype.then` pollutionAntoine du Hamel2022-10-212-2/+4
| | | | | | | | PR-URL: https://github.com/nodejs/node/pull/45061 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
* esm: protect ESM loader from prototype pollutionAntoine du Hamel2022-10-194-3/+6
| | | | | | | | | Fixes: https://github.com/nodejs/node/issues/45035 PR-URL: https://github.com/nodejs/node/pull/45044 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* module: fix segment deprecation for imports fieldGuy Bedford2022-10-131-6/+6
| | | | | | | | PR-URL: https://github.com/nodejs/node/pull/44883 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
* src: consolidate exit codes in the code baseJoyee Cheung2022-10-061-1/+3
| | | | | | | | | | | | | | | | Add an ExitCode enum class and use it throughout the code base instead of hard-coding the exit codes everywhere. At the moment, the exit codes used in many places do not actually conform to what the documentation describes. With the new enums (which are also available to the JS land as constants in an internal binding) we could migrate to a more consistent usage of the codes, and eventually expose the constants to the user land when they are stable enough. PR-URL: https://github.com/nodejs/node/pull/44746 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
* esm: remove specifier resolution flagGeoffrey Booth2022-10-044-116/+17
| | | | | | | | PR-URL: https://github.com/nodejs/node/pull/44859 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
* esm,loader: tidy ESMLoader internalsJacob Smith2022-09-192-73/+71
| | | | | PR-URL: https://github.com/nodejs/node/pull/44701 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
* module: runtime deprecate exports double slash mapsGuy Bedford2022-09-111-2/+0
| | | | | PR-URL: https://github.com/nodejs/node/pull/44495 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* module: exports & imports map invalid slash deprecationGuy Bedford2022-09-111-24/+74
| | | | | PR-URL: https://github.com/nodejs/node/pull/44477 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me>
* cli: add `--watch`Moshe Atlow2022-09-051-0/+4
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/44366 Fixes: https://github.com/nodejs/node/issues/40429 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
* lib: use safe `Promise` alternatives when availableAntoine du Hamel2022-08-271-3/+2
| | | | | PR-URL: https://github.com/nodejs/node/pull/43476 Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
* src: disambiguate terms used to refer to builtins and addonsJoyee Cheung2022-08-093-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The term "native module" dates back to some of the oldest code in the code base. Within the context of Node.js core it usually refers to modules that are native to Node.js (e.g. fs, http), but it can cause confusion for people who don't work on this part of the code base, as "native module" can also refer to native addons - which is even the case in some of the API docs and error messages. This patch tries to make the usage of these terms more consistent. Now within the context of Node.js core: - JavaScript scripts that are built-in to Node.js are now referred to as "built-in(s)". If they are available as modules, they can also be referred to as "built-in module(s)". - Dynamically-linked shared objects that are loaded into the Node.js processes are referred to as "addons". We will try to avoid using the term "native modules" because it could be ambiguous. Changes in this patch: File names: - node_native_module.h -> node_builtins.h, - node_native_module.cc -> node_builtins.cc C++ binding names: - `native_module` -> `builtins` `node::Environment`: - `native_modules_without_cache` -> `builtins_without_cache` - `native_modules_with_cache` -> `builtins_with_cache` - `native_modules_in_snapshot` -> `builtins_in_cache` - `native_module_require` -> `builtin_module_require` `node::EnvSerializeInfo`: - `native_modules` -> `builtins `node::native_module::NativeModuleLoader`: - `native_module` namespace -> `builtins` namespace - `NativeModuleLoader` -> `BuiltinLoader` - `NativeModuleRecordMap` -> `BuiltinSourceMap` - `NativeModuleCacheMap` -> `BuiltinCodeCacheMap` - `ModuleIds` -> `BuiltinIds` - `ModuleCategories` -> `BuiltinCategories` - `LoadBuiltinModuleSource` -> `LoadBuiltinSource` `loader.js`: - `NativeModule` -> `BuiltinModule` (the `NativeModule` name used in `process.moduleLoadList` is kept for compatibility) And other clarifications in the documentation and comments. PR-URL: https://github.com/nodejs/node/pull/44135 Fixes: https://github.com/nodejs/node/issues/44036 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Jan Krems <jan.krems@gmail.com>
* esm: do not bind loader hook functionsAntoine du Hamel2022-08-081-11/+6
| | | | | PR-URL: https://github.com/nodejs/node/pull/44122 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
* lib: reset `RegExp` statics before running user codeAntoine du Hamel2022-08-051-4/+3
| | | | | | | | Fixes: https://github.com/nodejs/node/issues/43740 PR-URL: https://github.com/nodejs/node/pull/43741 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* module: protect against prototype mutationAntoine du Hamel2022-08-041-2/+4
| | | | | | | Ensures that mutating the `Object` prototype does not influence the parsing of `package.json` files. PR-URL: https://github.com/nodejs/node/pull/44007 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
* esm: fix loader hooks accepting too many argumentsJacob Smith2022-08-041-15/+7
| | | | | | PR-URL: https://github.com/nodejs/node/pull/44109 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
* test: refactor ESM tests to improve performanceJacob Smith2022-07-291-1/+1
| | | | | PR-URL: https://github.com/nodejs/node/pull/43784 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>