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:
parent
5ce171bd74
commit
0d5073e74b
|
@ -18,6 +18,7 @@
|
|||
"sourceMap": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"lib": ["es2015", "dom"],
|
||||
"noImplicitAny": true,
|
||||
"suppressImplicitAnyIndexErrors": true
|
||||
},
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"sourceMap": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"lib": ["es2015", "dom"],
|
||||
"noImplicitAny": true,
|
||||
"suppressImplicitAnyIndexErrors": true
|
||||
},
|
||||
|
|
|
@ -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);
|
|
@ -2,7 +2,7 @@
|
|||
// #docplaster
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import 'rxjs/add/operator/pluck';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import { Hero } from '../model';
|
||||
import { HeroDetailService } from './hero-detail.service';
|
||||
|
@ -30,7 +30,7 @@ export class HeroDetailComponent implements OnInit {
|
|||
// #docregion ng-on-init
|
||||
ngOnInit(): void {
|
||||
// get hero when `id` param changes
|
||||
this.route.params.pluck<string>('id')
|
||||
this.route.params.map(p => p['id'])
|
||||
.forEach(id => this.getHero(id))
|
||||
.catch(() => this.hero = new Hero()); // no id; should edit new hero
|
||||
}
|
||||
|
|
|
@ -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'}
|
||||
}
|
||||
});
|
|
@ -122,6 +122,8 @@ class PlunkerBuilder {
|
|||
if (extn == '.png') {
|
||||
content = this._encodeBase64(fileName);
|
||||
fileName = fileName.substr(0, fileName.length - 4) + '.base64.png'
|
||||
} else if (-1 < fileName.indexOf('systemjs.config.extras')) {
|
||||
content = this._getSystemjsConfigExtras(config);
|
||||
} else {
|
||||
content = fs.readFileSync(fileName, 'utf-8');
|
||||
}
|
||||
|
@ -215,6 +217,26 @@ class PlunkerBuilder {
|
|||
// 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) {
|
||||
var div = document.createElement('div');
|
||||
div.innerHTML = html;
|
||||
|
|
Loading…
Reference in New Issue