diff --git a/lib/internal/modules/esm/hooks.js b/lib/internal/modules/esm/hooks.js index 8ab54bdbde9396..76239c2e6fb104 100644 --- a/lib/internal/modules/esm/hooks.js +++ b/lib/internal/modules/esm/hooks.js @@ -1,7 +1,6 @@ 'use strict'; const { - ArrayPrototypeJoin, ArrayPrototypePush, FunctionPrototypeCall, Int32Array, @@ -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; } diff --git a/test/es-module/test-esm-loader-obsolete-hooks.mjs b/test/es-module/test-esm-loader-obsolete-hooks.mjs deleted file mode 100644 index fa0baef8a216b7..00000000000000 --- a/test/es-module/test-esm-loader-obsolete-hooks.mjs +++ /dev/null @@ -1,28 +0,0 @@ -import { spawnPromisified } from '../common/index.mjs'; -import { fileURL, path } from '../common/fixtures.mjs'; -import { match, notStrictEqual } from 'node:assert'; -import { execPath } from 'node:process'; -import { describe, it } from 'node:test'; - - -describe('ESM: deprecation warnings for obsolete hooks', { concurrency: true }, () => { - it(async () => { - const { code, stderr } = await spawnPromisified(execPath, [ - '--no-warnings', - '--throw-deprecation', - '--experimental-loader', - fileURL('es-module-loaders', 'hooks-obsolete.mjs').href, - path('print-error-message.js'), - ]); - - // DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: - // dynamicInstantiate, getFormat, getSource, transformSource - match(stderr, /DeprecationWarning:/); - match(stderr, /dynamicInstantiate/); - match(stderr, /getFormat/); - match(stderr, /getSource/); - match(stderr, /transformSource/); - - notStrictEqual(code, 0); - }); -}); diff --git a/test/fixtures/es-module-loaders/hooks-obsolete.mjs b/test/fixtures/es-module-loaders/hooks-obsolete.mjs deleted file mode 100644 index bb10ef8ef4b29a..00000000000000 --- a/test/fixtures/es-module-loaders/hooks-obsolete.mjs +++ /dev/null @@ -1,22 +0,0 @@ -export function dynamicInstantiate() {} -export function getFormat() {} -export function getSource() {} -export function transformSource() {} - - -export function resolve(specifier, context, next) { - if (specifier === 'whatever') return { - url: specifier, - }; - - return next(specifier); -} - -export function load(url, context, next) { - if (url === 'whatever') return { - format: 'module', - source: '', - }; - - return next(url); -}