mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
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>
21 lines
456 B
JavaScript
21 lines
456 B
JavaScript
export async function resolve(specifier, { parentURL, importAttributes }, next) {
|
|
if (parentURL && specifier === '../fixtures/es-modules/test-esm-ok.mjs') {
|
|
return {
|
|
shortCircuit: true,
|
|
url: 'file:///asdf',
|
|
};
|
|
}
|
|
return next(specifier);
|
|
}
|
|
|
|
export async function load(url, context, next) {
|
|
if (url === 'file:///asdf') {
|
|
return {
|
|
format: 'esm',
|
|
shortCircuit: true,
|
|
source: '',
|
|
}
|
|
}
|
|
return next(url);
|
|
}
|