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

Update Vite to 6.0.0 #12524

Merged
merged 13 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/breezy-brooms-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': major
---

Bumps Vite to ^6.0.0 and handles its breaking changes
bluwy marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions .changeset/eighty-crabs-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/solid-js': patch
---

Updates vite-plugin-solid to handle Vite 6
5 changes: 5 additions & 0 deletions .changeset/lemon-frogs-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/svelte': major
---

Updates `@sveltejs/vite-plugin-svelte` to v5 to handle Vite 6
9 changes: 9 additions & 0 deletions .changeset/slimy-jeans-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@astrojs/preact': major
'@astrojs/svelte': major
'@astrojs/react': major
'@astrojs/solid-js': major
'@astrojs/vue': major
---

Updates Vite dependency to v6 to match Astro v5
4 changes: 2 additions & 2 deletions examples/container-with-vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"test": "vitest run"
},
"dependencies": {
"astro": "^5.0.0-beta.11",
"@astrojs/react": "^3.7.0-beta.1",
"astro": "^5.0.0-beta.11",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"vitest": "^2.1.4"
"vitest": "^2.1.6"
},
"devDependencies": {
"@types/react": "^18.3.12",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"astro": "^5.0.0-beta.11",
"autoprefixer": "^10.4.20",
"canvas-confetti": "^1.9.3",
"postcss": "^8.4.47",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.14"
}
}
2 changes: 1 addition & 1 deletion examples/with-vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
},
"dependencies": {
"astro": "^5.0.0-beta.11",
"vitest": "^2.1.4"
"vitest": "^2.1.6"
}
}
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@
"typescript-eslint": "^8.13.0"
},
"pnpm": {
"overrides": {
"vitest>vite": "6.0.0-beta.6",
"vite-node>vite": "6.0.0-beta.6"
},
"peerDependencyRules": {
"allowAny": [
"astro",
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@astrojs/tailwind": "workspace:*",
"astro": "workspace:*",
"autoprefixer": "^10.4.20",
"postcss": "^8.4.47",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.14"
}
}
6 changes: 3 additions & 3 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@
"ultrahtml": "^1.5.3",
"unist-util-visit": "^5.0.0",
"vfile": "^6.0.3",
"vite": "6.0.0-beta.6",
"vitefu": "^1.0.3",
"vite": "^6.0.1",
"vitefu": "^1.0.4",
"which-pm": "^3.0.0",
"xxhash-wasm": "^1.0.2",
"yargs-parser": "^21.1.1",
Expand Down Expand Up @@ -215,7 +215,7 @@
"sass": "^1.80.6",
"undici": "^6.20.1",
"unified": "^11.0.5",
"vitest": "^2.1.1"
"vitest": "^2.1.6"
},
"engines": {
"node": "^18.17.1 || ^20.3.0 || >=21.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ export async function createVite(
replacement: 'astro/components',
},
],
conditions: ['astro'],
// Astro imports in third-party packages should use the same version as root
dedupe: ['astro'],
},
Expand Down
14 changes: 13 additions & 1 deletion packages/astro/src/vite-plugin-astro/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
CompileMetadata,
} from './types.js';

import { normalizePath } from 'vite';
import { defaultClientConditions, defaultServerConditions, normalizePath } from 'vite';
import type { AstroConfig } from '../types/public/config.js';
import { hasSpecialQueries, normalizeFilename } from '../vite-plugin-utils/index.js';
import { type CompileAstroResult, compileAstro } from './compile.js';
Expand Down Expand Up @@ -43,6 +43,18 @@ export default function astro({ settings, logger }: AstroPluginOptions): vite.Pl
const prePlugin: vite.Plugin = {
name: 'astro:build',
enforce: 'pre', // run transforms before other plugins can
async configEnvironment(name, viteConfig, opts) {
viteConfig.resolve ??= {};
// Emulate Vite default fallback for `resolve.conditions` if not set
if (viteConfig.resolve.conditions == null) {
if (viteConfig.consumer === 'client' || name === 'client' || opts.isSsrTargetWebworker) {
viteConfig.resolve.conditions = [...defaultClientConditions];
} else {
viteConfig.resolve.conditions = [...defaultServerConditions];
}
}
viteConfig.resolve.conditions.push('astro');
},
configResolved(viteConfig) {
// Initialize `compile` function to simplify usage later
compile = (code, filename) => {
Expand Down
9 changes: 6 additions & 3 deletions packages/astro/test/config-vite.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import * as cheerio from 'cheerio';
import { resolveConfig } from 'vite';
import { defaultClientConditions, resolveConfig } from 'vite';
import { getViteConfig } from '../dist/config/index.js';
import { loadFixture } from './test-utils.js';

Expand All @@ -28,9 +28,12 @@ describe('getViteConfig', () => {
it('Does not change the default config.', async () => {
const command = 'serve';
const mode = 'test';
const configFn = getViteConfig({});
const configFn = getViteConfig({}, { logLevel: 'silent' });
const config = await configFn({ command, mode });
const resolvedConfig = await resolveConfig(config, command, mode);
assert.deepStrictEqual(resolvedConfig.resolve.conditions, ['astro']);
assert.deepStrictEqual(resolvedConfig.resolve.conditions, [
...defaultClientConditions,
'astro',
]);
});
});
2 changes: 1 addition & 1 deletion packages/astro/test/fixtures/postcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@astrojs/vue": "workspace:*",
"astro": "workspace:*",
"autoprefixer": "^10.4.20",
"postcss": "^8.4.47",
"postcss": "^8.4.49",
"solid-js": "^1.9.3",
"svelte": "^5.1.16",
"vue": "^3.5.12"
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/test/fixtures/tailwindcss-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"@astrojs/tailwind": "workspace:*",
"astro": "workspace:*",
"postcss": "^8.4.47",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.14"
}
}
2 changes: 1 addition & 1 deletion packages/astro/test/fixtures/tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@astrojs/tailwind": "workspace:*",
"astro": "workspace:*",
"autoprefixer": "^10.4.20",
"postcss": "^8.4.47",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.14"
}
}
2 changes: 1 addition & 1 deletion packages/astro/test/fixtures/vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
},
"dependencies": {
"astro": "workspace:*",
"vitest": "^2.1.1"
"vitest": "^2.1.6"
}
}
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.3",
"vite": "6.0.0-beta.6"
"vite": "^6.0.1"
}
}
2 changes: 1 addition & 1 deletion packages/db/test/fixtures/ticketing-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@astrojs/check": "^0.9.4",
"@astrojs/db": "workspace:*",
"@astrojs/node": "^8.3.4",
"@astrojs/react": "^3.6.2",
"@astrojs/react": "workspace:*",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"astro": "workspace:*",
Expand Down
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.48.2",
"astro": "workspace:*",
"astro-scripts": "workspace:*",
"vite": "6.0.0-beta.6"
"vite": "^6.0.1"
},
"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": "6.0.0-beta.6"
"vite": "^6.0.1"
},
"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.22.2",
"unified": "^11.0.5",
"vite": "6.0.0-beta.6"
"vite": "^6.0.1"
},
"engines": {
"node": "^18.17.1 || ^20.3.0 || >=21.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@preact/signals": "^1.3.0",
"babel-plugin-transform-hook-names": "^1.0.2",
"preact-render-to-string": "^6.5.11",
"vite": "^5.4.10"
"vite": "^6.0.1"
},
"devDependencies": {
"astro": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
"test": "astro-scripts test \"test/**/*.test.js\""
},
"dependencies": {
"@vitejs/plugin-react": "^4.3.3",
"@vitejs/plugin-react": "^4.3.4",
"ultrahtml": "^1.5.3",
"vite": "6.0.0-beta.6"
"vite": "^6.0.1"
},
"devDependencies": {
"@types/react": "^18.3.12",
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"dev": "astro-scripts dev \"src/**/*.ts\""
},
"dependencies": {
"vite-plugin-solid": "^2.10.2",
"vite": "6.0.0-beta.6"
"vite-plugin-solid": "^2.11.0",
"vite": "^6.0.1"
},
"devDependencies": {
"astro": "workspace:*",
Expand Down
34 changes: 3 additions & 31 deletions packages/integrations/solid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,43 +45,15 @@ async function getDevtoolsPlugin(logger: AstroIntegrationLogger, retrieve: boole
}
}

async function getViteConfiguration(
isDev: boolean,
function getViteConfiguration(
{ include, exclude }: Options,
devtoolsPlugin: DevtoolsPlugin | null,
) {
// https://github.com/solidjs/vite-plugin-solid
// We inject the dev mode only if the user explicitly wants it or if we are in dev (serve) mode
const nestedDeps = ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h'];
const config: UserConfig = {
resolve: {
conditions: ['solid', ...(isDev ? ['development'] : [])],
dedupe: nestedDeps,
alias: [{ find: /^solid-refresh$/, replacement: '/@solid-refresh' }],
},
optimizeDeps: {
include: [...nestedDeps],
exclude: ['@astrojs/solid-js/server.js'],
},
plugins: [
solid({ include, exclude, dev: isDev, ssr: true }),
{
name: '@astrojs/solid:config-overrides',
enforce: 'post',
config() {
return {
esbuild: {
// To support using alongside other JSX frameworks, still let
// esbuild compile stuff. Solid goes first anyways.
include: /\.(m?ts|[jt]sx)$/,
},
};
},
},
],
ssr: {
external: ['babel-preset-solid'],
},
plugins: [solid({ include, exclude, ssr: true })],
};

if (devtoolsPlugin) {
Expand Down Expand Up @@ -128,7 +100,7 @@ export default function (options: Options = {}): AstroIntegration {

addRenderer(getRenderer());
updateConfig({
vite: await getViteConfiguration(command === 'dev', options, devtoolsPlugin),
vite: getViteConfiguration(options, devtoolsPlugin),
});

if (devtoolsPlugin) {
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
"dev": "astro-scripts dev \"src/**/*.ts\""
},
"dependencies": {
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"svelte2tsx": "^0.7.22",
"vite": "6.0.0-beta.6"
"vite": "^6.0.1"
},
"devDependencies": {
"astro": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
},
"dependencies": {
"autoprefixer": "^10.4.20",
"postcss": "^8.4.47",
"postcss": "^8.4.49",
"postcss-load-config": "^4.0.2"
},
"devDependencies": {
"astro": "workspace:*",
"astro-scripts": "workspace:*",
"tailwindcss": "^3.4.14",
"vite": "6.0.0-beta.6"
"vite": "^6.0.1"
},
"peerDependencies": {
"astro": "^3.0.0 || ^4.0.0 || ^5.0.0-beta.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/integrations/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
"test": "astro-scripts test \"test/**/*.test.js\""
},
"dependencies": {
"@vitejs/plugin-vue": "^5.1.4",
"@vitejs/plugin-vue": "^5.2.1",
"@vitejs/plugin-vue-jsx": "^4.0.1",
"@vue/compiler-sfc": "^3.5.12",
"vite-plugin-vue-devtools": "^7.6.3",
"vite": "6.0.0-beta.6"
"vite": "^6.0.1",
"vite-plugin-vue-devtools": "^7.6.3"
},
"devDependencies": {
"astro": "workspace:*",
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.3",
"vite": "6.0.0-beta.6"
"vite": "^6.0.1"
}
}
Loading
Loading