Skip to content

Commit 20a16cb

Browse files
committed
fixed issues with boilerplate, added new options for update, edited CHANGELOG
1 parent 1567466 commit 20a16cb

9 files changed

+294
-183
lines changed

Diff for: CHANGELOG.md

+107-28
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,110 @@
1-
##1.0.0-beta.10
1+
## 1.0.0-beta.10
22

3-
- New configuration file `lazy.config.json` for lazyloaded bundles
4-
- New `system.polyfill.js` loads `lazy.config.json`, uses a polyfill for SystemJS to map lazyloaded bundles
3+
- BREAKING CHANGES in boilerplate `index.html`, `system.import.js`, and `system.config.prod.js`. Refactored files to support lazyloaded bundles
4+
- New configuration file `lazy.config.json` provides model for automating Closure Compiler and SystemJS polyfill for lazyloaded bundles
5+
- Moved the SystemJS polyfill into `system.polyfill.js`. This script requests `lazy.config.json`, uses a polyfill for SystemJS to map lazyloaded bundles
56
- `--closure` is now the default production build, use `ngr build prod --rollup` to bundle with Rollup instead
6-
- Condensed log messages for build scripts. Use --verbose to print more verbose messages
7-
- Fixed issue with closure that prevented bundle.js from being created
8-
- Updated --verbose logs for closure build
7+
- Condensed log messages for build scripts. Use `--verbose` to print more verbose messages
8+
- Fixed issue with Closure Compiler that prevented bundle.js from being created
9+
- Improved error reporting across the builds
10+
- Prevented overwriting of project files when user repeats `ngr scaffold` or `ngr update`
11+
- Third party libraries (externs) can be bundled but not mangled by ADVANCED_OPTIMIZATIONS when configured in `lazy.config.json`
12+
- New argument for update `--cliVersion` will attempt to update existing boilerplate, but will not overwrite existing files
13+
14+
To update:
15+
16+
$`npm -g angular-rollup@latest`
17+
18+
In the project directory:
19+
20+
$`ngr update --angularVersion 4.4.3 --cliVersion 1.0.0-beta.10`
21+
$`npm install`
22+
23+
24+
### ngr update --cliVersion
25+
26+
```
27+
$ ngr update --cliVersion 1.0.0-beta.10
28+
[13:17:07] LOG Review changes to angular-rollup in the CHANGELOG (https://github.com/steveblue/angular2-rollup/blob/master/CHANGELOG.md)
29+
[13:17:07] LOG lazy.config.json copied to /Users/steveb/www/4-test/
30+
[13:17:07] LOG system.polyfill.js copied to /Users/steveb/www/4-test/
31+
[13:17:07] WARN src/public/system.import.js already exists
32+
[13:17:07] WARN src/public/system.config.prod.js already exists
33+
[13:17:07] WARN src/public/index.html already exists
34+
[13:17:07] WARN Please move or delete existing files to prevent overwiting. Use a diff tool to track project specific changes.
35+
```
36+
37+
The update task copies new files, warns about overwriting existing files.
38+
39+
If you have changed boilerplate files, you will need to diff them against the new files.
40+
Copy the files into a temporary directory and run the command again, then diff the existing files to check for project specific changes.
41+
42+
If you do not have changes to the boilerplate files, just remove the files and run the command again.
43+
44+
```
45+
$ rm -rf src/public/system.import.js
46+
$ rm -rf src/public/system.config.prod.js
47+
$ rm -rf src/public/index.html
48+
$ ngr update --cliVersion 1.0.0-beta.10
49+
[13:20:43] LOG Review changes to angular-rollup in the CHANGELOG (https://github.com/steveblue/angular2-rollup/blob/master/CHANGELOG.md)
50+
[13:20:43] WARN lazy.config.json already exists
51+
[13:20:43] WARN src/public/system.polyfill.js already exists
52+
[13:20:43] LOG system.import.js copied to /Users/steveb/www/4-test/
53+
[13:20:43] LOG system.config.prod.js copied to /Users/steveb/www/4-test/
54+
[13:20:43] LOG index.html copied to /Users/steveb/www/4-test/
55+
[13:20:43] WARN Please move or delete existing files to prevent overwiting. Use a diff tool to track project specific changes.
56+
```
57+
58+
NOTE: The second warning in the above example is fine, since lazy.config.json and src/public/system.polyfill.js are new files.
59+
60+
61+
### lazy.config.json
62+
63+
A new file is required to configure both the production build script and the SystemJS polyfill at runtime.
64+
65+
```
66+
{
67+
"bundles": {
68+
"shared/components/lazy/lazy.module.ngfactory.js": {
69+
"src": "./ngfactory/src/app/shared/components/lazy/lazy.module.ngfactory.js",
70+
"filename": "lazy.module.bundle.js",
71+
"className": "LazyModuleNgFactory",
72+
"path": "http://localhost:4200",
73+
"externs": []
74+
}
75+
}
76+
}
77+
```
78+
79+
^ All properties are required except `externs`
80+
81+
To bundle third party scripts, point to the minified version of the script in the externs Array.
82+
83+
```
84+
"externs": [
85+
"node_modules/marked/marked.min.js"
86+
]
87+
```
988

