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

Prevent usage of astro:content in the client #11827

Merged
merged 7 commits into from
Aug 27, 2024
Merged

Conversation

matthewp
Copy link
Contributor

@matthewp matthewp commented Aug 23, 2024

Changes

  • Previously we warned users who imported it in the client, this changes that to a runtime error.

Testing

  • Hard to test given the build breaks, but willing to do so if we think it's important.

Docs

Copy link

changeset-bot bot commented Aug 23, 2024

🦋 Changeset detected

Latest commit: 5747564

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

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

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) semver: major Change triggers a `major` release labels Aug 23, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a major changeset. A reviewer will merge this at the next release if approved.

@@ -360,7 +372,7 @@ export async function generateLookupMap({
const contentEntryType = contentEntryConfigByExt.get(extname(filePath));
if (!contentEntryType) throw UnexpectedLookupMapError;

const { id, slug: generatedSlug } = await getContentEntryIdAndSlug({
const { id, slug: generatedSlug } = getContentEntryIdAndSlug({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is an unrelated change, but this await is on a sync function, so I removed.

@matthewp matthewp marked this pull request as ready for review August 23, 2024 16:52
@matthewp matthewp requested a review from sarah11918 August 23, 2024 16:53
if(isClient) {
// Empty exports is probably enough to break the build.
// If for some reason its being imported as a side-effect ala `import 'astro:content';` then throw an error message.
virtualModContents = `export {};
Copy link
Member

Choose a reason for hiding this comment

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

Is this really needed? I think for astro:env I just throw without returning any content

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, removed

@matthewp matthewp merged commit a83e362 into next Aug 27, 2024
13 checks passed
@matthewp matthewp deleted the no-astro-content-in-client branch August 27, 2024 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) semver: major Change triggers a `major` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants