feature: added AOT compile support (#885)#1298
Conversation
|
wicked! |
|
Restart the build jobs one at a time. Travis often hangs with concurrent builds. |
|
@colinskow - I'll take a look at this in the morning. //cc @gdi2290 @katallaxie should also take a look |
|
FYI - I restarted both the travis builds |
joshwiens
left a comment
There was a problem hiding this comment.
To keep the naming consistent as well as explicit, I would rename tsconfig.webpack.json to tsconfig.aot.json
Outside of that, it functions as expected and I'm personally good with all the other changes.
Thanks for the note in the README as well. Solid Work :)
| - npm run server:prod:ci & | ||
| - sleep 3 | ||
| - npm run e2e | ||
| - npm run ci |
There was a problem hiding this comment.
I would also suggest running the two build / test steps individually.
1.) Most of us run multiple test containers, I always run my jit / aot validations in parallel.
2.) If is step is going to fail, it's probably going to be AoT, splitting them just means less log output to go dig through to find the failure.
There was a problem hiding this comment.
The complication in running the builds in parallel is that we need two different build directories and setup servers on two different ports to not cause conflicts. With this PR each step is an individual command and npm run ci simply composes them. I think parallel builds is a separate PR because it would take some work to setup.
Do you think the Travis builds would be more likely to pass the first time if I added a sleep 3 between starting the server and starting the test?
There was a problem hiding this comment.
Also, after I got AoT working I hit a hitch where Angular was crashing on startup with the JIT build, even though the build process didn't show errors. That's why it is important to test both for this repo's CI. Individual developers can use npm run ci:aot for lint, karma, and e2e test of AoT build.
There was a problem hiding this comment.
I personally use Circle but this should still be applicable ..
- I agree completely in regards to testing both builds, the point i was trying to make is to separate the two completely to allow the parallel execution. I have multiple containers available for any given build so my Jit & AoT validations run in parallel. Given it's a devops thing and most people aren't going to be running the vanilla Travis file for their projects, no need to have the build config hold up this PR.
If I want to fiddle with the Travis execution, i'll do it later. Far more important to get the AoT support in for those that have been asking for it.
- As far as the e2e tests go, I run a
sleep 5after I spin up the server. I've had problems with 2-3 second sleeps when it's build prime time on Travis or Circle.
There was a problem hiding this comment.
@d3viant0ne are you talking about Docker containers? If you can get the builds to test in parallel and create a script command that would be great.
.gitignore
Outdated
| /node_modules | ||
| /bower_components | ||
| npm-debug.log | ||
| yarn.lock |
There was a problem hiding this comment.
The yarn.lock is set in .gitattributes as a binary file and shouldn't be ignored. See notes in #1226
There was a problem hiding this comment.
OK, I will remove this.
|
@d3viant0ne Karma and other node libraries can't deal with es2015 modules and must use commonjs. That is why I forked the file. One for Webpack's internal use. The other for everything else. |
|
re: |
|
I've got another incoming commit on this PR to reduce bundle size and enable automatic tree shaking of the vendors bundle. |
|
The AoT build was including lots of unnecessary files so I added a commit which automatically extracts imports from I also added the Webpack Bundle Analyzer plugin and made it accessible by setting the command line flag |
|
eagerly waiting for this PR to be merged. |
katallaxie
left a comment
There was a problem hiding this comment.
I would recommend to have AoT as default of prod. That's the way to go in production. I am still not a fan of the @ngtools, but it seems to have it in webpack seems a nicer solution. I would also have the BundleAnalyzerPlugin removed. Webpack 2 in RC and beyond provides sufficient information. This seems to blow up the size of the boilerplate.
|
Awesome work, you should also add a script for: npm run start:aot. |
|
@katallaxie not all Angular apps are compatible with AoT so I wouldn't want to break people's builds by setting it as default. The idea is to add features without making breaking changes. As mentioned above @ngtools/webpack is still unstable and I wasn't able to get it to work with this repo. But when they work out the bugs it is the best way to go with Webpack. The BundleAnalyzerPlugin adds 5.5mb to dependencies that are already 320mb+. It is very useful for ensuring that the builds contain what we expect them to contain and is optional to use via a command line flag. |
|
@Phmager AoT is more for production builds. Since the NGC compiler is running separately from Webpack it may not play well with the dev server. The new vendor referencing logic is that anything from However its bad practice to have large CSS files inlined in the Javascript code, so my next step is a PR to setup a |
|
@katallaxie - AOT should not be the default for Given the commitment required to create a large application published AoT, this is a feature that should be off by default & opt in or it's going to break every production build this starter backs when they pick up the changes. |
|
I do on the other hand agree about @katallaxie's comment in regards to the BundleAnalyzerPlugin, It's trivial to add and would suggest this be transfered to Wiki instructions & not added to the seed directly ( it's big ). We get basic bundle analysis via Webpack RC, if people want all the bells & whistles they can add |
|
@colinskow I get your point. Though, I believe it should be considered best practice to have AoT and deviate from that. So, if you have an application, that for what ever reasons, doesn't work with AoT then you can disable it. But I would see it the other way around. As regarding to |
|
@d3viant0ne Because we had some deps fixed, we should take care of them now. We should also update |
joshwiens
left a comment
There was a problem hiding this comment.
Can you update webpack to 2.2.0-rc.2 and webpack-dev-server to 2.2.0-rc.0 then drop the bundle analyzer when you have a moment? I'll land this PR once the package.json changes are in.
|
do we wanna update readme because the vendor file is gone ? btw, why do we remove vendor entry point ? Because of tree shaking ? But there is actually not much change. The parsed size of new main (808.11k) ~= main (9.04k) + vendor (799.6k). |
not working: component level LESS files images hash in *.html, template or templateUrl see app.component.ts, home.component.html and home.component.css
| @@ -177,6 +178,17 @@ module.exports = function (options) { | |||
| * See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin | |||
| * See: https://github.com/webpack/docs/wiki/optimization#multi-page-app | |||
| */ | |||
There was a problem hiding this comment.
I don't get what this instance of CommonsChunkPlugin is supposed to do.. As far as I can tell, with this settings it won't do anything at all. @colinskow could you elaborate please?
* feature: added AOT compile support (PatrickJS#885) * updated travis.yml with new ci script * removed yarn.lock from .gitignore * (optimize) vendor tree shaking and bundle analysis tool * (fix) support node 5 * upgraded to webpack 2.2.0-rc-2, removed analyzer
|
This PR adds AoT support using the
ngccompiler.@ngtools/webpackstill has many flaws, but this setup is working perfectly.npm installand thennpm run cito fully test both AoT and JIT builds.noEmittypescript flag to prevent accidentally spamming compiled files into the projectResolves #885