angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

NgFactory not generated when creating a bundle

Open rafiwardak2003 opened this issue 10 years ago • 5 comments

I am using Webpack 2 and it seems that a bundle is created and everything works fine. Why are there so many examples given where a factory is generated? Is that a must? Also, is it okay to use platformBrowserDynamic to load this bundle? I see examples where platformBrowser is used to load an ngFactory. Is that a must? I am doing this and it seems to work, but not sure the overhead:

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app'; platformBrowserDynamic() .bootstrapModule(AppModule)

rafiwardak2003 avatar Nov 17 '16 16:11 rafiwardak2003

The CLI translates the platform code from dynamic to AoT, and creates the factories, but this is all abstracted away from you.

If you want to see the factories (not the bootstrap transformation, no access to that), I guess you run something like ./node_modules/.bin/ngc -p ./src, but this is not how it's intended to be used. The CLI takes care of all that and you just get the result and not worry about intermediate steps or multiple bootstrapping files, etc.

Meligy avatar Nov 17 '16 23:11 Meligy

Okay I suspected that was the case. Thank you for confirming.

Should we be using platformBrowserDynamic or just platformBrowser to load my bundle generated?

rafiwardak2003 avatar Nov 18 '16 00:11 rafiwardak2003

Whatever ng new ... generates I guess?

Unless you are suggesting the template needs updating...

Meligy avatar Nov 18 '16 05:11 Meligy

The Factories are generated in memory; you won't find them on your disk. Tutorials uses the ngc command line which generates factories on the disk.

hansl avatar Dec 08 '16 22:12 hansl

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.