Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 843a185

Browse files
committed
chore: fix moduleId loader on plunkers
1 parent 223c944 commit 843a185

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

public/docs/_examples/_boilerplate/src/systemjs-angular-loader.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,27 @@ module.exports.translate = function(load){
66

77
var url = new URL(load.address);
88

9-
var basePathParts = url.pathname.split('/');
9+
var onPlunker = url.href.indexOf('plnkr') != -1;
10+
var onEmbedPlunker = url.href.indexOf('preview') != -1;
1011

11-
if (url.href.indexOf('plnkr') != -1) {
12-
basePathParts.shift();
13-
basePathParts.shift();
12+
var basePathParts = url.pathname.split('/').splice(1);
13+
14+
if (onPlunker) {
15+
var times = onEmbedPlunker ? 2 : 1;
16+
basePathParts.splice(0, times);
1417
}
1518

1619
basePathParts.pop();
1720
var basePath = basePathParts.join('/');
21+
22+
if (onPlunker) basePath.substr(1); // Plunker doesn't like the / suffix
23+
1824
load.source = load.source
1925
.replace(templateUrlRegex, function(match, quote, url){
2026
let resolvedUrl = url;
2127

2228
if (url.startsWith('.')) {
23-
resolvedUrl = basePath + url.substr(1);
29+
resolvedUrl = `${basePath}${url.substr(1)}`;
2430
}
2531

2632
return `templateUrl: '${resolvedUrl}'`;
@@ -30,7 +36,7 @@ module.exports.translate = function(load){
3036

3137
while ((match = stringRegex.exec(relativeUrls)) !== null) {
3238
if (match[2].startsWith('.')) {
33-
urls.push(`'${basePath.substr(1)}${match[2].substr(1)}'`);
39+
urls.push(`'${basePath}${match[2].substr(1)}'`);
3440
} else {
3541
urls.push(`'${match[2]}'`);
3642
}

public/docs/_examples/_boilerplate/src/systemjs.config.web.build.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
},
3535
// map tells the System loader where to look for things
3636
map: {
37-
'ng-loader': './systemjs-angular-loader.js',
3837
// our app is within the app folder
3938
'app': 'app',
4039

@@ -75,7 +74,7 @@
7574
defaultExtension: 'ts',
7675
meta: {
7776
'./*.ts': {
78-
loader: 'ng-loader'
77+
loader: 'systemjs-angular-loader.js'
7978
}
8079
}
8180
},

public/docs/_examples/_boilerplate/src/systemjs.config.web.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
},
3232
// map tells the System loader where to look for things
3333
map: {
34-
'ng-loader': './systemjs-angular-loader.js',
3534
// our app is within the app folder
3635
'app': 'app',
3736

@@ -62,7 +61,7 @@
6261
defaultExtension: 'ts',
6362
meta: {
6463
'./*.ts': {
65-
loader: 'ng-loader'
64+
loader: 'systemjs-angular-loader.js'
6665
}
6766
}
6867
},

0 commit comments

Comments
 (0)