Skip to content

Commit deaaf3f

Browse files
chore: remove Vite 8 warning (#16603)
Signed-off-by: Alexander Niebuhr <45965090+alexanderniebuhr@users.noreply.github.com>
1 parent e322c24 commit deaaf3f

4 files changed

Lines changed: 5 additions & 90 deletions

File tree

.changeset/goofy-tigers-like.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Removes the warning that Astro does not support vite v8, since Astro v7 does support vite v8

packages/astro/src/cli/add/index.ts

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,6 @@ export async function add(names: string[], { flags }: AddOptions) {
234234
logger,
235235
scripts: { 'generate-types': 'wrangler types' },
236236
});
237-
238-
await updatePackageJsonOverrides({
239-
configURL,
240-
flags,
241-
logger,
242-
overrides: { vite: '^7' },
243-
});
244237
}
245238
if (integrations.find((integration) => integration.id === 'tailwind')) {
246239
const dir = new URL('./styles/', new URL(userConfig.srcDir ?? './src/', root));
@@ -705,67 +698,6 @@ async function updateAstroConfig({
705698
}
706699
}
707700

708-
async function updatePackageJsonOverrides({
709-
configURL,
710-
flags,
711-
logger,
712-
overrides,
713-
}: {
714-
configURL: URL;
715-
flags: Flags;
716-
logger: AstroLogger;
717-
overrides: Record<string, string>;
718-
}): Promise<UpdateResult> {
719-
const pkgURL = new URL('./package.json', configURL);
720-
if (!existsSync(pkgURL)) {
721-
logger.debug('add', 'No package.json found, skipping overrides update');
722-
return 'none';
723-
}
724-
725-
const pkgPath = fileURLToPath(pkgURL);
726-
const input = await fs.readFile(pkgPath, { encoding: 'utf-8' });
727-
const pkgJson = JSON.parse(input);
728-
729-
pkgJson.overrides ??= {};
730-
let hasChanges = false;
731-
for (const [name, range] of Object.entries(overrides)) {
732-
if (!(name in pkgJson.overrides)) {
733-
pkgJson.overrides[name] = range;
734-
hasChanges = true;
735-
}
736-
}
737-
738-
if (!hasChanges) {
739-
return 'none';
740-
}
741-
742-
const output = JSON.stringify(pkgJson, null, 2);
743-
const diff = getDiffContent(input, output);
744-
745-
if (!diff) {
746-
return 'none';
747-
}
748-
749-
logger.info(
750-
'SKIP_FORMAT',
751-
`\n ${magenta('Astro will add the following overrides to your package.json:')}`,
752-
);
753-
754-
clack.box(diff, 'package.json', {
755-
rounded: true,
756-
withGuide: false,
757-
width: 'auto',
758-
});
759-
760-
if (await askToContinue({ flags, logger })) {
761-
await fs.writeFile(pkgPath, output, { encoding: 'utf-8' });
762-
logger.debug('add', 'Updated package.json overrides');
763-
return 'updated';
764-
} else {
765-
return 'cancelled';
766-
}
767-
}
768-
769701
async function updatePackageJsonScripts({
770702
configURL,
771703
flags,

packages/astro/src/core/dev/dev.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import fs from 'node:fs';
22
import type http from 'node:http';
3-
import { createRequire } from 'node:module';
43
import type { AddressInfo } from 'node:net';
54
import { performance } from 'node:perf_hooks';
65
import colors from 'piccolore';
@@ -25,19 +24,6 @@ import {
2524
} from './update-check.js';
2625
import { BuildTimeAstroVersionProvider } from '../../cli/infra/build-time-astro-version-provider.js';
2726
import { piccoloreTextStyler } from '../../cli/infra/piccolore-text-styler.js';
28-
import type { AstroLogger } from '../logger/core.js';
29-
30-
function warnIfVite8({ root, logger }: { root: URL | string; logger: AstroLogger }) {
31-
try {
32-
const require = createRequire(root);
33-
const { version } = require('vite/package.json') as { version: string };
34-
if (major(version) >= 8) {
35-
logger.warn('SKIP_FORMAT', msg.vite8Warning({ viteVersion: version }));
36-
}
37-
} catch {
38-
// If vite can't be resolved from the project root, skip the warning
39-
}
40-
}
4127

4228
export interface DevServer {
4329
address: AddressInfo;
@@ -154,8 +140,6 @@ export default async function dev(inlineConfig: AstroInlineConfig): Promise<DevS
154140
logger.warn('SKIP_FORMAT', msg.fsStrictWarning());
155141
}
156142

157-
setImmediate(() => warnIfVite8({ root: restart.container.settings.config.root, logger }));
158-
159143
logger.info(null, colors.green('watching for file changes...'));
160144

161145
return {

packages/astro/src/core/messages/runtime.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,6 @@ export function fsStrictWarning() {
179179
return `${title}\n${subtitle}\n`;
180180
}
181181

182-
export function vite8Warning({ viteVersion }: { viteVersion: string }) {
183-
const title = yellow('▶ ' + `Vite ${bold(viteVersion)} detected in your project.`);
184-
const subtitle = ` Astro requires Vite 7. Add ${bold('"overrides": { "vite": "^7" }')} to your ${bold('package.json')} to avoid issues.`;
185-
return `${title}\n${subtitle}\n`;
186-
}
187-
188182
export function prerelease({ currentVersion }: { currentVersion: string }) {
189183
const tag = currentVersion.split('-').slice(1).join('-').replace(/\..*$/, '') || 'unknown';
190184
const badge = bgYellow(black(` ${tag} `));

0 commit comments

Comments
 (0)