1089

1190
-------------------------------------------------------------------------------------------------------------
1291

13-
##1.0.0-beta.9
92+
## 1.0.0-beta.9
1493

1594
- Fixed issue with update warning
1695

1796
-------------------------------------------------------------------------------------------------------------
1897

1998

20-
##1.0.0-beta.8
99+
## 1.0.0-beta.8
21100

22101
- Cleaned up terminal logs
23102
- Added warning message for when locally installed cli is out of date
24103
- Fixed missing .map file for Reflect.js in --jit mode
25104

26105
-------------------------------------------------------------------------------------------------------------
27106

28-
##1.0.0-beta.7
107+
## 1.0.0-beta.7
29108

30109
- New wizard makes codegen simpler, trigger with `ngr generate wizard`
31110
- Fixed usage of `g` as shorthand for `generate`
@@ -56,7 +135,7 @@ e2e: n
56135

57136
-------------------------------------------------------------------------------------------------------------
58137

59-
##1.0.0-beta.6
138+
## 1.0.0-beta.6
60139

61140
- Use `ngr update --angularVersion` to update your package.json to a specific version of @angular
62141
- New and improved Module generation. `--include` flag can be configured to auto import Component, Directive, Routes into the Module.
@@ -85,19 +164,19 @@ COMING SOON FOR 1.0.0-beta
85164

86165
-------------------------------------------------------------------------------------------------------------
87166

88-
##1.0.0-beta.4
167+
## 1.0.0-beta.4
89168

90169
- Hotfix TypeScript compilation onchange when using `ngr build dev --jit`
91170

92171
-------------------------------------------------------------------------------------------------------------
93172

94-
##1.0.0-beta.3
173+
## 1.0.0-beta.3
95174

96175
- Hotfix for global css that would not compile correctly
97176

98177
-------------------------------------------------------------------------------------------------------------
99178

100-
##1.0.0-beta.2
179+
## 1.0.0-beta.2
101180

