[node] Fix CommonJS import of module (#41225)

This commit is contained in:
Andrew Branch
2019-12-30 11:26:41 -06:00
committed by GitHub
parent 8b6f65181d
commit c08d2b5e4a
2 changed files with 3 additions and 1 deletions

View File

@@ -16,4 +16,5 @@ declare module "module" {
constructor(id: string, parent?: Module);
}
export = Module;
}

View File

@@ -1,4 +1,4 @@
import { Module } from 'module';
import Module = require('module');
import { URL } from 'url';
require.extensions[".ts"] = () => "";
@@ -10,6 +10,7 @@ const m2: Module = new Module("moduleId");
const b: string[] = Module.builtinModules;
let paths: string[] = [];
paths = m1.paths;
m1 instanceof Module;
Module.createRequireFromPath('./test')('test');