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

fix(ivy): move setClassMetadata calls into a pure iife #33337

Closed

Commits on Nov 20, 2019

  1. fix(ivy): move setClassMetadata calls into a pure iife

    This commit transforms the setClassMetadata calls generated by ngtsc from:
    
    ```typescript
    /*@__PURE__*/ setClassMetadata(...);
    ```
    
    to:
    
    ```typescript
    /*@__PURE__*/ (function() {
      setClassMetadata(...);
    })();
    ```
    
    Without the IIFE, terser won't remove these function calls because the
    function calls have arguments that themselves are function calls or other
    impure expressions. In order to make the whole block be DCE-ed by terser,
    we wrap it into IIFE and mark the IIFE as pure.
    
    It should be noted that this change doesn't have any impact on CLI* with
    build-optimizer, which removes the whole setClassMetadata block within
    the webpack loader, so terser or webpack itself don't get to see it at
    all. This is done to prevent cross-chunk retention issues caused by
    webpack's internal module registry.
    
    * actually we do expect a short-term size regression while
    angular/angular-cli#16228
    is merged and released in the next rc of the CLI. But long term this
    change does nothing to CLI + build-optimizer configuration and is done
    primarly to correct the seemingly correct but non-function PURE annotation
    that builds not using build-optimizer could rely on.
    alxhub committed Nov 20, 2019
    Configuration menu
    Copy the full SHA
    559b341 View commit details
    Browse the repository at this point in the history