Skip to content

Commit d98785b

Browse files
committed
adopt loader #35e8bf0
1 parent fff2411 commit d98785b

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

src/vs/loader.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ var AMDLoader;
294294
function Configuration(options) {
295295
this.options = ConfigurationOptionsUtil.mergeConfigurationOptions(options);
296296
this._createIgnoreDuplicateModulesMap();
297+
this._createNodeModulesMap();
297298
this._createSortedPathsRules();
298299
if (this.options.baseUrl === '') {
299300
if (AMDLoader.isNode && this.options.nodeRequire && this.options.nodeRequire.main && this.options.nodeRequire.main.filename) {
@@ -315,6 +316,14 @@ var AMDLoader;
315316
this.ignoreDuplicateModulesMap[this.options.ignoreDuplicateModules[i]] = true;
316317
}
317318
};
319+
Configuration.prototype._createNodeModulesMap = function () {
320+
// Build a map out of nodeModules array
321+
this.nodeModulesMap = Object.create(null);
322+
for (var _i = 0, _a = this.options.nodeModules; _i < _a.length; _i++) {
323+
var nodeModule = _a[_i];
324+
this.nodeModulesMap[nodeModule] = true;
325+
}
326+
};
318327
Configuration.prototype._createSortedPathsRules = function () {
319328
var _this = this;
320329
// Create an array our of the paths rules, sorted descending by length to
@@ -392,9 +401,16 @@ var AMDLoader;
392401
* Transform a module id to a location. Appends .js to module ids
393402
*/
394403
Configuration.prototype.moduleIdToPaths = function (moduleId) {
395-
if (this.isBuild() && this.options.nodeModules.indexOf(moduleId) >= 0) {
396-
// This is a node module and we are at build time, drop it
397-
return ['empty:'];
404+
if (this.nodeModulesMap[moduleId] === true) {
405+
// This is a node module...
406+
if (this.isBuild()) {
407+
// ...and we are at build time, drop it
408+
return ['empty:'];
409+
}
410+
else {
411+
// ...and at runtime we create a `shortcut`-path
412+
return ['node|' + moduleId];
413+
}
398414
}
399415
var result = moduleId;
400416
var results;

0 commit comments

Comments
 (0)