Angular 2 rc 6
, typescript 2
, node 4.5.0
, npm 2.15.9
running on Windows 7
I am in the process of transitioning from Just-in-Time compilation to Ahead-of-Time compilation and I am utilizing the following resources:
- Angular 2 - Ahead-of-time compilation how to
- Github link for Angular template compiler
I have grasped the concept that I need to execute the compiler ngc
to create ngfactory.ts
files, as well as modify main.ts
to utilize platformBrowser
instead of platformBrowserDynamic
for bootstrapping. However, I have encountered an obstacle and require guidance on the next steps.
1. I have verified that the application functions without errors using Just-in-Time compilation. My current main.ts
code is:
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
2. I have removed all application files from my production directory but retained third-party libraries (e.g., Angular 2, Angular 2 Material)
3. Upon executing "node_modules/.bin/ngc" -p ./
, there is no output displayed in the console. Each of my components and modules now has an associated .ngfactory.ts
file, along with a .css.shim.ts
file for component styles. Furthermore, transpiled .js
and .js.map
files are present in the production directory as well
4. When attempting to run the application at this stage, I encounter 404 not found
errors for all the component templates stored in .html
files
5. To address this issue, I manually relocate all template files (.html
) to the production directory and launch the application successfully. However, it continues to use Just-in-Time compilation (255 requests, including compiler.umd.js
)
6. I update my main.ts
to:
enableProdMode();
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
Despite making this adjustment, there is no noticeable impact since the new code has not been compiled. Consequently, I am unsure of the subsequent steps to take.
Should I re-run ngc
? If so, I encounter multiple errors similar to:
Error at C:/path/to/notify.component.ngfactory.ts:113:41: Property 'visible' is private and only accessible within class 'NotifyComponent'
... (numerous such occurrences featuring various properties from different components)
Compilation failed
Is it necessary to make all class properties public when utilizing AoT compilation? Am I overlooking a crucial step?