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

"Couldn't find any stories in your Storybook." after upgrade to 6.4.9 #17038

Closed
Domiii opened this issue Dec 18, 2021 · 5 comments
Closed

"Couldn't find any stories in your Storybook." after upgrade to 6.4.9 #17038

Domiii opened this issue Dec 18, 2021 · 5 comments
Assignees

Comments

@Domiii
Copy link

Domiii commented Dec 18, 2021

Describe the bug

This worked before, but now complains it cannot find any stories anymore:

{
  stories: [
    // stories folder: ignore 'components/', `data/`, `*.Template.js` files; `.stories` suffix is optional.
    `../packages/theproject-*/**/stories!(/components|/data|.*Template.js)/*?(.stories).js`,

    // src folder: `.stories` files
    `../packages/theproject-*/src/**/*.stories.js`,

    // only get the index file for nested story folders
    `../packages/theproject-*/src/**/stories/index.js`,
  ]
}

I tried simplifying, and this still does not find anything:

{
  stories: ['../packages/theproject-*/src/**/stories/index.js']
}

Explicit paths without any wildcards work though:

{
  stories: ['C:/Users/me/code/repo/packages/theproject-frontend-common/src/features/table/stories/index.js']
}

System

Environment Info:

  System:
    OS: Windows 10 10.0.19042
    CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
  Binaries:
    Node: 16.13.0 - ~\AppData\Local\Volta\tools\image\node\16.13.0\node.EXE
    Yarn: 1.22.17 - ~\AppData\Local\Volta\tools\image\yarn\1.22.17\bin\yarn.CMD
    npm: 8.1.0 - ~\AppData\Local\Volta\tools\image\node\16.13.0\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (96.0.1054.57)
  npmPackages:
    @storybook/addon-actions: ^6.4.9 => 6.4.9
    @storybook/addon-essentials: ^6.4.9 => 6.4.9
    @storybook/addon-links: ^6.4.9 => 6.4.9
    @storybook/addon-postcss: ^2.0.0 => 2.0.0
    @storybook/builder-webpack5: ^6.4.9 => 6.4.9
    @storybook/manager-webpack5: ^6.4.9 => 6.4.9
    @storybook/react: ^6.4.9 => 6.4.9

Additional context

I realized that the context builder code has changed a lot since the last version.

The final require string of the pattern looks like this:

 "use strict";

var _frameworkImportPath = require("@storybook/react");

/* eslint-disable import/no-unresolved */
(0, _frameworkImportPath.configure)([require.context('./packages', false, /^\.[\\/](?:theproject-[^\\/]*?[\\/]src(?:[\\/](?!\.)(?:(?:(?!(?:^|[\\/])\.).)*?)[\\/]|[\\/]|$)stories[\\/]index\.js)$/)], module, false);

It looks like recursive = false seems wrong here.

Update

I did some more experimentations and I found the recursive flag is indeed incorrect and makes zero sense. This worked fine before, so not sure what you changed, but it certainly messes with the stories globs.

This works:

{
  stories: ['../packages/theproject-frontend-common/src/features/**/stories/index.js']
}

In @storybook/core-common/dist/cjs/utils/to-require-context.js it now becomes:

 {
  "path": "./packages/theproject-frontend-common/src/features",
  "files": "**/stories/index.js",
  "recursive": true,
  "match": {}
}

Conclusion

This worked before, but since latest update does not anymore -

'a-*/b/**/c'

However, this still works:

'a/b/**/c'

=> Since the upgrade, a double-star glob must always be the first, apparently. (But I'm not sure. I have not spent more time to find out, where it breaks off pattern and directory.)

This regression might not be intended, or maybe it is. Either way, it SHOULD be mentioned in the migration guide.

Workaround

const packages = [
  // ...
];

function s(pattern) {
  return packages.map(p => `../packages/${p}/${pattern}`);
}

module.exports = {
  stories: [
    // stories folder: ignore 'components/', `data/`, `*.Template.js` files; `.stories` suffix is optional.
    s(`stories!(/components|/data|.*Template.js)/*?(.stories).${exts}`),

    // src folder: `.stories` files
    s(`src/**/*.stories.${exts}`),

    // only get the index file for nested story folders
    s(`src/**/stories/index.${exts}`)
  ].flat()
};
@stale
Copy link

stale bot commented Jan 9, 2022

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Jan 9, 2022
@Domiii
Copy link
Author

Domiii commented Jan 9, 2022

Still a regression/bug

@tmeasday
Copy link
Member

tmeasday commented Jan 17, 2022

Apologies about the delay here, you were quite right about the recursive flag: #17252

@shilman
Copy link
Member

shilman commented Jan 17, 2022

¡Ay Caramba!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.5.0-alpha.19 containing PR #17252 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Jan 17, 2022
@shilman
Copy link
Member

shilman commented Jan 21, 2022

Yippee!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.14 containing PR #17252 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb upgrade

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

3 participants