Skip to content

Commit

Permalink
esm: remove support for deprecated hooks
Browse files Browse the repository at this point in the history
Those have been deprecated for a while, it's time.

PR-URL: nodejs#47580
Reviewed-By: Jacob Smith <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
aduh95 authored and targos committed Nov 10, 2023
1 parent 40fa6e4 commit d8687c4
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 87 deletions.
37 changes: 0 additions & 37 deletions lib/internal/modules/esm/hooks.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const {
ArrayPrototypeJoin,
ArrayPrototypePush,
FunctionPrototypeCall,
Int32Array,
Expand Down Expand Up @@ -658,45 +657,9 @@ function pluckHooks({
globalPreload,
resolve,
load,
// obsolete hooks:
dynamicInstantiate,
getFormat,
getGlobalPreloadCode,
getSource,
transformSource,
}) {
const obsoleteHooks = [];
const acceptedHooks = { __proto__: null };

if (getGlobalPreloadCode) {
globalPreload ??= getGlobalPreloadCode;

process.emitWarning(
'Loader hook "getGlobalPreloadCode" has been renamed to "globalPreload"',
);
}
if (dynamicInstantiate) {
ArrayPrototypePush(obsoleteHooks, 'dynamicInstantiate');
}
if (getFormat) {
ArrayPrototypePush(obsoleteHooks, 'getFormat');
}
if (getSource) {
ArrayPrototypePush(obsoleteHooks, 'getSource');
}
if (transformSource) {
ArrayPrototypePush(obsoleteHooks, 'transformSource');
}

if (obsoleteHooks.length) {
process.emitWarning(
`Obsolete loader hook(s) supplied and will be ignored: ${
ArrayPrototypeJoin(obsoleteHooks, ', ')
}`,
'DeprecationWarning',
);
}

if (globalPreload) {
acceptedHooks.globalPreload = globalPreload;
}
Expand Down
28 changes: 0 additions & 28 deletions test/es-module/test-esm-loader-obsolete-hooks.mjs

This file was deleted.

22 changes: 0 additions & 22 deletions test/fixtures/es-module-loaders/hooks-obsolete.mjs

This file was deleted.

0 comments on commit d8687c4

Please sign in to comment.