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

Commit 0d5073e

Browse files
authored
chore(plunker): substitute systemjs.config.extras.web.js for systemjs.config.extras.js (#2968)
Solves sudden problem with plunker not handling the non-plunker version Also switch from `pluck` to `map` because `pluck` typing stopped working.
1 parent 5ce171b commit 0d5073e

File tree

6 files changed

+48
-2
lines changed

6 files changed

+48
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"sourceMap": true,
1919
"emitDecoratorMetadata": true,
2020
"experimentalDecorators": true,
21+
"lib": ["es2015", "dom"],
2122
"noImplicitAny": true,
2223
"suppressImplicitAnyIndexErrors": true
2324
},

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"sourceMap": true,
1717
"emitDecoratorMetadata": true,
1818
"experimentalDecorators": true,
19+
"lib": ["es2015", "dom"],
1920
"noImplicitAny": true,
2021
"suppressImplicitAnyIndexErrors": true
2122
},
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Web (plunker) version of systemjs.config.extras.js
3+
* It should default to `.ts` extensions rather than `.js` extensions in almost all cases.
4+
*/
5+
// (function (global) {
6+
// System.config({
7+
// packages: {
8+
// // add packages here
9+
// }
10+
// });
11+
// })(this);

public/docs/_examples/testing/ts/app/hero/hero-detail.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// #docplaster
33
import { Component, Input, OnInit } from '@angular/core';
44
import { ActivatedRoute, Router } from '@angular/router';
5-
import 'rxjs/add/operator/pluck';
5+
import 'rxjs/add/operator/map';
66

77
import { Hero } from '../model';
88
import { HeroDetailService } from './hero-detail.service';
@@ -30,7 +30,7 @@ export class HeroDetailComponent implements OnInit {
3030
// #docregion ng-on-init
3131
ngOnInit(): void {
3232
// get hero when `id` param changes
33-
this.route.params.pluck<string>('id')
33+
this.route.params.map(p => p['id'])
3434
.forEach(id => this.getHero(id))
3535
.catch(() => this.hero = new Hero()); // no id; should edit new hero
3636
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Web (plunker) version of systemjs.config.extras.js
3+
* It should default to `.ts` extensions rather than `.js` extensions in almost all cases.
4+
*/
5+
System.config({
6+
packages: {
7+
// barrels
8+
'app/model': {main:'index.ts', defaultExtension:'ts'},
9+
'app/model/testing': {main:'index.ts', defaultExtension:'ts'}
10+
}
11+
});

tools/plunker-builder/builder.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ class PlunkerBuilder {
122122
if (extn == '.png') {
123123
content = this._encodeBase64(fileName);
124124
fileName = fileName.substr(0, fileName.length - 4) + '.base64.png'
125+
} else if (-1 < fileName.indexOf('systemjs.config.extras')) {
126+
content = this._getSystemjsConfigExtras(config);
125127
} else {
126128
content = fs.readFileSync(fileName, 'utf-8');
127129
}
@@ -215,6 +217,26 @@ class PlunkerBuilder {
215217
// this.systemjsConfig += this.copyrights.jsCss;
216218
}
217219

220+
// Try to replace `systemjs.config.extras.js` with the
221+
// `systemjs.config.extras.web.js` web version that
222+
// should default SystemJS barrels to `.ts` files rather than `.js` files
223+
// Example: see docs `testing`.
224+
// HACK-O-MATIC!
225+
_getSystemjsConfigExtras(config) {
226+
var extras = config.basePath + '/systemjs.config.extras.js';
227+
var webExtras = config.basePath + '/systemjs.config.extras.web.js';
228+
if (fs.existsSync(webExtras)) {
229+
// console.log('** Substituted "' + webExtras + '" for "' + extras + '".');
230+
return fs.readFileSync(webExtras, 'utf-8');
231+
} else if (fs.existsSync(extras)){
232+
console.log('** WARNING: no "' + webExtras + '" replacement for "' + extras + '".');
233+
return fs.readFileSync(extras, 'utf-8');
234+
} else {
235+
console.log('** WARNING: no "' + extras + '" file; returning empty content.');
236+
return '';
237+
}
238+
}
239+
218240
_htmlToElement(document, html) {
219241
var div = document.createElement('div');
220242
div.innerHTML = html;

0 commit comments

Comments
 (0)