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

Refactor content collection transforms #6817

Merged
merged 12 commits into from
Apr 11, 2023
Merged

Conversation

bholmesdev
Copy link
Contributor

@bholmesdev bholmesdev commented Apr 11, 2023

Changes

  • Resolve Astro 2.0 warning when using sourcemaps #6058
  • Migrate load step for content collection imports and assets to the transform step. This reduces complexity and unblocks support for content extensions with existing transforms from Vite core, like .json (reason for unblock here).
  • Add check for vite.build.sourcemap option to content collections and the MDX plugin. When present, generate source maps. Avoid generating otherwise to prevent perf bottlenecks.

Testing

Docs

@changeset-bot
Copy link

changeset-bot bot commented Apr 11, 2023

🦋 Changeset detected

Latest commit: 1d16001

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) pkg: example Related to an example package (scope) labels Apr 11, 2023
@github-actions github-actions bot removed the pkg: example Related to an example package (scope) label Apr 11, 2023
@@ -104,6 +105,11 @@ interface AstroPluginJSXOptions {
logging: LogOptions;
}

// Format inspired by https://github.com/vitejs/vite/blob/main/packages/vite/src/node/constants.ts#L54
const SPECIAL_QUERY_REGEX = new RegExp(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I discovered our JSX runtime will try to process files with special flags like ?raw and ?astroContent. This regex should prevent that

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Apr 11, 2023
@bholmesdev bholmesdev marked this pull request as ready for review April 11, 2023 15:10

function isPropagatedAsset(viteId: string, contentEntryExts: string[]): boolean {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

contentEntryExts check removed. Speeds up check and unlocks for future file extensions

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

Nice refactor!

@bholmesdev bholmesdev merged commit f882bc1 into main Apr 11, 2023
@bholmesdev bholmesdev deleted the refactor/content-transforms branch April 11, 2023 17:44
@astrobot-houston astrobot-houston mentioned this pull request Apr 11, 2023
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) pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Astro 2.0 warning when using sourcemaps
2 participants