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 — module: refactor to use `normalizeRequirableId` in the CJS module loader · nodejs/node@c19385c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal
    • bootstrap
      • realm.js
    • modules/cjs
      • loader.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/bootstrap/realm.js‎

Copy file name to clipboardExpand all lines: lib/internal/bootstrap/realm.js
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,16 @@ class BuiltinModule {
287287
}
288288

289289
static normalizeRequirableId(id) {
290-
let normalizedId = id;
291290
if (StringPrototypeStartsWith(id, 'node:')) {
292-
normalizedId = StringPrototypeSlice(id, 5);
293-
}
294-
295-
if (!BuiltinModule.canBeRequiredByUsers(normalizedId) ||
296-
(id === normalizedId && !BuiltinModule.canBeRequiredWithoutScheme(normalizedId))) {
297-
return undefined;
291+
const normalizedId = StringPrototypeSlice(id, 5);
292+
if (BuiltinModule.canBeRequiredByUsers(normalizedId)) {
293+
return normalizedId;
294+
}
295+
} else if (BuiltinModule.canBeRequiredWithoutScheme(id)) {
296+
return id;
298297
}
299298

300-
return normalizedId;
299+
return undefined;
301300
}
302301

303302
static isBuiltin(id) {
Collapse file

‎lib/internal/modules/cjs/loader.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js
+2-14Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -792,12 +792,7 @@ if (isWindows) {
792792
}
793793

794794
Module._resolveLookupPaths = function(request, parent) {
795-
if ((
796-
StringPrototypeStartsWith(request, 'node:') &&
797-
BuiltinModule.canBeRequiredByUsers(StringPrototypeSlice(request, 5))
798-
) || (
799-
BuiltinModule.canBeRequiredWithoutScheme(request)
800-
)) {
795+
if (BuiltinModule.normalizeRequirableId(request)) {
801796
debug('looking for %j in []', request);
802797
return null;
803798
}
@@ -989,14 +984,7 @@ Module._load = function(request, parent, isMain) {
989984
};
990985

991986
Module._resolveFilename = function(request, parent, isMain, options) {
992-
if (
993-
(
994-
StringPrototypeStartsWith(request, 'node:') &&
995-
BuiltinModule.canBeRequiredByUsers(StringPrototypeSlice(request, 5))
996-
) || (
997-
BuiltinModule.canBeRequiredWithoutScheme(request)
998-
)
999-
) {
987+
if (BuiltinModule.normalizeRequirableId(request)) {
1000988
return request;
1001989
}
1002990

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.