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

Fix usage of <StarlightPage> with a custom srcDir configuration #2054

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

HiDeoo
Copy link
Member

@HiDeoo HiDeoo commented Jun 26, 2024

Description

When using a custom page with the <StarlightPage> component, the user docs schema is retrived using the virtual module virtual:starlight/collection-config which attempts to import /src/content/config.ts. Altho, this does not consider the user having a custom srcDir.

In such cases, trying to build the project would result in the following error:

[vite]: Rollup failed to resolve import "/src/content/config.ts" from "virtual:starlight/collection-config".

This PR fixes the issue by taking the srcDir into account when importing the user docs schema.

I could not imagine a proper way to test this using a unit test so I ended up adding an e2e one instead which would fail to even build the fixture project before the fix.

Copy link

changeset-bot bot commented Jun 26, 2024

🦋 Changeset detected

Latest commit: 790a62c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/starlight Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jun 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
starlight ✅ Ready (Inspect) Visit Preview Jun 26, 2024 9:28am

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! End-to-end test here is actually not a bad idea in general as a basic sanity check for srcDir support.

The only thing I’m wondering is if we should also be running E2E tests on Windows? I never remember with file path stuff what we’re supposed to do, so for something like this change, Windows E2E might add some confidence if they weren’t too slow.

@HiDeoo
Copy link
Member Author

HiDeoo commented Jun 27, 2024

The only thing I’m wondering is if we should also be running E2E tests on Windows?

Yeah, I'll enable them.

This is also the approach we would have ended up with very soon anyway as the SSR PR includes atm some "functional" tests but it's just a few tests which do not really justify a new kind of tests. The idea will be to improve our E2E setup and refactor them as E2E tests, using @playwright/test for the runner and just not ending up using a browser instance during these tests.

@delucis
Copy link
Member

delucis commented Jun 28, 2024

Will merge this without the extra E2E tests — at worst it fixes stuff for users on some platforms and we can add the Windows E2E later. Thanks again @HiDeoo!

@delucis delucis merged commit dbfd3ee into withastro:main Jun 28, 2024
12 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Jun 28, 2024
@HiDeoo HiDeoo mentioned this pull request Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟 core Changes to Starlight’s main package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Astro's srcDir seems to be not supported
2 participants