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 accidental CSS inclusion in dev #7381

Merged
merged 6 commits into from
Jun 22, 2023
Merged

Prevent accidental CSS inclusion in dev #7381

merged 6 commits into from
Jun 22, 2023

Conversation

matthewp
Copy link
Contributor

Changes

Testing

  • Added a new unit test

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Jun 12, 2023

🦋 Changeset detected

Latest commit: cef3a44

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

Comment on lines 85 to 89
if (isImportedBy(id, importedModule) && !isPropagationStoppingPoint) {
importedModules.add(importedModule);
}
}
Copy link
Member

@bluwy bluwy Jun 13, 2023

Choose a reason for hiding this comment

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

On line 47, maybe we can do this instead?

-			for (const importedModule of entry.importedModules) {
+			for (const importedModule of entry.ssrTransformResult.deps) {

Assuming ssrTransformResult would always exist since we're running the Astro component in SSR. .ssrTransformResult.deps should contain the direct imports during Vite's SSR transformation. It's an array of strings, so we'd need to call Vite's moduleGraph.getModuleByUrl() for each string to get the ModuleNode (might need to extend the loader). This is a bit similar to #6716 when I was refactoring it.

If this doesn't quite work, I think this current solution is fine too.

Tailwind strikes again 😦

Copy link
Member

Choose a reason for hiding this comment

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

Sorry if this might not be the place for such a question, but I'm curious.

What's the problem with tailwind? What does it do that causes so much nuance in Astro?

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 don't think this is a problem with Tailwind so much. They aren't doing anything wrong here. This comes down to the Vite API changing and us using the new one incorrectly.

Thanks @bluwy I'll give that option a try.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ssrTransformResult.deps will work. It is urls (paths), so need to compare against entry.url.

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jun 13, 2023
@matthewp matthewp merged commit f359d77 into main Jun 22, 2023
@matthewp matthewp deleted the child-importer branch June 22, 2023 18:36
@astrobot-houston astrobot-houston mentioned this pull request Jun 22, 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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unused Layouts' styles are being imported in Dev Mode
3 participants