Skip to content

Commit f724722

Browse files
paisanousahansl
authored andcommitted
fix(@angular/cli): exclude nodejs built-ins from process.cwd() resolve
1 parent 5a736bd commit f724722

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

lib/bootstrap-local.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const fs = require('fs');
55
const path = require('path');
66
const ts = require('typescript');
7+
const builtinModules = require('builtin-modules');
78

89

910
Error.stackTraceLimit = Infinity;
@@ -79,12 +80,14 @@ if (!__dirname.match(new RegExp(`\\${path.sep}node_modules\\${path.sep}`))) {
7980
const p = path.join(packages[match].root, request.substr(match.length));
8081
return oldLoad.call(this, p, parent);
8182
} else {
82-
try {
83-
if (isAngularProject) {
84-
return oldLoad.call(this, resolve.sync(request, { basedir: process.cwd() }), parent);
83+
if (!(builtinModules.indexOf(request) > -1)) {
84+
try {
85+
if (isAngularProject) {
86+
return oldLoad.call(this, resolve.sync(request, { basedir: process.cwd() }), parent);
87+
}
88+
} catch (e) {
89+
// Do nothing. Fallback to the old method.
8590
}
86-
} catch (e) {
87-
// Do nothing. Fallback to the old method.
8891
}
8992

9093
return oldLoad.apply(this, arguments);

package-lock.json

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
"@types/source-map": "0.5.2",
126126
"@types/webpack": "^3.0.5",
127127
"@types/webpack-sources": "^0.1.3",
128+
"builtin-modules": "2.0.0",
128129
"conventional-changelog": "1.1.0",
129130
"dtsgenerator": "^0.9.1",
130131
"eslint": "^3.11.0",

0 commit comments

Comments
 (0)