Skip to content
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

ngcc - use inner/outer class names as appropriate #33533

Closed

Commits on Nov 2, 2019

  1. refactor(ivy): split type into type, internalType and `adjacent…

    …Type`
    
    When compiling an Angular decorator (e.g. Directive), @angular/compiler
    generates an 'expression' to be added as a static definition field
    on the class, a 'type' which will be added for that field to the .d.ts
    file, and a statement adjacent to the class that calls `setClassMetadata()`.
    
    Previously, the same WrappedNodeExpr of the class' ts.Identifier was used
    within each of this situations.
    
    In the ngtsc case, this is proper. In the ngcc case, if the class being
    compiled is within an ES5 IIFE, the outer name of the class may have
    changed. Thus, the class has both an inner and outer name. The outer name
    should continue to be used elsewhere in the compiler and in 'type'.
    
    The 'expression' will live within the IIFE, the `internalType` should be used.
    The adjacent statement will also live within the IIFE, the `adjacentType` should be used.
    
    This commit introduces `ReflectionHost.getInternalNameOfClass()` and
    `ReflectionHost.getAdjacentNameOfClass()`, which the compiler can use to
    query for the correct name to use.
    alxhub authored and petebacondarwin committed Nov 2, 2019
    Copy the full SHA
    8a6238d View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    539c38c View commit details
    Browse the repository at this point in the history
  3. fix(ngcc): override getInternalNameOfClass() and `getAdjacentNameOf…

    …Class()` for ES5
    
    In ES5 the class consists of an outer variable declaration that is
    initialised by an IIFE. Inside the IIFE the class is implemented by
    an inner function declaration that is returned from the IIFE.
    This inner declaration may have a different name to the outer
    declaration.
    
    This commit overrides `getInternalNameOfClass()` and
    `getAdjacentNameOfClass()` in `Esm5ReflectionHost` with methods that
    can find the correct inner declaration name identifier.
    petebacondarwin committed Nov 2, 2019
    Copy the full SHA
    abfc920 View commit details
    Browse the repository at this point in the history
  4. fix(ngcc): render new definitions using the inner name of the class

    When decorating classes with ivy definitions (e.g. `ɵfac` or `ɵdir`)
    the inner name of the class declaration must be used.
    
    This is because in ES5 the definitions are inside the class's IIFE
    where the outer declaration has not yet been initialized.
    petebacondarwin committed Nov 2, 2019
    Copy the full SHA
    64d5f04 View commit details
    Browse the repository at this point in the history