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

Does not work with Astro v3.3.3 and Starlight v0.11.1 #26

Closed
dhruvkb opened this issue Oct 24, 2023 · 10 comments
Closed

Does not work with Astro v3.3.3 and Starlight v0.11.1 #26

dhruvkb opened this issue Oct 24, 2023 · 10 comments

Comments

@dhruvkb
Copy link

dhruvkb commented Oct 24, 2023

With this plugin configured on Astro v2.7.0 and Starlight v.5.6, everything worked. When I updated Astro and Starlight, without any config changes, the plugin stopped working.

@delucis
Copy link
Owner

delucis commented Oct 24, 2023

Could you please share a reproduction? Not sure why this might be.

@dhruvkb
Copy link
Author

dhruvkb commented Oct 24, 2023

Sure! This is an example repo with the docs being inside the docs/ directory.

The dep_bump branch is on the latest versions of both Astro and Starlight and the imports are broken, which they aren't on main that uses slightly older versions.

@dhruvkb
Copy link
Author

dhruvkb commented Oct 24, 2023

This is the error message that appears.

image

@delucis
Copy link
Owner

delucis commented Oct 24, 2023

I think this may be Starlight-related somehow. Here’s a basic test which shows auto-imports working in MDX with latest Astro: https://stackblitz.com/edit/github-t6bbob?file=src%2Fpages%2Findex.mdx

Downgrading Starlight to v0.10 also seems to make auto-imports work again, so will need to investigate what changed recently that could break this.

@delucis

This comment was marked as outdated.

@delucis
Copy link
Owner

delucis commented Oct 24, 2023

Sure! This is an example repo with the docs being inside the docs/ directory.

Is there some kind of set-up step needed? I get errors about importing @/examples/hero/hero.mdx and that file seems to be missing from the repo.


As a quick fix for the original issue: moving autoImport() after starlight() in your integrations array in astro.config.mjs seems to fix things, although I’m not sure yet why. It’s quite confusing because usually, MDX needs to come AFTER auto-imports. We did change how Starlight enables MDX in v0.11, but I wouldn’t expect it to have this impact.

  • Pre v0.11, integrations: [autoImport(...), starlight(...)] should result in an order of autoImport, starlight, mdx
  • Post v0.11, the same config should result in autoImport, starlight and then mdx is injected when starlight runs, still ending up at the end.
  • Post v0.11, I’d also expect the reversed order to behave the same, i.e. integrations: [starlight(...), autoImport(...)] results in starlight, autoImport and then mdx is injected at the end.

@dhruvkb
Copy link
Author

dhruvkb commented Oct 25, 2023

Is there some kind of set-up step needed?

Sorry, my bad. This has a pretty complex setup process. I'll try to prepare a minimal reproducible example.

moving autoImport() after starlight() in your integrations array in astro.config.mjs seems to fix things

Yes, that worked perfectly. I have no idea why this order would've changed. I couldn't find any reference to import-order in the Astro changelogs. If more people experience this, it might be worth documenting the new order somewhere.

@delucis
Copy link
Owner

delucis commented Oct 25, 2023

I couldn't find any reference to import-order in the Astro changelogs.

I think this was caused by a Starlight change — specifically withastro/starlight@372ec96 (withastro/starlight#796) — but don’t understand yet why. In regular Astro projects, the guidance in the astro-auto-import docs continue to work, but it’s a bit of a mystery to me why that’s not the case for Starlight projects.

@dhruvkb
Copy link
Author

dhruvkb commented Oct 26, 2023

Feel free to close this issue if you think there's nothing actionable here. And thanks for the solution, I wasn't able to update and use the newest features in Starlight till this was resolved.

@delucis
Copy link
Owner

delucis commented Oct 26, 2023

Thanks. Yes, will close this as the issue is not something we can solve in this repo. Will keep investigating to understand why it's an issue with Starlight.

@delucis delucis closed this as completed Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants