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

Commit b3c65a9

Browse files
authored
docs(systemjs.web): auto-bootstrap option that creates its own AppModule and boots it. (#2833)
For specific plunkers, e.g. "QuickStart (reboot edition)" PR #2762, that shouldn't have AppModule or main.ts Rescinds the automatic bootstrapping and exclusion of `main.ts` in #2786 and #2756 Only autoBootstraps when `window.autoBootstrap === true`.
1 parent 2d3836c commit b3c65a9

File tree

10 files changed

+25
-31
lines changed

10 files changed

+25
-31
lines changed

public/docs/_examples/_boilerplate/systemjs.config.web.build.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@
7777
}
7878
});
7979

80-
if (!global.noBootstrap) { bootstrap(); }
80+
if (global.autoBootstrap) { bootstrap(); }
8181

82-
// Bootstrap the `AppModule`(skip the `app/main.ts` that normally does this)
82+
// Bootstrap with a default `AppModule`
83+
// ignore an `app/app.module.ts` and `app/main.ts`, even if present
84+
// This function exists primarily (exclusively?) for the QuickStart
8385
function bootstrap() {
8486
console.log('Auto-bootstrapping');
8587

@@ -99,17 +101,10 @@
99101
.catch(function(err){ console.error(err); });
100102
}
101103

102-
// Import AppModule or make the default AppModule if there isn't one
104+
// Make the default AppModule
103105
// returns a promise for the AppModule
104106
function getAppModule() {
105-
if (global.noAppModule) {
106-
return makeAppModule();
107-
}
108-
return System.import('app/app.module').catch(makeAppModule)
109-
}
110-
111-
function makeAppModule() {
112-
console.log('No AppModule; making a bare-bones, default AppModule');
107+
console.log('Making a bare-bones, default AppModule');
113108

114109
return Promise.all([
115110
System.import('@angular/core'),
@@ -135,3 +130,9 @@
135130
})
136131
}
137132
})(this);
133+
134+
/*
135+
Copyright 2016 Google Inc. All Rights Reserved.
136+
Use of this source code is governed by an MIT-style license that
137+
can be found in the LICENSE file at http://angular.io/license
138+
*/

public/docs/_examples/_boilerplate/systemjs.config.web.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@
6464
}
6565
});
6666

67-
if (!global.noBootstrap) { bootstrap(); }
67+
if (global.autoBootstrap) { bootstrap(); }
6868

69-
// Bootstrap the `AppModule`(skip the `app/main.ts` that normally does this)
69+
// Bootstrap with a default `AppModule`
70+
// ignore an `app/app.module.ts` and `app/main.ts`, even if present
71+
// This function exists primarily (exclusively?) for the QuickStart
7072
function bootstrap() {
7173
console.log('Auto-bootstrapping');
7274

@@ -86,17 +88,10 @@
8688
.catch(function(err){ console.error(err); });
8789
}
8890

89-
// Import AppModule or make the default AppModule if there isn't one
91+
// Make the default AppModule
9092
// returns a promise for the AppModule
9193
function getAppModule() {
92-
if (global.noAppModule) {
93-
return makeAppModule();
94-
}
95-
return System.import('app/app.module').catch(makeAppModule)
96-
}
97-
98-
function makeAppModule() {
99-
console.log('No AppModule; making a bare-bones, default AppModule');
94+
console.log('Making a bare-bones, default AppModule');
10095

10196
return Promise.all([
10297
System.import('@angular/core'),
@@ -122,3 +117,9 @@
122117
})
123118
}
124119
})(this);
120+
121+
/*
122+
Copyright 2016 Google Inc. All Rights Reserved.
123+
Use of this source code is governed by an MIT-style license that
124+
can be found in the LICENSE file at http://angular.io/license
125+
*/

public/docs/_examples/ngmodule/ts/index.0.html

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<script src="node_modules/zone.js/dist/zone.js"></script>
1414
<script src="node_modules/reflect-metadata/Reflect.js"></script>
1515
<script src="node_modules/systemjs/dist/system.src.js"></script>
16-
<script>document.noBootstrap = true;</script>
1716
<script src="systemjs.config.js"></script>
1817
<script>
1918
System.import('app/main.0').catch(function(err){ console.error(err); });

public/docs/_examples/ngmodule/ts/index.1.html

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<script src="node_modules/zone.js/dist/zone.js"></script>
1414
<script src="node_modules/reflect-metadata/Reflect.js"></script>
1515
<script src="node_modules/systemjs/dist/system.src.js"></script>
16-
<script>document.noBootstrap = true;</script>
1716
<script src="systemjs.config.js"></script>
1817
<script>
1918
System.import('app/main.1').catch(function(err){ console.error(err); });

public/docs/_examples/ngmodule/ts/index.1b.html

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<script src="node_modules/zone.js/dist/zone.js"></script>
1414
<script src="node_modules/reflect-metadata/Reflect.js"></script>
1515
<script src="node_modules/systemjs/dist/system.src.js"></script>
16-
<script>document.noBootstrap = true;</script>
1716
<script src="systemjs.config.js"></script>
1817
<script>
1918
System.import('app/main.1b').catch(function(err){ console.error(err); });

public/docs/_examples/ngmodule/ts/index.2.html

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<script src="node_modules/zone.js/dist/zone.js"></script>
1414
<script src="node_modules/reflect-metadata/Reflect.js"></script>
1515
<script src="node_modules/systemjs/dist/system.src.js"></script>
16-
<script>document.noBootstrap = true;</script>
1716
<script src="systemjs.config.js"></script>
1817
<script>
1918
System.import('app/main.2').catch(function(err){ console.error(err); });

public/docs/_examples/ngmodule/ts/index.3.html

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<script src="node_modules/zone.js/dist/zone.js"></script>
1414
<script src="node_modules/reflect-metadata/Reflect.js"></script>
1515
<script src="node_modules/systemjs/dist/system.src.js"></script>
16-
<script>document.noBootstrap = true;</script>
1716
<script src="systemjs.config.js"></script>
1817
<script>
1918
System.import('app/main.3').catch(function(err){ console.error(err); });

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

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

36-
document['noBootstrap'] = true; // do not run system.config.web.js bootstrap
37-
3836
System.import('systemjs.config.js')
3937
.then(importSystemJsExtras)
4038
.then(initTestBed)

tools/plunker-builder/builder.js

-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ class PlunkerBuilder {
248248
});
249249

250250
var defaultExcludes = [
251-
'!**/app/main.ts',
252251
'!**/a2docs.css',
253252
'!**/tsconfig.json',
254253
'!**/*plnkr.*',

tools/plunker-builder/indexHtmlTranslator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var _rxRules = {
2121
},
2222
systemjs: {
2323
from: /<script src="systemjs.config.js"><\/script>/,
24-
to: '<script src="https://cdn.rawgit.com/angular/angular.io/74ef87f/public/docs/_examples/_boilerplate/systemjs.config.web.js"></script>'
24+
to: '<script src="https://cdn.rawgit.com/angular/angular.io/f2daab7/public/docs/_examples/_boilerplate/systemjs.config.web.js"></script>'
2525
},
2626
// Clear script like this:
2727
// <script>

0 commit comments

Comments
 (0)