102181
- Refactored SASS / PostCSS build steps, removed duplicate code
103182
- Added config for the `libsass` compiler
@@ -143,7 +222,7 @@ style: {
143222
-------------------------------------------------------------------------------------------------------------
144223

145224

146-
##1.0.0-beta.1
225+
## 1.0.0-beta.1
147226

148227
- Bypass Rollup and build for production with ClosureCompiler in ADVANCED_OPTIMIZATIONS mode
149228
- EXPERIMENTAL Support for lazyloading routes with ClosureCompiler, requires additional high level API coming soon
@@ -164,7 +243,7 @@ To build for production with support for lazyloaded routes:
164243

165244

166245
-------------------------------------------------------------------------------------------------------------
167-
##1.0.0-beta.0
246+
## 1.0.0-beta.0
168247

169248
- Updated npm package name to `angular-rollup`, `angular2-rollup` is deprecated
170249
- Cross platform support including MacOS, Windows and Linux for the CLI
@@ -182,7 +261,7 @@ Minimal changes will be required to upgrade to `angular-rollup`.
182261

183262
-------------------------------------------------------------------------------------------------------------
184263

185-
##5.0.0-beta.6
264+
## 5.0.0-beta.6
186265

187266
BREAKING CHANGES
188267

@@ -196,7 +275,7 @@ To update existing projects, migrate `main.prod.ts`, `tsconfig.dev.json` and `ts
196275

197276
NOTE: `ngr build lib` is broken in `5.0.0-beta.4-5.0.0-beta.6`. If you want to test this build use `ngr scaffold --angularVersion 5.0.0-beta.3` to scaffold your app.
198277

199-
###Prior to 5.0.0
278+
### Prior to 5.0.0
200279

201280
`main.prod.ts`
202281

@@ -283,7 +362,7 @@ platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
283362
```
284363

285364

286-
###After 5.0.0
365+
### After 5.0.0
287366

288367
`main.prod.ts`
289368

@@ -403,7 +482,7 @@ Prior to 5.0.0 `main.prod.ts` needed to be included for `ngc`. After 5.0.0 `ngc`
403482
```
404483

405484

406-
##4.4.0-RC.0
485+
## 4.4.0-RC.0
407486

408487
MAJOR BREAKING CHANGES in this release. This release is primarily to improve the CLI, make writing custom builds easier. This release decouples the CLI from project code.
409488

@@ -417,7 +496,7 @@ MAJOR BREAKING CHANGES in this release. This release is primarily to improve the
417496
- Normalized CLI commands, use build instead of --build or generate instead of --generate
418497

419498

420-
###MIGRATING from 4.3.6 to 4.4.0-RC.0
499+
### MIGRATING from 4.3.6 to 4.4.0-RC.0
421500

422501
Install the CLI globally. `npm install -g angular2-rollup`
423502

@@ -493,19 +572,19 @@ Update `@angular` dependencies in `package.json`
493572

494573

495574

496-
##4.3.6
575+
## 4.3.6
497576

498577
- Updated to Angular 4.3.6
499578
- Fixed issue in library build that prevented global CSS form compiling minified
500579

501580

502-
##4.3.5
581+
## 4.3.5
503582

504583
- Updated to Angular 4.3.5
505584
- Deprecated `@types/core-js` and instead configured `compilerOptions.lib` for the dev build
506585

507586

508-
##4.3.0
587+
## 4.3.0
509588

510589
- Updated to Angular 4.3.0
511590
- Updated RxJs to ~5.4.2 and TypeScript to ^4.2.0, included TypeScript fix in RxJs
@@ -540,7 +619,7 @@ The production build now requires a new Object in build.config.js with the prope
540619
```
541620

542621

543-
##4.3.0-beta.0
622+
## 4.3.0-beta.0
544623

545624
- Updated to Angular 4.3.0-beta.0
546625
- Updated packages to latest compatible versions
@@ -589,7 +668,7 @@ For more information: https://github.com/postcss/postcss-cli/wiki/Migrating-from
589668
----------------------------------------------------------------------------------------------------
590669

591670

592-
##4.2.0
671+
## 4.2.0
593672

594673
- Updated to Angular 4.2.0
595674
- Fixed issue when updating global SASS, livereload and CSS would not update when editing certain files
@@ -600,7 +679,7 @@ For more information: https://github.com/postcss/postcss-cli/wiki/Migrating-from
600679

601680
----------------------------------------------------------------------------------------------------
602681

603-
##4.0.3
682+
## 4.0.3
604683

605684
- Updated to Angular 4.0.3
606685
- New CLI commands, run `npm i -g` to use in your project
@@ -630,13 +709,13 @@ For more information: https://github.com/postcss/postcss-cli/wiki/Migrating-from
630709

631710
----------------------------------------------------------------------------------------------------
632711

633-
##4.0.2
712+
## 4.0.2
634713

635714
- Updated to Angular 4.0.2
636715

637716
----------------------------------------------------------------------------------------------------
638717

639-
##4.0.1
718+
## 4.0.1
640719

641720

642721
- Updated to Angular 4.0.1

Diff for: build.prod.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ const compile = {
213213
fs.writeFile(path.normalize(config.projectRoot+'/tmp/closure.lazy.conf'), conf, 'utf-8', () => {
214214

215215
if (isVerbose) log('manifest built');
216-
//if (isVerbose) log('\n'+conf);
217216

218217
finalExec += 'java -jar node_modules/google-closure-compiler/compiler.jar --flagfile ./tmp/closure.lazy.conf \\\n'
219218
finalExec += '--entry_point=./main.prod \\\n';
@@ -233,10 +232,14 @@ const compile = {
233232
':(self._S=self._S||[]).push((function(){%s})); //# sourceMappingURL=%basename%.map" \\\n';
234233
});
235234

236-
exec(finalExec, () => {
235+
exec(finalExec, { silent: true }, (code, output, error) => {
237236

237+
if (error) {
238+
warn(error);
239+
return;
240+
}
238241

239-
exec('java -jar node_modules/google-closure-compiler/compiler.jar --compilation_level=SIMPLE_OPTIMIZATIONS --js ./src/public/system.polyfill.js --js_output_file ./build/system.polyfill.js', { silent: true }, (code, output, error) => {
242+
exec('java -jar node_modules/google-closure-compiler/compiler.jar --compilation_level=SIMPLE_OPTIMIZATIONS --js ./src/public/system.polyfill.js --js_output_file ./build/system.polyfill.js', { silent: true }, (code, output, error) => {
240243

241244
if (error) {
242245
warn(error);
@@ -245,7 +248,7 @@ const compile = {
245248

246249
if(isVerbose) log('closure compiler', 'optimized system.polyfill.js');
247250
alert('closure compiler', colors.green('optimized project bundles'));
248-
251+
249252
if (canServe === true) {
250253
alert(colors.green('Ready to serve'));
251254
utils.serve(canWatch);
@@ -258,6 +261,10 @@ const compile = {
258261

259262
var externs = bundle.model.externs;
260263

264+
if(!externs || externs.length === 0) {
265+
return;
266+
}
267+
261268
fs.readFile(config.build + '/' + bundle.model.filename, 'utf8', function (err, contents) {
262269

263270
externs.forEach((dep, i) => {
@@ -347,7 +354,7 @@ const compile = {
347354
let modulePath = filePath.substring(0, filePath.replace(/\\/g,"/").lastIndexOf('/'));
348355

349356
if (isVerbose) log('optimizing', bundle.filename);
350-
357+
351358
fs.readFile(filePath, 'utf8', function (err, contents) {
352359
if (!err) {
353360
let ngFactoryClassName = '';
@@ -363,7 +370,7 @@ const compile = {
363370

364371
let bun = {
365372
ngFactoryFile: fileName,
366-
ngFactoryClassName: ngFactoryClassName,
373+
ngFactoryClassName: bundle.className || ngFactoryClassName,
367374
fileName: fileName.replace('.js', '').replace('.ts', ''),
368375
filePath: filePath,
369376
fileContent: fs.readFileSync('./tmp/' + fileName.replace('.js', '').replace('.ts', '').concat('.MF'), 'utf-8').split('\n'),

0 commit comments

Comments
 (0)