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

Docs: Fix issue with referencing non-story files with names similar or equal to docs files #21348

Merged
merged 6 commits into from Mar 3, 2023

Conversation

tmeasday
Copy link
Member

@tmeasday tmeasday commented Mar 2, 2023

Closes #20958

A MDX file can reference a component or other non-story file with the same prefix as an MDX file, which leads to a matching entry in the cache but that entry will not have been processed yet. That's OK, we just assume that import is not a story file (rather than throwing).

  • Match file names a little more strictly
  • Just continue if we find a matching non-story entry (like we never found it).

How to test

See test cases and example from issue.

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • If this PR should be tested against many or all sandboxes,
    make sure to add the ci:merged or ci:daily GH label to it.
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

A MDX file can reference a component or other non-story file with the same prefix as an MDX file, which leads to a matching entry in the cache but that entry will not have been processed yet. That's OK, we just assume that import is not a story file (rather than throwing).
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.

Kind of confusing, but I guess it's OK.

Is there anything that the throw new Error was protecting us against that we are no longer protected from? Is there some other way to handle that case?

@tmeasday
Copy link
Member Author

tmeasday commented Mar 2, 2023

Yeah, I guess the code path is pretty weird, it's like:

  1. Input all RHS of import lines in the MDX file
  2. Search for all known entries that could be those imports
  3. Then search over them for any that are stories.

I'm not quite sure why there are two loops. I'll refactor.

@tmeasday
Copy link
Member Author

tmeasday commented Mar 2, 2023

And, no, I don't think it was protecting us from anything. It was a "if this is missing something weird is going on" type throw, not a "we expect this to fail in certain circumstances".

@shilman
Copy link
Member

shilman commented Mar 2, 2023

@tmeasday looks like your refactor broke something in CI

@tmeasday tmeasday added the ci:pr label Mar 3, 2023
@shilman shilman merged commit 916873b into next Mar 3, 2023
@shilman shilman deleted the 20958-fix-indexing-errors-referencing-non-stories branch March 3, 2023 03:56
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.

[Bug]: Unexpected Dependency false when importing component inside MDX file
2 participants