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

Angular component get redeclared - that is regression compared to legacy Angular renderer (specific casees) #15590

Closed
kbrilla opened this issue Jul 14, 2021 · 7 comments

Comments

@kbrilla
Copy link

kbrilla commented Jul 14, 2021

Describe the bug
Angular component get redeclared - that is regression compared to legacy Angular renderer (specific cases)

To Reproduce
for example:
/// button.module.ts

@NgModule({
  declarations: [
  ButtonComponent,
  imports: [CommonModule],
  exports: [ButtonComponent],
})
export class ButtonModule {}
export default {
  title: 'Components/Core/Button',
  component: ButtonComponent,
  decorators: [
    moduleMetadata({
      declarations: [],
      imports: [
[ButtonModule]],
    }),
  ],
} as Meta;

const Overview: Story<ButtonComponent> = (args) => ({
  props: args,
  template: `
<button loButton [variant]="variant" [size]="size" type="button" >
Button
</button>
</div>
`,
});

System
Storybook 6.3.4

Additional context
This is regression:
#6346
21e4997#diff-87c2ba58c37542c29b4838493e7f8bcdd62b593851e30671fd1bb081eb39530f

legacy helper has function that checks if component needs to be declared:

const extractNgModuleMetadata = (importItem: any): NgModule => {

it exists in new renderer but with a bit limited functionality
const extractNgModuleMetadata = (importItem: any): NgModule => {

Other issues that were raised that actually are caused by this:
#14026

//edit

Ok so regression is smaller than I originally though
what is not working compared to old version of extractNgModuleMetadata is that when imports array has an item that is an array it is not flat mapped to pick up a imports from [] item;

weird thing is that extractNgModuleMetadata the same so mayby it is problem in another function higer up in call chain.

probably also something to do with having template or not as they are handled differently in both cases

const componentRequiresDeclaration =

@kbrilla kbrilla changed the title Angular component get redeclared - that is regression compared to legacy Angular renderer Angular component get redeclared - that is regression compared to legacy Angular renderer (specific casees) Jul 14, 2021
@parkersweb
Copy link

Is there any news on this one? We're seeing it cause a number of headaches in rendering stories using the docs add-on that makes it basically unusable at the moment...

@shilman shilman added the angular label Jan 7, 2022
@shilman
Copy link
Member

shilman commented Jan 7, 2022

@storybookjs/angular any thoughts on this one?

@shilman
Copy link
Member

shilman commented Jan 7, 2022

@parkersweb is using the legacy renderer an acceptable workaround until this gets sorted out?

@parkersweb
Copy link

@shilman yeah - I think I've found a pattern that gets me around the problem for now thanks 👍

@sir-captainmorgan21
Copy link

@parkersweb what workaround did you use?

@parkersweb
Copy link

@sir-captainmorgan21 I'm afraid its been a while since I looked in on the project that uses this so I don't recall exactly which change got us working.

We're currently running 6.4.19 - without the angular legacy renderer flag set. Our story meta looks something like this

<Meta
  title="Components/Avatar"
  component={AvatarComponent}
  decorators={[
    moduleMetadata({
      imports: [AvatarModule],
    }),
  ]}
/>

and that doesn't seem to cause issues? Sorry I couldn't be more helpful!

@shilman
Copy link
Member

shilman commented Jun 8, 2023

We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid. Please open a new issue referencing this one if:

@shilman shilman closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants