Skip to content

Scope helper environment to only handle CSS #13045

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

Merged
merged 3 commits into from
Feb 19, 2025

Conversation

markdalgleish
Copy link
Member

This is a follow-up to #13008.

This PR makes the following refactors:

  • Ensure the helper environment is only used for CSS. This is because the helper environment is Node-based and may differ from the ssr environment, e.g. when using vite-plugin-cloudflare. CSS is handled the same regardless of environment so it's safe to load from another environment, but we don't want to be loading arbitrary modules.
  • In order to scope the helper environment to CSS, the server manifest is no longer loaded from the module graph during HMR. Instead, we now keep a reference to the current server manifest in memory.
  • Hoists the CSS dev helper environment up to site alongside the other environments rather than being added on separately within the plugin.

Copy link

changeset-bot bot commented Feb 18, 2025

⚠️ No Changeset found

Latest commit: eb8e4fd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Comment on lines 980 to 986
invariant(
typeof cssMod === "object" &&
cssMod !== null &&
"default" in cssMod &&
typeof cssMod.default === "string",
`Failed to load CSS for ${dep.url}`
);
Copy link
Member Author

Choose a reason for hiding this comment

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

The only consumer of this code threw an error if the result was undefined, so I've inlined that logic into this function now instead.

@markdalgleish markdalgleish merged commit 8677247 into dev Feb 19, 2025
8 checks passed
@markdalgleish markdalgleish deleted the markdalgleish/css-dev-helper-environment branch February 19, 2025 00:16
Copy link
Contributor

github-actions bot commented Mar 6, 2025

🤖 Hello there,

We just published version 7.3.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant