Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit 0a59971

Browse files
committed
disable auto js extensions
1 parent 4f652d8 commit 0a59971

34 files changed

+266
-380
lines changed

dist/es6-module-loader-sans-promises.js

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

dist/es6-module-loader-sans-promises.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6-module-loader-sans-promises.min.js

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

dist/es6-module-loader-sans-promises.src.js

Lines changed: 51 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,10 @@ function logloads(loads) {
11841184
xhr.onload = load;
11851185
xhr.onerror = error;
11861186
xhr.ontimeout = error;
1187+
// IE8/IE9 bug may hang requests unless all properties are defined.
1188+
// See: http://stackoverflow.com/a/9928073/3949247
1189+
xhr.onprogress = function() {};
1190+
xhr.timeout = 0;
11871191
}
11881192
function load() {
11891193
fulfill(xhr.responseText);
@@ -1230,7 +1234,7 @@ function logloads(loads) {
12301234
else {
12311235
this.baseURL = process.cwd() + '/';
12321236
}
1233-
this.paths = { '*': '*.js' };
1237+
this.paths = { '*': '*' };
12341238
}
12351239

12361240
SystemLoader.__proto__ = ($__super !== null ? $__super : Function.prototype);
@@ -1258,102 +1262,65 @@ function logloads(loads) {
12581262
if (typeof name != 'string')
12591263
throw new TypeError('Module name must be a string');
12601264

1261-
var segments = name.split('/');
1262-
1263-
if (segments.length == 0)
1264-
throw new TypeError('No module name provided');
1265-
1266-
// current segment
1267-
var i = 0;
1268-
// is the module name relative
1269-
var rel = false;
1270-
// number of backtracking segments
1271-
var dotdots = 0;
1272-
if (segments[0] == '.') {
1273-
i++;
1274-
if (i == segments.length)
1275-
throw new TypeError('Illegal module name "' + name + '"');
1276-
rel = true;
1277-
}
1278-
else {
1279-
while (segments[i] == '..') {
1280-
i++;
1281-
if (i == segments.length)
1282-
throw new TypeError('Illegal module name "' + name + '"');
1283-
}
1284-
if (i)
1285-
rel = true;
1286-
dotdots = i;
1287-
}
1288-
1289-
for (var j = i; j < segments.length; j++) {
1290-
var segment = segments[j];
1291-
if (segment == '' || segment == '.' || segment == '..')
1292-
throw new TypeError('Illegal module name "' + name + '"');
1293-
}
1294-
1295-
if (!rel)
1296-
return name;
1297-
1298-
// build the full module name
1299-
var normalizedParts = [];
1300-
var parentParts = (parentName || '').split('/');
1301-
var normalizedLen = parentParts.length - 1 - dotdots;
1302-
1303-
normalizedParts = normalizedParts.concat(parentParts.splice(0, parentParts.length - 1 - dotdots));
1304-
normalizedParts = normalizedParts.concat(segments.splice(i, segments.length - i));
1305-
1306-
return normalizedParts.join('/');
1307-
},
1308-
1309-
enumerable: false,
1310-
writable: true
1311-
});
1312-
1313-
$__Object$defineProperty(SystemLoader.prototype, "locate", {
1314-
value: function(load) {
1315-
var name = load.name;
1316-
1317-
// NB no specification provided for System.paths, used ideas discussed in https://github.com/jorendorff/js-loaders/issues/25
1265+
// if all names are normalized, then we only ever need to
1266+
// normalize relative to the parent
1267+
// the top-level parent is then just the baseURL
1268+
parentName = parentName || this.baseURL;
13181269

1270+
// if the name does not start with a ./, ../, / or scheme:
1271+
// then we first apply paths configuration with wildcard
1272+
// used ideas discussed in https://github.com/jorendorff/js-loaders/issues/25
13191273
// most specific (longest) match wins
1320-
var pathMatch = '', wildcard;
1321-
1322-
// check to see if we have a paths entry
1323-
for (var p in this.paths) {
1324-
var pathParts = p.split('*');
1325-
if (pathParts.length > 2)
1326-
throw new TypeError('Only one wildcard in a path is permitted');
1327-
1328-
// exact path match
1329-
if (pathParts.length == 1) {
1330-
if (name == p && p.length > pathMatch.length) {
1331-
pathMatch = p;
1332-
break;
1274+
if (name.substr(0, 2) != './' && name.substr(0, 3) != '../' && name.substr(0, 1) != '/' && name.indexOf(':') == -1) {
1275+
var pathMatch = '', wildcard;
1276+
1277+
// check to see if we have a paths entry
1278+
for (var p in this.paths) {
1279+
var pathParts = p.split('*');
1280+
if (pathParts.length > 2)
1281+
throw new TypeError('Only one wildcard in a path is permitted');
1282+
1283+
// exact path match
1284+
if (pathParts.length == 1) {
1285+
if (name == p && p.length > pathMatch.length) {
1286+
pathMatch = p;
1287+
break;
1288+
}
13331289
}
1334-
}
13351290

1336-
// wildcard path match
1337-
else {
1338-
if (name.substr(0, pathParts[0].length) == pathParts[0] && name.substr(name.length - pathParts[1].length) == pathParts[1]) {
1339-
pathMatch = p;
1340-
wildcard = name.substr(pathParts[0].length, name.length - pathParts[1].length - pathParts[0].length);
1291+
// wildcard path match
1292+
else {
1293+
if (name.substr(0, pathParts[0].length) == pathParts[0] && name.substr(name.length - pathParts[1].length) == pathParts[1]) {
1294+
pathMatch = p;
1295+
wildcard = name.substr(pathParts[0].length, name.length - pathParts[1].length - pathParts[0].length);
1296+
}
13411297
}
13421298
}
1299+
name = this.paths[pathMatch];
1300+
if (wildcard)
1301+
name = name.replace('*', wildcard);
13431302
}
13441303

1345-
var outPath = this.paths[pathMatch];
1346-
if (wildcard)
1347-
outPath = outPath.replace('*', wildcard);
1348-
13491304
// percent encode just '#' in module names
13501305
// according to https://github.com/jorendorff/js-loaders/blob/master/browser-loader.js#L238
13511306
// we should encode everything, but it breaks for servers that don't expect it
13521307
// like in (https://github.com/systemjs/systemjs/issues/168)
13531308
if (isBrowser)
1354-
outPath = outPath.replace(/#/g, '%23');
1309+
name = name.replace(/#/g, '%23');
13551310

1356-
return toAbsoluteURL(this.baseURL, outPath);
1311+
return toAbsoluteURL(parentName, name);
1312+
},
1313+
1314+
enumerable: false,
1315+
writable: true
1316+
});
1317+
1318+
$__Object$defineProperty(SystemLoader.prototype, "locate", {
1319+
value: function(load) {
1320+
// it is possible for locate to not to be a fully normalized URL
1321+
// if name was forced into not being of an absolute URL by normalize
1322+
// so we run toAbsoluteURL again just in case
1323+
return toAbsoluteURL(this.baseURL, load.name);
13571324
},
13581325

13591326
enumerable: false,
@@ -1424,6 +1391,7 @@ function logloads(loads) {
14241391
}
14251392
})();
14261393

1394+
14271395
// Define our eval outside of the scope of any other reference defined in this
14281396
// file to avoid adding those references to the evaluation scope.
14291397
function __eval(__source, __global, load) {

dist/es6-module-loader.js

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

dist/es6-module-loader.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6-module-loader.min.js

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

dist/es6-module-loader.src.js

Lines changed: 51 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,6 +2387,10 @@ function logloads(loads) {
23872387
xhr.onload = load;
23882388
xhr.onerror = error;
23892389
xhr.ontimeout = error;
2390+
// IE8/IE9 bug may hang requests unless all properties are defined.
2391+
// See: http://stackoverflow.com/a/9928073/3949247
2392+
xhr.onprogress = function() {};
2393+
xhr.timeout = 0;
23902394
}
23912395
function load() {
23922396
fulfill(xhr.responseText);
@@ -2433,7 +2437,7 @@ function logloads(loads) {
24332437
else {
24342438
this.baseURL = process.cwd() + '/';
24352439
}
2436-
this.paths = { '*': '*.js' };
2440+
this.paths = { '*': '*' };
24372441
}
24382442

24392443
SystemLoader.__proto__ = ($__super !== null ? $__super : Function.prototype);
@@ -2461,102 +2465,65 @@ function logloads(loads) {
24612465
if (typeof name != 'string')
24622466
throw new TypeError('Module name must be a string');
24632467

2464-
var segments = name.split('/');
2465-
2466-
if (segments.length == 0)
2467-
throw new TypeError('No module name provided');
2468-
2469-
// current segment
2470-
var i = 0;
2471-
// is the module name relative
2472-
var rel = false;
2473-
// number of backtracking segments
2474-
var dotdots = 0;
2475-
if (segments[0] == '.') {
2476-
i++;
2477-
if (i == segments.length)
2478-
throw new TypeError('Illegal module name "' + name + '"');
2479-
rel = true;
2480-
}
2481-
else {
2482-
while (segments[i] == '..') {
2483-
i++;
2484-
if (i == segments.length)
2485-
throw new TypeError('Illegal module name "' + name + '"');
2486-
}
2487-
if (i)
2488-
rel = true;
2489-
dotdots = i;
2490-
}
2491-
2492-
for (var j = i; j < segments.length; j++) {
2493-
var segment = segments[j];
2494-
if (segment == '' || segment == '.' || segment == '..')
2495-
throw new TypeError('Illegal module name "' + name + '"');
2496-
}
2497-
2498-
if (!rel)
2499-
return name;
2500-
2501-
// build the full module name
2502-
var normalizedParts = [];
2503-
var parentParts = (parentName || '').split('/');
2504-
var normalizedLen = parentParts.length - 1 - dotdots;
2505-
2506-
normalizedParts = normalizedParts.concat(parentParts.splice(0, parentParts.length - 1 - dotdots));
2507-
normalizedParts = normalizedParts.concat(segments.splice(i, segments.length - i));
2508-
2509-
return normalizedParts.join('/');
2510-
},
2511-
2512-
enumerable: false,
2513-
writable: true
2514-
});
2515-
2516-
$__Object$defineProperty(SystemLoader.prototype, "locate", {
2517-
value: function(load) {
2518-
var name = load.name;
2519-
2520-
// NB no specification provided for System.paths, used ideas discussed in https://github.com/jorendorff/js-loaders/issues/25
2468+
// if all names are normalized, then we only ever need to
2469+
// normalize relative to the parent
2470+
// the top-level parent is then just the baseURL
2471+
parentName = parentName || this.baseURL;
25212472

2473+
// if the name does not start with a ./, ../, / or scheme:
2474+
// then we first apply paths configuration with wildcard
2475+
// used ideas discussed in https://github.com/jorendorff/js-loaders/issues/25
25222476
// most specific (longest) match wins
2523-
var pathMatch = '', wildcard;
2524-
2525-
// check to see if we have a paths entry
2526-
for (var p in this.paths) {
2527-
var pathParts = p.split('*');
2528-
if (pathParts.length > 2)
2529-
throw new TypeError('Only one wildcard in a path is permitted');
2530-
2531-
// exact path match
2532-
if (pathParts.length == 1) {
2533-
if (name == p && p.length > pathMatch.length) {
2534-
pathMatch = p;
2535-
break;
2477+
if (name.substr(0, 2) != './' && name.substr(0, 3) != '../' && name.substr(0, 1) != '/' && name.indexOf(':') == -1) {
2478+
var pathMatch = '', wildcard;
2479+
2480+
// check to see if we have a paths entry
2481+
for (var p in this.paths) {
2482+
var pathParts = p.split('*');
2483+
if (pathParts.length > 2)
2484+
throw new TypeError('Only one wildcard in a path is permitted');
2485+
2486+
// exact path match
2487+
if (pathParts.length == 1) {
2488+
if (name == p && p.length > pathMatch.length) {
2489+
pathMatch = p;
2490+
break;
2491+
}
25362492
}
2537-
}
25382493

2539-
// wildcard path match
2540-
else {
2541-
if (name.substr(0, pathParts[0].length) == pathParts[0] && name.substr(name.length - pathParts[1].length) == pathParts[1]) {
2542-
pathMatch = p;
2543-
wildcard = name.substr(pathParts[0].length, name.length - pathParts[1].length - pathParts[0].length);
2494+
// wildcard path match
2495+
else {
2496+
if (name.substr(0, pathParts[0].length) == pathParts[0] && name.substr(name.length - pathParts[1].length) == pathParts[1]) {
2497+
pathMatch = p;
2498+
wildcard = name.substr(pathParts[0].length, name.length - pathParts[1].length - pathParts[0].length);
2499+
}
25442500
}
25452501
}
2502+
name = this.paths[pathMatch];
2503+
if (wildcard)
2504+
name = name.replace('*', wildcard);
25462505
}
25472506

2548-
var outPath = this.paths[pathMatch];
2549-
if (wildcard)
2550-
outPath = outPath.replace('*', wildcard);
2551-
25522507
// percent encode just '#' in module names
25532508
// according to https://github.com/jorendorff/js-loaders/blob/master/browser-loader.js#L238
25542509
// we should encode everything, but it breaks for servers that don't expect it
25552510
// like in (https://github.com/systemjs/systemjs/issues/168)
25562511
if (isBrowser)
2557-
outPath = outPath.replace(/#/g, '%23');
2512+
name = name.replace(/#/g, '%23');
25582513

2559-
return toAbsoluteURL(this.baseURL, outPath);
2514+
return toAbsoluteURL(parentName, name);
2515+
},
2516+
2517+
enumerable: false,
2518+
writable: true
2519+
});
2520+
2521+
$__Object$defineProperty(SystemLoader.prototype, "locate", {
2522+
value: function(load) {
2523+
// it is possible for locate to not to be a fully normalized URL
2524+
// if name was forced into not being of an absolute URL by normalize
2525+
// so we run toAbsoluteURL again just in case
2526+
return toAbsoluteURL(this.baseURL, load.name);
25602527
},
25612528

25622529
enumerable: false,
@@ -2627,6 +2594,7 @@ function logloads(loads) {
26272594
}
26282595
})();
26292596

2597+
26302598
// Define our eval outside of the scope of any other reference defined in this
26312599
// file to avoid adding those references to the evaluation scope.
26322600
function __eval(__source, __global, load) {

0 commit comments

Comments
 (0)