There PRs in the CLI and the nativescript-dev-webpack:
tns run ios --bundle --release
.We basically want to extend this and have it for development builds. We need fast incremental web pack builds.
Problems:
TODO:
Resources:
https://github.com/angular/angular/tree/master/packages/compiler-cli
https://github.com/angular/angular/pull/18818
time ./node_modules/.bin/ngc -p tsconfig.aot.json
With tns-platform-declarations
:
NG codegen: 5881.254ms
NG downlevel: 690.687ms
TS I/O Read: 223ms
TS Parse: 10001ms
TS Program: 16555ms
TS I/O Write: 216ms
TS Bind: 8881ms
TS Check: 1164ms
TS transformTime: 590ms
TS printTime: 682ms
TS Emit: 1282ms
real 0m29.511s
user 0m30.300s
sys 0m1.217s
Without tns-platform-declarations
:
NG codegen: 5840.692ms
NG downlevel: 762.195ms
TS I/O Read: 118ms
TS Parse: 1745ms
TS Program: 3781ms
TS I/O Write: 215ms
TS Bind: 1116ms
TS Check: 1222ms
TS transformTime: 574ms
TS printTime: 654ms
TS Emit: 1238ms
real 0m13.376s
user 0m14.343s
sys 0m0.775s
DLL plugins:
https://robertknight.github.io/posts/webpack-dll-plugins/
https://webpack.js.org/plugins/dll-plugin/
Example for Angular with AOT and DLL and lots more:
https://github.com/qdouble/angular-webpack2-starter/blob/master/webpack.config.ts
It looks like compiling without the code generation (AoT) in web pack makes somewhere a web pack context that recursively includes all *.module.ts files generated by the angular compiler. However our loader tries to load using require here, we should probably check how to import the modules from the context for the "no-aot in web" story to work.
We can further use similar approach to import all "-page.xml" and "-page.css" files from app/ for vanilla NativeScript apps.
We'll target Angular 5 and the new AngularCompilerPlugin for webpack.
For incremental builds we can use https://github.com/webpack-contrib/cache-loader.
To use skipCodeGeneration: true, we will have to deal with module.id being a number instead of string in web packed modules. This seems to be solvable by using __filename (which web pack seems to replace with path relative to app) and then deal with the calculation of absolute path here
{N} CLI command webpack hook for development concerns:
After consulting with @Mitko-Kerezov, here is what we agreed:
Ok, so for development we will be targeting Angular 5 with the AngularCompilerPlugin and there are some changes that should happen, here is a list of some issues and how we are about to address them:
I'm not sure if we should provide update scripts. I think we should document the changes in the webpack configuration and release v1.0, because:
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Ok, so for development we will be targeting Angular 5 with the AngularCompilerPlugin and there are some changes that should happen, here is a list of some issues and how we are about to address them: