Skip to content

Commit

Permalink
Bump vite to beta (#11979)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Oct 4, 2024
1 parent 7a1d54a commit 423dfc1
Show file tree
Hide file tree
Showing 17 changed files with 402 additions and 89 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-queens-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': major
---

Bumps `vite` dependency to v6.0.0-beta.2. The version is pinned and will be updated as new Vite versions publish to prevent unhandled breaking changes. For the full list of Vite-specific changes, see [its changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md).
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,14 @@
"typescript-eslint": "^8.7.0"
},
"pnpm": {
"overrides": {
"vitest>vite": "6.0.0-beta.2",
"vite-node>vite": "6.0.0-beta.2"
},
"peerDependencyRules": {
"allowAny": [
"astro"
"astro",
"vite"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
"tsconfck": "^3.1.3",
"unist-util-visit": "^5.0.0",
"vfile": "^6.0.3",
"vite": "^5.4.8",
"vite": "6.0.0-beta.2",
"vitefu": "^1.0.2",
"which-pm": "^3.0.0",
"xxhash-wasm": "^1.0.2",
Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { vitePluginMiddleware } from './middleware/vite-plugin.js';
import { joinPaths } from './path.js';
import { vitePluginServerIslands } from './server-islands/vite-plugin-server-islands.js';
import { isObject } from './util.js';
import astroHmrReloadPlugin from '../vite-plugin-hmr-reload/index.js';

type CreateViteOptions = {
settings: AstroSettings;
Expand Down Expand Up @@ -166,6 +167,7 @@ export async function createVite(
vitePluginUserActions({ settings }),
vitePluginServerIslands({ settings }),
astroContainer(),
astroHmrReloadPlugin(),
],
publicDir: fileURLToPath(settings.config.publicDir),
root: fileURLToPath(settings.config.root),
Expand Down
13 changes: 13 additions & 0 deletions packages/astro/src/vite-plugin-astro/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,19 @@ export default function astro({ settings, logger }: AstroPluginOptions): vite.Pl
const parsedId = parseAstroRequest(id);
// ignore astro file sub-requests, e.g. Foo.astro?astro&type=script&index=0&lang.ts
if (!parsedId.filename.endsWith('.astro') || parsedId.query.astro) {
// Special edge case handling for Vite 6 beta, the style dependencies need to be registered here take affect
// TODO: Remove this when Vite fixes it (https://github.com/vitejs/vite/pull/18103)
if (this.environment.name === 'client') {
const astroFilename = normalizePath(normalizeFilename(parsedId.filename, config.root));
const compileMetadata = astroFileToCompileMetadata.get(astroFilename);
if (compileMetadata && parsedId.query.type === 'style' && parsedId.query.index != null) {
const result = compileMetadata.css[parsedId.query.index];

// Register dependencies from preprocessing this style
result.dependencies?.forEach((dep) => this.addWatchFile(dep));
}
}

return;
}

Expand Down
36 changes: 36 additions & 0 deletions packages/astro/src/vite-plugin-hmr-reload/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { EnvironmentModuleNode, Plugin } from 'vite';

/**
* The very last Vite plugin to reload the browser if any SSR-only module are updated
* which will require a full page reload. This mimics the behaviour of Vite 5 where
* it used to unconditionally reload for us.
*/
export default function hmrReload(): Plugin {
return {
name: 'astro:hmr-reload',
enforce: 'post',
hotUpdate: {
order: 'post',
handler({ modules, server, timestamp }) {
if (this.environment.name !== 'ssr') return;

let hasSsrOnlyModules = false;

const invalidatedModules = new Set<EnvironmentModuleNode>();
for (const mod of modules) {
if (mod.id == null) continue;
const clientModule = server.environments.client.moduleGraph.getModuleById(mod.id);
if (clientModule != null) continue;

this.environment.moduleGraph.invalidateModule(mod, invalidatedModules, timestamp, true);
hasSsrOnlyModules = true;
}

if (hasSsrOnlyModules) {
server.ws.send({ type: 'full-reload' });
return [];
}
},
},
};
}
2 changes: 1 addition & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@
"astro-scripts": "workspace:*",
"cheerio": "1.0.0",
"typescript": "^5.6.2",
"vite": "^5.4.8"
"vite": "6.0.0-beta.2"
}
}
2 changes: 1 addition & 1 deletion packages/integrations/alpinejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@playwright/test": "1.47.2",
"astro": "workspace:*",
"astro-scripts": "workspace:*",
"vite": "^5.4.8"
"vite": "6.0.0-beta.2"
},
"publishConfig": {
"provenance": true
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/markdoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"astro-scripts": "workspace:*",
"devalue": "^5.1.1",
"linkedom": "^0.18.5",
"vite": "^5.4.8"
"vite": "6.0.0-beta.2"
},
"engines": {
"node": "^18.17.1 || ^20.3.0 || >=21.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"remark-toc": "^9.0.0",
"shiki": "^1.21.0",
"unified": "^11.0.5",
"vite": "^5.4.8"
"vite": "6.0.0-beta.2"
},
"engines": {
"node": "^18.17.1 || ^20.3.0 || >=21.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"cheerio": "1.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"vite": "^5.4.8"
"vite": "6.0.0-beta.2"
},
"peerDependencies": {
"@types/react": "^17.0.50 || ^18.0.21",
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"astro": "workspace:*",
"astro-scripts": "workspace:*",
"solid-js": "^1.9.1",
"vite": "^5.4.8"
"vite": "6.0.0-beta.2"
},
"peerDependencies": {
"solid-devtools": "^0.30.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"astro": "workspace:*",
"astro-scripts": "workspace:*",
"svelte": "^4.2.19",
"vite": "^5.4.8"
"vite": "6.0.0-beta.2"
},
"peerDependencies": {
"astro": "^5.0.0-alpha.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"astro": "workspace:*",
"astro-scripts": "workspace:*",
"tailwindcss": "^3.4.13",
"vite": "^5.4.8"
"vite": "6.0.0-beta.2"
},
"peerDependencies": {
"astro": "^3.0.0 || ^4.0.0 || ^5.0.0-beta.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"astro-scripts": "workspace:*",
"cheerio": "1.0.0",
"linkedom": "^0.18.5",
"vite": "^5.4.8",
"vite": "6.0.0-beta.2",
"vue": "^3.5.10"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
"astro": "workspace:*",
"astro-scripts": "workspace:*",
"typescript": "^5.6.2",
"vite": "^5.4.8"
"vite": "6.0.0-beta.2"
}
}
Loading

0 comments on commit 423dfc1

Please sign in to comment.