Antoine du Hamel
d1ef6aa2db
esm: use import attributes instead of import assertions
...
The old import assertions proposal has been
renamed to "import attributes" with the follwing major changes:
1. The keyword is now `with` instead of `assert`.
2. Unknown assertions cause an error rather than being ignored,
This commit updates the documentation to encourage folks to use the new
syntax, and add aliases for module customization hooks.
PR-URL: https://github.com/nodejs/node/pull/50140
Fixes: https://github.com/nodejs/node/issues/50134
Refs: https://github.com/v8/v8/commit/159c82c5e6392e78b9bba7161b1bed6e23758984
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2023-10-14 03:52:38 +00:00
Antoine du Hamel
053511f7ec
module: ensure successful import returns the same result
...
PR-URL: https://github.com/nodejs/node/pull/46662
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
2023-07-26 20:34:20 +00:00
Jordan Harband
757c104147
tools: add prefer-proto rule
...
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 >
2023-01-10 05:38:36 +00:00
Joyee Cheung
265ea1e74e
bootstrap: lazy load non-essential modules
...
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 >
2022-12-09 22:37:35 +00:00
Geoffrey Booth
6dfbf04474
module: import assertions improvements
...
PR-URL: https://github.com/nodejs/node/pull/40785
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-11-24 15:50:05 +00:00
Antoine du Hamel and Geoffrey Booth
2cc7a91a5d
esm: add support for JSON import assertion
...
Remove V8 flag for import assertions, enabling support for the syntax;
require the import assertion syntax for imports of JSON.
Support import assertions in user loaders.
Use both resolved module URL and import assertion type as the key for
caching modules.
Co-authored-by: Geoffrey Booth <webadmin@geoffreybooth.com >
PR-URL: https://github.com/nodejs/node/pull/40250
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
2021-11-03 20:06:55 -07: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
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
Michaël Zasso
0646eda4fc
lib: flatten access to primordials
...
Store all primordials as properties of the primordials object.
Static functions are prefixed by the constructor's name and prototype
methods are prefixed by the constructor's name followed by "Prototype".
For example: primordials.Object.keys becomes primordials.ObjectKeys.
PR-URL: https://github.com/nodejs/node/pull/30610
Refs: https://github.com/nodejs/node/issues/29766
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2019-11-25 10:28:15 +01:00
Bradley Farias
a6b030d5ac
module: refactor modules bootstrap
...
PR-URL: https://github.com/nodejs/node/pull/29937
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2019-10-16 21:50:05 -04:00
dnlup
25b78c0940
module: remove usage of require('util')
...
Use `require('internal/util/debuglog').debuglog` instead of
`require('util').debuglog` in `lib/internal/modules/esm/module_map.js`.
Refs: https://github.com/nodejs/node/issues/26546
PR-URL: https://github.com/nodejs/node/pull/26805
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
2019-03-24 21:45:39 +08:00
Joyee Cheung
39d922123c
lib: save primordials during bootstrap and use it in builtins
...
This patches changes the `safe_globals` internal module into a
script that gets run during bootstrap and saves JavaScript builtins
(primordials) into an object that is available for all other builtin
modules to access lexically later.
PR-URL: https://github.com/nodejs/node/pull/25816
Refs: https://github.com/nodejs/node/issues/18795
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Gus Caplan <me@gus.host >
2019-02-02 05:40:47 +08:00
ZYSzys
d695a019ae
module: use validateString in modules/esm
...
PR-URL: https://github.com/nodejs/node/pull/24868
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2018-12-10 09:48:49 -08:00
Daniel Bevenius
f2b10799ef
lib: rename js source to lower snake_case
...
This commit renames all JavaScript source files in lib to lower
snake_case.
PR-URL: https://github.com/nodejs/node/pull/19556
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
2018-03-28 08:09:16 +02:00