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

Core: Fix webpack recursion in mainjs glob processing logic #11647

Merged
merged 2 commits into from
Jul 23, 2020
Merged

Core: Fix webpack recursion in mainjs glob processing logic #11647

merged 2 commits into from
Jul 23, 2020

Conversation

daniel-ac-martin
Copy link
Contributor

@daniel-ac-martin daniel-ac-martin commented Jul 22, 2020

../base-dir/*/index.stories.jsx will lead to glob being set to */index.stories.jsx and so glob.split('/').length = 2.

With the existing code the recursive flag would not be set and yet webpack will need to recurse into the directories in order to find any index.stories.jsx files that might exist within them.

Therefore, we should compare to 1 and not 2.

See: #11530 (comment)

`../base-dir/*/index.stories.jsx` will lead to `glob` being set to `*/index.stories.jsx` and so `glob.split('/').length` = 2.

With the existing code the `recursive` flag would _not_ be set and yet webpack will need to recurse into the directories in order to find any `index.stories.jsx` files that might exist within them.

Therefore, we should compare to 1 and not 2.

See: #11530 (comment)
@daniel-ac-martin
Copy link
Contributor Author

Unfortunately, the recursive flag is not covered by the unit tests and I'm not sure it could be covered in a meaningful way.

Adds some crude tests for when we expect to run webpack's
`require.context` in recursive mode.
@daniel-ac-martin
Copy link
Contributor Author

I had a think about this and I think it's possible to have some tests for this, even if they are quite crude test. So I've added that.

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! ❤️

@shilman shilman changed the title Core: toRequireContext: recurse in more cases Core: Fix webpack recursion in mainjs glob processing logic Jul 23, 2020
@shilman shilman merged commit 4af0d0d into storybookjs:next Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants