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(upgrade): fix HMR for hybrid applications #40045

Closed
wants to merge 5 commits into from

Commits on Dec 10, 2020

  1. refactor(upgrade): remove unused variables

    This commit removes a couple of unused variables.
    gkalpak committed Dec 10, 2020
    Copy the full SHA
    c1f5f66 View commit details
    Browse the repository at this point in the history
  2. refactor(upgrade): create a helper for cleaning jqLite/jQuery data

    This commit moves the code for cleaning jqLite/jQuery data on an element
    to a re-usable helper function. This way it is easier to keep the code
    consistent across all places where we need to clean data (now and in the
    future).
    gkalpak committed Dec 10, 2020
    Copy the full SHA
    8ff6319 View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    e80c8f5 View commit details
    Browse the repository at this point in the history
  4. fix(upgrade): fix HMR for hybrid applications

    Previously, trying to apply a change via Hot Module Replacement (HMR) in
    a hybrid app would result in an error. This was caused by not having the
    AngularJS app destroyed and thus trying to bootstrap an AngularJS app on
    the same element twice.
    
    This commit fixes HMR for hybrid apps by ensuring the AngularJS app is
    destroyed when the Angular `PlatformRef` is [destroyed][1] in the
    [`module.hot.dispose()` callback][2].
    
    NOTE:
    For "ngUpgradeLite" apps (i.e. those using `downgradeModule()`), HMR
    will only work if the downgraded module has been bootstrapped and there
    is at least one Angular component present on the page. The is due to a
    combination of two facts:
    - The logic for setting up the listener that destroys the AngularJS app
      depends on the downgraded module's `NgModuleRef`, which is only
      available after the module has been bootstrapped.
    - The [HMR dispose logic][3] depends on having an Angular element
      (identified by the auto-geenrated `ng-version` attribute) present in
      the DOM in order to retrieve the Angular `PlatformRef`.
    
    [1]:
    https://github.com/angular/angular-cli/blob/205ea2b638f154291993bfd9e065cd66ff20503/packages/angular_devkit/build_angular/src/webpack/plugins/hmr/hmr-accept.ts#L75
    [2]:
    https://github.com/angular/angular-cli/blob/205ea2b638f154291993bfd9e065cd66ff205033/packages/angular_devkit/build_angular/src/webpack/plugins/hmr/hmr-accept.ts#L31
    [3]:
    https://github.com/angular/angular-cli/blob/205ea2b638f154291993bfd9e065cd66ff205033/packages/angular_devkit/build_angular/src/webpack/plugins/hmr/hmr-accept.ts#L116
    
    Fixes angular#39935
    gkalpak committed Dec 10, 2020
    Copy the full SHA
    43e994d View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    885710a View commit details
    Browse the repository at this point in the history