Skip to content

refactor: optimise dependencies#14951

Merged
ematipico merged 8 commits into
feat/environment-apifrom
refactor/optimize-environments
Dec 4, 2025
Merged

refactor: optimise dependencies#14951
ematipico merged 8 commits into
feat/environment-apifrom
refactor/optimize-environments

Conversation

@ematipico

@ematipico ematipico commented Dec 3, 2025

Copy link
Copy Markdown
Member

Changes

This PR reworks how dependencies are optimised and resolved by using the new hook configEnvironment from vitev7.

Astro core

As for createVite, I decided to move the resolution inside a plugin, so it doesn't clutter the already big craeteVite function. I tried to keep the same logic we had before.

Cloudflare

I removed stuff that I think it's not needed anymore. All current tests work and the fixture builds without issues. The preview server still works as expected.

I had to add an exception for the unstorage driver because it couldn't be optimised, and the server was crashing.

Other integrations

I updated other integrations such as react, vue, solid, svelte and preact.

As for vue, I had to add vue/server-renderer because it was crashing the Cloudflare server.

Note

I plan to optimise the rest of the integrations in another PR

Testing

After this change, one of the tests in cloudflare broke. The thing is, I had to change the test assumptions earlier, but now the build output is back to how it was, so I restored the test's previous assertion.

The remaining tests should work.

Docs

N/A

@changeset-bot

changeset-bot Bot commented Dec 3, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8da7b84

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.

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

@github-actions github-actions Bot added pkg: vue Related to Vue (scope) pkg: react Related to React (scope) pkg: preact Related to Preact (scope) pkg: solid Related to Solid (scope) pkg: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) labels Dec 3, 2025
@ematipico ematipico changed the title refactor: use environments to load modules (#14191) refactor: optimise dependencies Dec 3, 2025
@ematipico ematipico marked this pull request as ready for review December 3, 2025 15:02
@ematipico ematipico marked this pull request as draft December 3, 2025 15:19
@ematipico ematipico self-assigned this Dec 3, 2025
@matthewp

matthewp commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

Pulled this down locally and confirmed that uncached the vite-plugin fixture no longer crashes. Will wait for tests to be passing before reviewing.

@github-actions github-actions Bot added the pkg: svelte Related to Svelte (scope) label Dec 3, 2025
Comment thread packages/astro/src/core/constants.ts
@ematipico ematipico marked this pull request as ready for review December 3, 2025 16:42
@matthewp

matthewp commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

Approved once tests are passing again.

@ematipico ematipico merged commit 98144fb into feat/environment-api Dec 4, 2025
22 checks passed
@ematipico ematipico deleted the refactor/optimize-environments branch December 4, 2025 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs pr pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) pkg: preact Related to Preact (scope) pkg: react Related to React (scope) pkg: solid Related to Solid (scope) pkg: svelte Related to Svelte (scope) pkg: vue Related to Vue (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants