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

Commit 74ef87f

Browse files
authored
docs: systemjs.config.plunker -> systemjs.config.web w/ auto-bootstrap (#2756)
see PR #2756
1 parent 6ec0e8c commit 74ef87f

File tree

5 files changed

+78
-10
lines changed

5 files changed

+78
-10
lines changed

gulpfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ gulp.task('build-dart-api-docs', ['_shred-api-examples', 'dartdoc'], function()
637637
return buildApiDocsForDart();
638638
});
639639

640-
// Using the --build flag will use systemjs.config.plunker.build.js (for preview builds)
640+
// Using the --build flag will use systemjs.config.web.build.js (for preview builds)
641641
gulp.task('build-plunkers', ['_copy-example-boilerplate'], function() {
642642
regularPlunker.buildPlunkers(EXAMPLES_PATH, LIVE_EXAMPLES_PATH, { errFn: gutil.log, build: argv.build });
643643
return embeddedPlunker.buildPlunkers(EXAMPLES_PATH, LIVE_EXAMPLES_PATH, { errFn: gutil.log, build: argv.build, targetSelf: argv.targetSelf });

public/docs/_examples/_boilerplate/systemjs.config.plunker.build.js renamed to public/docs/_examples/_boilerplate/systemjs.config.web.build.js

+36-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* PLUNKER VERSION FOR CURRENT ANGULAR BUILD
2+
* WEB VERSION FOR CURRENT ANGULAR BUILD
33
* (based on systemjs.config.js in angular.io)
44
* System configuration for Angular samples
55
* Adjust as necessary for your application needs.
@@ -11,7 +11,19 @@
1111
// DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
1212
transpiler: 'ts',
1313
typescriptOptions: {
14-
tsconfig: true
14+
// Complete copy of compiler options in standard tsconfig.json
15+
"target": "es5",
16+
"module": "commonjs",
17+
"moduleResolution": "node",
18+
"sourceMap": true,
19+
"emitDecoratorMetadata": true,
20+
"experimentalDecorators": true,
21+
"removeComments": false,
22+
"noImplicitAny": true,
23+
"suppressImplicitAnyIndexErrors": true,
24+
"typeRoots": [
25+
"../../node_modules/@types/"
26+
]
1527
},
1628
meta: {
1729
'typescript': {
@@ -67,4 +79,26 @@
6779
}
6880
}
6981
});
82+
83+
if (!global.noBootstrap) { bootstrap(); }
84+
85+
// Bootstrap the `AppModule`(skip the `app/main.ts` that normally does this)
86+
function bootstrap() {
87+
88+
// Stub out `app/main.ts` so System.import('app') doesn't fail if called in the index.html
89+
System.set(System.normalizeSync('app/main.ts'), System.newModule({ }));
90+
91+
// bootstrap and launch the app (equivalent to standard main.ts)
92+
Promise.all([
93+
System.import('@angular/platform-browser-dynamic'),
94+
System.import('app/app.module')
95+
])
96+
.then(function (imports) {
97+
var platform = imports[0];
98+
var app = imports[1];
99+
platform.platformBrowserDynamic().bootstrapModule(app.AppModule);
100+
})
101+
.catch(function(err){ console.error(err); });
102+
}
103+
70104
})(this);

public/docs/_examples/_boilerplate/systemjs.config.plunker.js renamed to public/docs/_examples/_boilerplate/systemjs.config.web.js

+36-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* PLUNKER VERSION
2+
* WEB ANGULAR VERSION
33
* (based on systemjs.config.js in angular.io)
44
* System configuration for Angular samples
55
* Adjust as necessary for your application needs.
@@ -9,7 +9,19 @@
99
// DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
1010
transpiler: 'ts',
1111
typescriptOptions: {
12-
tsconfig: true
12+
// Complete copy of compiler options in standard tsconfig.json
13+
"target": "es5",
14+
"module": "commonjs",
15+
"moduleResolution": "node",
16+
"sourceMap": true,
17+
"emitDecoratorMetadata": true,
18+
"experimentalDecorators": true,
19+
"removeComments": false,
20+
"noImplicitAny": true,
21+
"suppressImplicitAnyIndexErrors": true,
22+
"typeRoots": [
23+
"../../node_modules/@types/"
24+
]
1325
},
1426
meta: {
1527
'typescript': {
@@ -54,4 +66,26 @@
5466
}
5567
}
5668
});
69+
70+
if (!global.noBootstrap) { bootstrap(); }
71+
72+
// Bootstrap the `AppModule`(skip the `app/main.ts` that normally does this)
73+
function bootstrap() {
74+
75+
// Stub out `app/main.ts` so System.import('app') doesn't fail if called in the index.html
76+
System.set(System.normalizeSync('app/main.ts'), System.newModule({ }));
77+
78+
// bootstrap and launch the app (equivalent to standard main.ts)
79+
Promise.all([
80+
System.import('@angular/platform-browser-dynamic'),
81+
System.import('app/app.module')
82+
])
83+
.then(function (imports) {
84+
var platform = imports[0];
85+
var app = imports[1];
86+
platform.platformBrowserDynamic().bootstrapModule(app.AppModule);
87+
})
88+
.catch(function(err){ console.error(err); });
89+
}
90+
5791
})(this);

public/docs/_examples/testing/ts/browser-test-shim.js

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ System.config({
3333
},
3434
});
3535

36+
document['noBootstrap'] = true; // do not run system.config.web.js bootstrap
37+
3638
System.import('systemjs.config.js')
3739
.then(importSystemJsExtras)
3840
.then(initTestBed)

tools/plunker-builder/builder.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class PlunkerBuilder {
4141
if (config.basePath.indexOf('/ts') > -1) {
4242
// uses systemjs.config.js so add plunker version
4343
this.options.addField(postData, 'systemjs.config.js', this.systemjsConfig);
44-
this.options.addField(postData, 'tsconfig.json', this.tsconfig);
4544
}
4645
}
4746

@@ -210,13 +209,12 @@ class PlunkerBuilder {
210209
_getPlunkerFiles() {
211210
// Assume plunker version is sibling of node_modules version
212211
this.readme = fs.readFileSync(this.basePath + '/_boilerplate/plunker.README.md', 'utf-8');
213-
var systemJsConfigPath = '/_boilerplate/systemjs.config.plunker.js';
212+
var systemJsConfigPath = '/_boilerplate/systemjs.config.web.js';
214213
if (this.options.build) {
215-
systemJsConfigPath = '/_boilerplate/systemjs.config.plunker.build.js';
214+
systemJsConfigPath = '/_boilerplate/systemjs.config.web.build.js';
216215
}
217216
this.systemjsConfig = fs.readFileSync(this.basePath + systemJsConfigPath, 'utf-8');
218217
this.systemjsConfig += this.copyrights.jsCss;
219-
this.tsconfig = fs.readFileSync(`${this.basePath}/_boilerplate/tsconfig.json`, 'utf-8');
220218
}
221219

222220
_htmlToElement(document, html) {
@@ -255,8 +253,8 @@ class PlunkerBuilder {
255253
}
256254
});
257255

258-
// var defaultExcludes = [ '!**/node_modules/**','!**/tsconfig.json', '!**/*plnkr.json', '!**/*plnkr.html', '!**/*plnkr.no-link.html' ];
259256
var defaultExcludes = [
257+
'!**/app/main.ts',
260258
'!**/tsconfig.json',
261259
'!**/*plnkr.*',
262260
'!**/package.json',

0 commit comments

Comments
 (0)