Skip to content

Lazy load and AOT : Working but splitted chunk ONLY WITH AOT FLAG #3267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maxime1992 opened this issue Nov 24, 2016 · 7 comments
Closed

Lazy load and AOT : Working but splitted chunk ONLY WITH AOT FLAG #3267

maxime1992 opened this issue Nov 24, 2016 · 7 comments
Labels
needs: repro steps We cannot reproduce the issue with the information given

Comments

@maxime1992
Copy link
Contributor

Please provide us with the following information:

OS?

Ubuntu 16.10 (x64)

Versions.

angular-cli: 1.0.0-beta.21

Repro steps.

After I read more about lazy load + AOT on this issue, I decided to give a try and it's working really nice for the first time in my app.

So I decided to have some fun and benchmark different results. Here's the ouput :

+-----------------------+-------------+--------------+-----------+-------------+
|                       | Main bundle |   Chunk 0    | Scripting | First paint |
+-----------------------+-------------+--------------+-----------+-------------+
| ng serve              | 4.5 MB      | Not splitted | 6075 ms   | 5500+ ms    |
| ng serve --prod       | 334 KB      | Not splitted | 5587 ms   | 4750+ ms    |
| ng serve --aot        | 3.3 MB      | 326 KB       | 4011 ms   | 4400+ ms    |
| ng serve --prod --aot | 243 KB      | 18.1 Kb      | 3860 ms   | 4250+ ms    |
+-----------------------+-------------+--------------+-----------+-------------+
  • The --prod --aot build size is 27% smaller than --prod build
  • The --prod --aot build is 31% faster when scripting than --prod build
  • AOT is cool !

BUT

As you can see, ng serve and ng serve --prod doesn't have the chunk expected and I'm able to find the code (that's supposed to be in the chunk) inside the main bundle. With aot flag, I always have both the main bundle and my chunk.

Even tho it's working, devs who want to put their app in prod without building with --aot will not enjoy the lazy loading they've setup ;)

@NgxDev
Copy link

NgxDev commented Nov 24, 2016

It works fine on my end (here: https://github.com/MrCroft/lazy)
Plus I already had a bigger app and updated the cli from beta.20-4 to beta.21, and ng build --prod or ng serve --prod both work as before (separate chunks get created for each lazy module).
Make sure you're using angular 2.2.1 (they've locked the version to that I see, in the latest CLI release).
Ultimately, if the app wasn't initially generated with beta.21, remove node_modules folder entirely and do an ng init, check the file differences.

@intellix
Copy link
Contributor

Also noticed this. I have a 3.2mb main bundle only now

@filipesilva
Copy link
Contributor

That's definitely odd. You should always have the lazy loaded chunks.

Does this still happen with the latest versions? If so, can you get me a repro I can debug?

@filipesilva filipesilva added the needs: repro steps We cannot reproduce the issue with the information given label Dec 29, 2016
@intellix
Copy link
Contributor

Not happening for me anymore with the latest stuff (b24)

@maxime1992
Copy link
Contributor Author

I've got many errors since beta 24 which make me stay on beta 22.
(for example : No module factory available for dependency type: ContextElementDependency).
When I manage to make my project works with beta 24 I'll let you know about the lazy loading problem. :)

@filipesilva
Copy link
Contributor

Dupe of #2496 (I think), fixed in #3079.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests

4 participants