mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-25 14:57:38 +00:00
ensure full Node path checking with @node/x requires
This commit is contained in:
parent
b12938b5aa
commit
9fd707a9a0
17
lib/core.js
17
lib/core.js
@ -89,22 +89,17 @@ if (typeof require != 'undefined' && typeof process != 'undefined' && !process.b
|
||||
a URL.
|
||||
*/
|
||||
|
||||
var parentModuleContext;
|
||||
function getNodeModule(name) {
|
||||
if (!isPlain(name))
|
||||
throw new Error('Node module ' + name + ' can\'t be loaded as it is not a package require.');
|
||||
|
||||
var nodePath = this._nodeRequire('path');
|
||||
// try to load from node_modules
|
||||
var module;
|
||||
try {
|
||||
module = this._nodeRequire(nodePath.resolve(process.cwd(), 'node_modules', name));
|
||||
if (!parentModuleContext) {
|
||||
var Module = this._nodeRequire('module');
|
||||
parentModuleContext = new Module(process.cwd());
|
||||
parentModuleContext.paths = Module._nodeModulePaths(process.cwd());
|
||||
}
|
||||
catch(e) {
|
||||
// fall back to direct require (in theory this is core modules only, which should really be filtered)
|
||||
if (e.code == 'MODULE_NOT_FOUND')
|
||||
module = this._nodeRequire(name);
|
||||
}
|
||||
return module;
|
||||
return parentModuleContext.require(name);
|
||||
}
|
||||
|
||||
function coreResolve(name, parentName) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user