giscafer / blog

Next.js + Issues 博客解决方案 https://www.giscafer.com
https://www.giscafer.com
MIT License
280 stars 49 forks source link

Angular AOT构建优化与后端渲染 #13

Open giscafer opened 7 years ago

giscafer commented 7 years ago

AOT 编译

相关文章

如何评价 angular 2 中的 AoT?

Angular 预编译(AOT)

预 (AOT) 编译器

JIT: Just-in-Time Compiler AOT:Ahead-of-Time Compiler

Issues

Cannot determine the module for class ImComponent

解决方案

ERROR in main.19f09357128c495bb8e8.bundle.js from UglifyJs Unexpected token: name (Wrapper_RouterOutlet) [main.19f09357128c495bb8e8.bundle.js:15,6]

构建如果报错JavaScript heap out of memory

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 00000319856CFB61 <JS Object>
    1: DoJoin(aka DoJoin) [native array.js:~129] [pc=00000258C3E9F96F] (this=0000031985604381 <undefined>,w=0000012E5C1B5271 <JS Array[688]>,x=688,N=00000319856043C1 <true>,J=0000031985604411 <String[0]: >,I=00000319856B46F1 <JS Function ConvertToString (SharedFunctionInfo 0000031985652DC9)>)
    2: Join(aka Join) [native array.js:180] [pc=00000258C330EE12] (this=0000031985604381 <undefined>,...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

https://github.com/angular/angular/issues/12184

package.json设置node内存后执行 "build-aot": "node --max_old_space_size=2192 node_modules/@angular/cli/bin/ng build --aot --prod"

AngularUniversal 后端模板渲染

AngularUniversal : https://universal.angular.io/

相关文章

http://www.jianshu.com/p/81e8472376cc#

http://www.jianshu.com/p/304bb0728e7c

giscafer commented 7 years ago

AOT 打包文件hash值相关问题

Unique identifier ng build --prod

https://github.com/angular/angular-cli/issues/9165

如果以上问题解决不了你的方案,可以自己动态在'[name].bundle.js?[hash]文件后加hash版本号。

写了个node脚本在打包后正则匹配替换dist/index.html

gist code: https://gist.github.com/giscafer/72b9c73493daa13fefb5f26243c63f07