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

chore(plunker): sub systemjs.config.extras.web.js for systemjs.config.extras.js #2968

Merged
merged 1 commit into from
Dec 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es2015", "dom"],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
Expand Down
1 change: 1 addition & 0 deletions public/docs/_examples/_boilerplate/systemjs.config.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es2015", "dom"],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
Expand Down
11 changes: 11 additions & 0 deletions public/docs/_examples/setup/ts/systemjs.config.extras.web.js
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
}
Expand Down
11 changes: 11 additions & 0 deletions public/docs/_examples/testing/ts/systemjs.config.extras.web.js
Original file line number Diff line number Diff line change
@@ -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'}
}
});
22 changes: 22 additions & 0 deletions tools/plunker-builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -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;
Expand Down