Skip to content

Enable chunk optimizer for SSR apps #33438

Description

@jsaguet

Command

build

Description

Building an SSR application in Angular 22 produces a huge amount of chunks. It is a "regression" compared to Angular 21.
This is currently a blocker for us to migrate to Angular 22.

But according to the code, it's not a bug.
It is intentionally disabled for SSR applications as stated in this todo:

// TODO: Remove this log once chunk optimization is supported for server builds as this
// causes the file to be renamed and thus causes incorrect preloading.
if (!options.serverEntryPoint && lazyChunksCount >= optimizeChunksThreshold) {

This code was added in e9a4fb1

I've tested my app by removing this guard and it seems to work.
I also have a branch where I added a few tests to try to find what would break but they all seem to pass too.

So I haven't figured out what part of the preloading story is broken with chunk optimization but I would be happy to help if I can.

Describe the solution you'd like

Chunk optimizer should be enabled for SSR applications.

Describe alternatives you've considered

I don't think we can workaround that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions