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

[Bug]: Indexers are 'first-come, first served' for each RegExp match #29135

Open
LazerFX opened this issue Sep 16, 2024 · 0 comments
Open

[Bug]: Indexers are 'first-come, first served' for each RegExp match #29135

LazerFX opened this issue Sep 16, 2024 · 0 comments

Comments

@LazerFX
Copy link

LazerFX commented Sep 16, 2024

Describe the bug

I attempted to create a new indexer with the RegExp match \.amlstories.ts$?\ and couldn't understand why it was not working. It took quite some debugging and referencing existing indexers to realise that the indexer array is first-come, first-served for the regex match. After changing the RegExp to \.aml.ts%?\, the indexer matched the file type and ran normally.

I see two solutions - the easiest is to simply document this fact. It shouldn't be hard to keep story or stories out of the matched filename, though instinct does indicate that you write that. Alternatively, a combinatorial approach would allow you to have a different render for each indexer, and combine them together. I don't mind, I just wanted this to be documented for anyone else who hits this (admittedly trivial) issue in the future :)

Reproduction link

https://stackblitz.com/~/github.com/LazerFX/storybook-indexer-bug

Reproduction steps

  1. Add a custom_indexer with the test matching the same as the default indexer (i.e. anything ending story or stories).

I expected the indexer to be 'added' or 'merged' with the existing one, so that regular stories would be indexed, as well as new ones. Instead, the existing indexer was ran, and the new indexer wasn't even triggered (Which led to a lot of head scratching to figure out why the test was failing - it wasn't, strictly speaking, it was just never ran as the first indexer to satisfy the result was used).

System

Storybook Environment Info:

  System:
    OS: Windows 11 10.0.22631
    CPU: (14) x64 Intel(R) Core(TM) Ultra 5 135U
  Binaries:
    Node: 20.17.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD <----- active
  Browsers:
    Edge: Chromium (127.0.2651.86)

Additional context

No response

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

1 participant