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.
This commit is contained in:
Ward Bell 2016-12-13 20:57:47 -08:00 committed by GitHub
parent 5ce171bd74
commit 0d5073e74b
6 changed files with 48 additions and 2 deletions

View File

@ -18,6 +18,7 @@
"sourceMap": true, "sourceMap": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"lib": ["es2015", "dom"],
"noImplicitAny": true, "noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true "suppressImplicitAnyIndexErrors": true
}, },

View File

@ -16,6 +16,7 @@
"sourceMap": true, "sourceMap": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"lib": ["es2015", "dom"],
"noImplicitAny": true, "noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true "suppressImplicitAnyIndexErrors": true
}, },

View File

@ -0,0 +1,11 @@
/**
* Web (plunker) version of systemjs.config.extras.js
* It should default to `.ts` extensions rather than `.js` extensions in almost all cases.
*/
// (function (global) {
// System.config({
// packages: {
// // add packages here
// }
// });
// })(this);

View File

@ -2,7 +2,7 @@
// #docplaster // #docplaster
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import 'rxjs/add/operator/pluck'; import 'rxjs/add/operator/map';
import { Hero } from '../model'; import { Hero } from '../model';
import { HeroDetailService } from './hero-detail.service'; import { HeroDetailService } from './hero-detail.service';
@ -30,7 +30,7 @@ export class HeroDetailComponent implements OnInit {
// #docregion ng-on-init // #docregion ng-on-init
ngOnInit(): void { ngOnInit(): void {
// get hero when `id` param changes // get hero when `id` param changes
this.route.params.pluck<string>('id') this.route.params.map(p => p['id'])
.forEach(id => this.getHero(id)) .forEach(id => this.getHero(id))
.catch(() => this.hero = new Hero()); // no id; should edit new hero .catch(() => this.hero = new Hero()); // no id; should edit new hero
} }

View File

@ -0,0 +1,11 @@
/**
* Web (plunker) version of systemjs.config.extras.js
* It should default to `.ts` extensions rather than `.js` extensions in almost all cases.
*/
System.config({
packages: {
// barrels
'app/model': {main:'index.ts', defaultExtension:'ts'},
'app/model/testing': {main:'index.ts', defaultExtension:'ts'}
}
});

View File

@ -122,6 +122,8 @@ class PlunkerBuilder {
if (extn == '.png') { if (extn == '.png') {
content = this._encodeBase64(fileName); content = this._encodeBase64(fileName);
fileName = fileName.substr(0, fileName.length - 4) + '.base64.png' fileName = fileName.substr(0, fileName.length - 4) + '.base64.png'
} else if (-1 < fileName.indexOf('systemjs.config.extras')) {
content = this._getSystemjsConfigExtras(config);
} else { } else {
content = fs.readFileSync(fileName, 'utf-8'); content = fs.readFileSync(fileName, 'utf-8');
} }
@ -215,6 +217,26 @@ class PlunkerBuilder {
// this.systemjsConfig += this.copyrights.jsCss; // this.systemjsConfig += this.copyrights.jsCss;
} }
// Try to replace `systemjs.config.extras.js` with the
// `systemjs.config.extras.web.js` web version that
// should default SystemJS barrels to `.ts` files rather than `.js` files
// Example: see docs `testing`.
// HACK-O-MATIC!
_getSystemjsConfigExtras(config) {
var extras = config.basePath + '/systemjs.config.extras.js';
var webExtras = config.basePath + '/systemjs.config.extras.web.js';
if (fs.existsSync(webExtras)) {
// console.log('** Substituted "' + webExtras + '" for "' + extras + '".');
return fs.readFileSync(webExtras, 'utf-8');
} else if (fs.existsSync(extras)){
console.log('** WARNING: no "' + webExtras + '" replacement for "' + extras + '".');
return fs.readFileSync(extras, 'utf-8');
} else {
console.log('** WARNING: no "' + extras + '" file; returning empty content.');
return '';
}
}
_htmlToElement(document, html) { _htmlToElement(document, html) {
var div = document.createElement('div'); var div = document.createElement('div');
div.innerHTML = html; div.innerHTML = html;