Skip to content

Commit d2b8035

Browse files
committed
module: convert schema-only core module on convertCJSFilenameToURL
1 parent 68bac3d commit d2b8035

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/internal/modules/customization_hooks.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ function convertCJSFilenameToURL(filename) {
130130
if (builtinId) {
131131
return `node:${builtinId}`;
132132
}
133+
if (BuiltinModule.canBeRequiredByUsers(filename) && !filename.startsWith('node:')) {
134+
return `node:${filename}`;
135+
}
133136
// Handle the case where filename is neither a path, nor a built-in id,
134137
// which is possible via monkey-patching.
135138
if (isAbsolute(filename)) {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const { registerHooks } = require('module');
5+
6+
const schemelessBlockList = new Set([
7+
'sea',
8+
'sqlite',
9+
'test',
10+
'test/reporters',
11+
]);
12+
13+
const testModules = [];
14+
for (const mod of schemelessBlockList) {
15+
testModules.push(`node:${mod}`);
16+
}
17+
18+
const hook = registerHooks({
19+
resolve: common.mustCall((specifier, context, nextResolve) => nextResolve(specifier, context), testModules.length),
20+
load: common.mustCall((url, context, nextLoad) => nextLoad(url, context), testModules.length),
21+
});
22+
23+
for (const mod of testModules) {
24+
require(mod);
25+
}
26+
27+
hook.deregister();

0 commit comments

Comments
 (0)