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

RegExp for builder webpack5 for storybook not recognized properly #9290

Closed
creaux opened this issue Mar 11, 2022 · 3 comments · Fixed by #10662
Closed

RegExp for builder webpack5 for storybook not recognized properly #9290

creaux opened this issue Mar 11, 2022 · 3 comments · Fixed by #10662
Labels
outdated scope: storybook Issues related to Storybook support in Nx type: enhancement

Comments

@creaux
Copy link

creaux commented Mar 11, 2022

As soon as storybook configuration is structured by modules.

.
└── .storybook/
    ├── main.ts
    └── configuration/
        ├── index.ts
        └── core.config.ts

Where .storybook/configuration/core.config.ts could be like follows:

...
export const core: CoreConfig = { builder: 'webpack5' };
...

And .storybook/configuration/index.ts

import { core } from './core.config';
...
export const configuration: StorybookConfig = {
  core,
  ...
}

And .storybook/main.ts therefore:

import { configuration } from './configuration';

module.exports = configuration

The it doesn't work as following line is raw file reader and regexp.

!storybookConfig.match(/builder: ('webpack5'|"webpack5"|`webpack5`)/g)

Workaround is to put core property directly in main.ts. But I think it shiould work in better way.

@creaux creaux changed the title RegExp for builder webpack5 not recognized properly RegExp for builder webpack5 for storybook not recognized properly Mar 11, 2022
@mandarini mandarini added type: enhancement scope: storybook Issues related to Storybook support in Nx labels Mar 11, 2022
@mandarini
Copy link
Member

Hi there @creaux ! Thanks for filing an issue! I am going to mark this as an enhancement. Although I understand the issues that this may cause to your setup, I still believe it's sort of a niche use-case. We are relying on a regex to determine the builder, as this seems to be the most efficient way to do it, since the Storybook configuration uses that syntax (builder: 'webpack5') to set the builder. We could potentially look at the imports into main.ts and then at the imports of the imports and so on, and look into every one of these files to see if there's a builder: 'webpack5', but I think this would not be very efficient. With the Nx plugins we are trying to cover all the use cases, if that's possible, and where this is not possible, we are at least trying to cover most use cases. Since this has an easy workaround, and the workaround is actually the most common syntax, then I think it makes sense to leave it aside for the time being.

That said, if you come up with a better/more efficient way to do this, let me know, and I can help you implement this, as a contribution! :) Thank you, again, very much for submitting this issue! :)

@mandarini
Copy link
Member

Linking this here. I'll fix this soon!

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: storybook Issues related to Storybook support in Nx type: enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants