Skip to content

Commit

Permalink
fix(ext/node): fix builtin module module (denoland#15904)
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k authored Sep 17, 2022
1 parent 5fe660e commit d7b27ed
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 22 deletions.
2 changes: 2 additions & 0 deletions cli/tests/testdata/npm/builtin_module_module/main.out
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
function
function
function
true
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ import m1 from "node:module";
import m2 from "module";

console.log(typeof m1.Module);
console.log(typeof m2.Module);
console.log(typeof m2.Module);
console.log(typeof m1);
console.log(m1 === m1.Module);
21 changes: 1 addition & 20 deletions ext/node/02_require.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,25 +828,7 @@

Module.Module = Module;

const m = {
_cache: Module._cache,
_extensions: Module._extensions,
_findPath: Module._findPath,
_initPaths: Module._initPaths,
_load: Module._load,
_nodeModulePaths: Module._nodeModulePaths,
_pathCache: Module._pathCache,
_preloadModules: Module._preloadModules,
_resolveFilename: Module._resolveFilename,
_resolveLookupPaths: Module._resolveLookupPaths,
builtinModules: Module.builtinModules,
createRequire: Module.createRequire,
globalPaths: Module.globalPaths,
Module,
wrap: Module.wrap,
};

node.nativeModuleExports.module = m;
node.nativeModuleExports.module = Module;

function loadNativeModule(_id, request) {
if (nativeModulePolyfill.has(request)) {
Expand Down Expand Up @@ -890,7 +872,6 @@
toRealPath,
cjsParseCache,
readPackageScope,
moduleExports: m,
},
};
})(globalThis);
2 changes: 1 addition & 1 deletion ext/node/module_es_shim.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const m = Deno[Deno.internal].require.moduleExports;
const m = Deno[Deno.internal].require.Module;
export const _cache = m._cache;
export const _extensions = m._extensions;
export const _findPath = m._findPath;
Expand Down

0 comments on commit d7b27ed

Please sign in to comment.