Update Dec 19, 2024 tracked by Updatify
2024-12-19, Version 23.5.0 (Current), @aduh95
Notable Changes
WebCryptoAPI Ed25519 and X25519 algorithms are now stable
Following the merge of Curve25519 into the
Web Cryptography API Editor’s Draft the
Ed25519 and X25519 algorithm identifiers are now stable and will no longer
emit an ExperimentalWarning upon use.
Contributed by Filip Skokan in #56142.
On-thread hooks are back
This release introduces module.registerHooks() for registering module loader
customization hooks that are run for all modules loaded by require(), import
and functions returned by createRequire() in the same thread, which makes them
easier for CJS monkey-patchers to migrate to.
import assert from 'node:assert';
import { registerHooks, createRequire } from 'node:module';
import { writeFileSync } from 'node:fs';
writeFileSync('./bar.js', 'export const id = 123;', 'utf8');
registerHooks({
resolve(specifier, context, nextResolve) {
const replaced = specifier.replace('foo', 'bar');
return nextResolve(replaced, context);
},
load(url, context, nextLoad) {
const result = nextLoad(url, context);
return {
...result,
source: result.source.toString().replace('123', '456'),
};
},
});
// Checks that it works with require.
const require = createRequire(import.meta.url);
const required = require('./foo.js'); // Redirected by resolve hook to bar.js