Skip to content

Commit

Permalink
Merge pull request #14649 from storybookjs/angular-support-for-addon-ivy
Browse files Browse the repository at this point in the history
Angular: Support Ivy addon
  • Loading branch information
shilman committed Apr 19, 2021
2 parents ab89248 + bb0856e commit 3afa7f4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/angular/src/client/preview/angular-beta/RendererService.ts
Expand Up @@ -80,6 +80,25 @@ export class RendererService {
return;
}

try {
// Clear global Angular component cache in order to be able to re-render the same component across multiple stories
//
// References:
// https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/build_angular/src/webpack/plugins/hmr/hmr-accept.ts#L50
// https://github.com/angular/angular/blob/2ebe2bcb2fe19bf672316b05f15241fd7fd40803/packages/core/src/render3/jit/module.ts#L377-L384
// eslint-disable-next-line global-require
const resetCompiledComponents = require('@angular/core').ɵresetCompiledComponents;
resetCompiledComponents();
} catch (e) {
/**
* noop catch
* This means angular removed or modified ɵresetCompiledComponents
*
* Probably, they added a clearCache mechanism to platform.destroy() and
* we can simply remove this in case no errors are thrown during runtime
*/
}

// Complete last BehaviorSubject and set a new one for the current module
if (this.storyProps$) {
this.storyProps$.complete();
Expand Down

0 comments on commit 3afa7f4

Please sign in to comment.