Commit Graph

8 Commits

Author SHA1 Message Date
Bruce MacNaughton
ab857e138f
esm: fix hook name in error message
PR-URL: https://github.com/nodejs/node/pull/50466
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>
2023-12-05 19:54:01 +01:00
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: 159c82c5e6
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
Geoffrey Booth
9e840deecc
esm: misc test refactors
- add test specific to the event loop
- move parallel tests into es-module folder
- refactor fixture to add braces for if blocks
- use 'os' instead of 'fs' as placeholder
- spelling

PR-URL: https://github.com/nodejs/node/pull/46631
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2023-02-18 14:26:36 +00:00
Jacob Smith
447635b440
test: refactor ESM tests to improve performance
PR-URL: https://github.com/nodejs/node/pull/43784
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-07-29 10:42:55 +02:00
Jacob Smith
d859e9e997
esm: add chaining to loaders
PR-URL: https://github.com/nodejs/node/pull/42623
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-05-04 16:51:12 +01:00
Jacob Smith
dbc6e39ca7
esm: improve validation of resolved URLs
PR-URL: https://github.com/nodejs/node/pull/41446
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
2022-01-19 05:28:32 +00:00
Antoine du Hamel
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
Jacob
df22736d80 esm: consolidate ESM loader hooks
doc: update ESM hook examples

esm: fix unsafe primordial

doc: fix ESM example linting

esm: allow source of type ArrayBuffer

doc: update ESM hook changelog to include resolve format

esm: allow all ArrayBuffers and TypedArrays for load hook source

doc: tidy code & API docs

doc: convert ESM source table header from Title Case to Sentence case

doc: add detailed explanation for getPackageType

esm: add caveat that ESMLoader::import() must NOT be renamed

esm: tidy code declaration of getFormat protocolHandlers

doc: correct ESM doc link (bad conflict resolution)

doc: update ESM hook limitation for CJS

esm: tweak preload description

doc: update ESM getPackageType() example explanation

PR-URL: https://github.com/nodejs/node/pull/37468
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
2021-09-11 18:08:35 -07:00