Skip to content

@defer blocks emit no dynamic import() — deferred deps are statically bundled #289

Description

@brandonroberts

@defer blocks compile without a dependency-resolver function. Deferred components stay as static top-level imports — the block defers rendering but does zero code-splitting.

Repro

import { Component } from '@angular/core';
import { LazyCmp } from './lazy';
@Component({ selector: 'app-parent', imports: [LazyCmp], template: '@defer { <app-lazy/> }' })
export class Parent {}

Actual

LazyCmp kept as a static import; ɵɵdefer(1, 0) receives no dependency-resolver argument; no import('./lazy') anywhere.

Expected

Angular emits a deferred dependency function — () => [import('./lazy').then(m => m.LazyCmp)] — wired into ɵɵdefer, so the chunk is code-split. Aliased imports must use the original export name (m.HeavyWidget, not the local alias); default imports use m.default.

Impact

@defer provides no bundle benefit — its entire purpose. Renders correctly, but a headline Angular feature is silently inert.


Researched and drafted with Claude Code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions