Closed dhruvkb closed 9 months ago
Could you please share a reproduction? Not sure why this might be.
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.
This is the error message that appears.
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.
Ah interesting, just tried something and I think I found a fix — will make a PR shortly.
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.
integrations: [autoImport(...), starlight(...)]
should result in an order of autoImport, starlight, mdx
autoImport, starlight
and then mdx
is injected when starlight runs, still ending up at the end.integrations: [starlight(...), autoImport(...)]
results in starlight, autoImport
and then mdx
is injected at the end.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.
I couldn't find any reference to import-order in the Astro changelogs.
I think this was caused by a Starlight change — specifically https://github.com/withastro/starlight/commit/372ec96d31d0c1a9aa8bc1605de2b424bf9bd5af (https://github.com/withastro/starlight/pull/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.
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.
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.
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.