GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — esm: fix `globalPreload` warning · nodejs/node@31442b9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/modules/esm
    • hooks.js
  • test/es-module
    • test-esm-loader-hooks.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/modules/esm/hooks.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/esm/hooks.js
+3-7Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ let importMetaInitializer;
8686

8787
// [2] `validate...()`s throw the wrong error
8888

89-
let globalPreloadWarned = false;
9089
class Hooks {
9190
#chains = {
9291
/**
@@ -162,12 +161,9 @@ class Hooks {
162161
} = pluckHooks(exports);
163162

164163
if (globalPreload && !initialize) {
165-
if (globalPreloadWarned === false) {
166-
globalPreloadWarned = true;
167-
emitExperimentalWarning(
168-
'`globalPreload` will be removed in a future version. Please use `initialize` instead.',
169-
);
170-
}
164+
emitExperimentalWarning(
165+
'`globalPreload` is planned for removal in favor of `initialize`. `globalPreload`',
166+
);
171167
ArrayPrototypePush(this.#chains.globalPreload, { __proto__: null, fn: globalPreload, url });
172168
}
173169
if (resolve) {
Collapse file

‎test/es-module/test-esm-loader-hooks.mjs‎

Copy file name to clipboardExpand all lines: test/es-module/test-esm-loader-hooks.mjs
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,22 @@ describe('Loader hooks', { concurrency: true }, () => {
424424
const { stderr } = await spawnPromisified(execPath, [
425425
'--experimental-loader',
426426
'data:text/javascript,export function globalPreload(){}',
427+
'--experimental-loader',
428+
'data:text/javascript,export function globalPreload(){return""}',
429+
fixtures.path('empty.js'),
430+
]);
431+
432+
assert.strictEqual(stderr.match(/`globalPreload` is an experimental feature/g).length, 1);
433+
});
434+
435+
it('should not emit deprecation warning when initialize is supplied', async () => {
436+
const { stderr } = await spawnPromisified(execPath, [
437+
'--experimental-loader',
438+
'data:text/javascript,export function globalPreload(){}export function initialize(){}',
427439
fixtures.path('empty.js'),
428440
]);
429441

430-
assert.match(stderr, /`globalPreload` will be removed/);
442+
assert.doesNotMatch(stderr, /`globalPreload` is an experimental feature/);
431443
});
432444

433445
it('should handle globalPreload returning undefined', async () => {

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.