question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[6.2.0-beta.1] Angular library not rendering without calling ngcc

See original GitHub issue

Hi iam testing the new angular inline feature (https://github.com/storybookjs/storybook/pull/13525) in our component library (Angular 10).

Sadly this is a private project and i cannot share any source files.

The library is a part of an monorepository and we build the library separate. Afterwards we are linking the library dist-folder to the storybook project.

In the current alpha release (6.2.0-alpha.29) I have to compile the dist-folder with the ngcc compiler after each build, otherwise i get the following error message: zone.js:690 Unhandled Promise rejection: Cannot read property 'id' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'id' of undefined at registerNgModuleType (core.umd.js:24829) at core.umd.js:24840 at Array.forEach (<anonymous>) at registerNgModuleType (core.umd.js:24840) at new NgModuleFactory (core.umd.js:24936) at compileNgModuleFactory__POST_R3__ (core.umd.js:28472) at PlatformRef.push../node_modules/@angular/core/bundles/core.umd.js.PlatformRef.bootstrapModule (core.umd.js:28716) at ElementRendererService.<anonymous> (ElementRendererService.js:89) at step (ElementRendererService.js:53) at Object.next (ElementRendererService.js:34) TypeError: Cannot read property 'id' of undefined at registerNgModuleType (http://localhost:6006/vendors~main.331aca382febe703f812.bundle.js:76527:31) at http://localhost:6006/vendors~main.331aca382febe703f812.bundle.js:76538:51 at Array.forEach (<anonymous>) at registerNgModuleType (http://localhost:6006/vendors~main.331aca382febe703f812.bundle.js:76538:21) at new NgModuleFactory (http://localhost:6006/vendors~main.331aca382febe703f812.bundle.js:76634:17) at compileNgModuleFactory__POST_R3__ (http://localhost:6006/vendors~main.331aca382febe703f812.bundle.js:80170:29) at PlatformRef.push../node_modules/@angular/core/bundles/core.umd.js.PlatformRef.bootstrapModule (http://localhost:6006/vendors~main.331aca382febe703f812.bundle.js:80414:20) at ElementRendererService.<anonymous> (http://localhost:6006/vendors~main.331aca382febe703f812.bundle.js:140803:26) at step (http://localhost:6006/vendors~main.331aca382febe703f812.bundle.js:140767:23) at Object.next (http://localhost:6006/vendors~main.331aca382febe703f812.bundle.js:140748:53)

Example storybook:

import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {
  ArgsTable,
  Description,
  Primary,
  PRIMARY_STORY,
  Stories,
  Subtitle,
  Title,
} from '@storybook/addon-docs/blocks';
import { Meta, moduleMetadata, Story } from '@storybook/angular';
import { MyCompoennt, MyLibraryModule } from 'dist/my-project';
import React from 'react';

export default {
  title: 'Navigation/MyComponent',
  component: MyCompoennt,
  decorators: [
    moduleMetadata({
      declarations: [],
      imports: [MyLibraryModule, BrowserAnimationsModule],
      schemas: [CUSTOM_ELEMENTS_SCHEMA],
    }),
  ],
  parameters: {
    docs: {
      page: () => (
        <>
          <Title />
          <Subtitle />
          <Description />
          <Primary />
          <ArgsTable story={PRIMARY_STORY} />
          <Stories />
        </>
      ),
    },
  },
} as Meta;

const Template: Story = (args) => {
  return {
    props: args,
  };
};

export const Default = Template.bind({});
Default.args = {
  items: ['Item1', 'Item2', 'Item3', 'Item4', 'Item5'],
};

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
daniellerouxcommented, Feb 23, 2021

Okay than i will Update my GitHub example tomorrow.

But in our production environment we have 6.2.0-Alpha.29 and can reproduce the problem.

Maybe it’s a other Problem than the inline feature ?

0reactions
ThibaudAVcommented, Mar 4, 2021

@danielleroux Ok thanks for the workaround. I think it might help other people if they have the same problem 🙂 .

Storybook is on its way to working with ivy 🤞 (I hope this will solve this problem )🤞

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upcoming improvements to Angular library distribution
Upcoming improvements to Angular library distribution. TLDR; In v12, we'll deprecate our legacy compilation and rendering pipeline called View ...
Read more >
Heroku-postbuild error when deploying nodejs and angular to ...
I have a app that is currently deployed on heroku and working ... on the previous instance I have on heroku but wont...
Read more >
inject() must be called from an injection context at ... - You.com
Solution: use projects.$name.architect.build.options.preserveSymlinks: true in the angular.json file of the client project, not the library. Further information ...
Read more >
The Angular Ivy guide for library authors - DEV Community ‍ ‍
The Ivy Instruction Set which is the compilation output in directive and component rendering functions will not be finalised before Angular ...
Read more >
The Angular linker (goodbye ngcc!) - Ninja Squad
Even using Angular CLI v11.1, the library is configured to be built with View Engine and not Ivy! That might seem strange, but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found