diff --git a/public/docs/_examples/_boilerplate/systemjs.config.web.build.js b/public/docs/_examples/_boilerplate/systemjs.config.web.build.js index e9c3c5998e..661251cbb8 100644 --- a/public/docs/_examples/_boilerplate/systemjs.config.web.build.js +++ b/public/docs/_examples/_boilerplate/systemjs.config.web.build.js @@ -18,6 +18,7 @@ "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, + "lib": ["es2015", "dom"], "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true }, diff --git a/public/docs/_examples/_boilerplate/systemjs.config.web.js b/public/docs/_examples/_boilerplate/systemjs.config.web.js index 17a873f219..6f5e047c29 100644 --- a/public/docs/_examples/_boilerplate/systemjs.config.web.js +++ b/public/docs/_examples/_boilerplate/systemjs.config.web.js @@ -16,6 +16,7 @@ "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, + "lib": ["es2015", "dom"], "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true }, diff --git a/public/docs/_examples/setup/ts/systemjs.config.extras.web.js b/public/docs/_examples/setup/ts/systemjs.config.extras.web.js new file mode 100644 index 0000000000..71546a2901 --- /dev/null +++ b/public/docs/_examples/setup/ts/systemjs.config.extras.web.js @@ -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); diff --git a/public/docs/_examples/testing/ts/app/hero/hero-detail.component.ts b/public/docs/_examples/testing/ts/app/hero/hero-detail.component.ts index 7e8f23bc23..8c7a58a512 100644 --- a/public/docs/_examples/testing/ts/app/hero/hero-detail.component.ts +++ b/public/docs/_examples/testing/ts/app/hero/hero-detail.component.ts @@ -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('id') + this.route.params.map(p => p['id']) .forEach(id => this.getHero(id)) .catch(() => this.hero = new Hero()); // no id; should edit new hero } diff --git a/public/docs/_examples/testing/ts/systemjs.config.extras.web.js b/public/docs/_examples/testing/ts/systemjs.config.extras.web.js new file mode 100644 index 0000000000..ed28ad662e --- /dev/null +++ b/public/docs/_examples/testing/ts/systemjs.config.extras.web.js @@ -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'} + } +}); diff --git a/tools/plunker-builder/builder.js b/tools/plunker-builder/builder.js index 5dd807e82d..9bb3e2ee44 100644 --- a/tools/plunker-builder/builder.js +++ b/tools/plunker-builder/builder.js @@ -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;