Fix Vite build hygiene warnings (#264)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Graham Neubig
2026-05-10 07:29:03 -04:00
committed by GitHub
co-authored by openhands
parent 4683fa90ae
commit 2d454b0405
4 changed files with 67 additions and 64 deletions
+44
View File
@@ -22,6 +22,50 @@ describe("vite optimizeDeps", () => {
});
});
describe("vite path resolution", () => {
it("uses Vite's native tsconfig paths support", async () => {
const config = await viteConfig({ mode: "development", command: "serve" });
expect(config.resolve?.tsconfigPaths).toBe(true);
expect(config.plugins).not.toEqual(
expect.arrayContaining([
expect.objectContaining({ name: "vite-tsconfig-paths" }),
]),
);
});
});
describe("vite app build", () => {
it("configures Rolldown code splitting for large vendor chunks", async () => {
const config = await viteConfig({ mode: "production", command: "build" });
const appBuild = config as {
build?: {
rolldownOptions?: {
output?: {
codeSplitting?: {
groups?: Array<{
name?: string;
maxSize?: number;
entriesAware?: boolean;
}>;
};
};
};
};
};
expect(appBuild.build?.rolldownOptions?.output?.codeSplitting?.groups).toEqual(
expect.arrayContaining([
expect.objectContaining({
name: "vendor",
maxSize: 450 * 1024,
entriesAware: true,
}),
]),
);
});
});
describe("vite library build", () => {
it("configures a dual-format preserved-module library build", async () => {
process.env.BUILD_LIB = "true";
-60
View File
@@ -90,7 +90,6 @@
"tailwindcss": "4.2.4",
"typescript": "6.0.3",
"vite-plugin-svgr": "5.2.0",
"vite-tsconfig-paths": "6.1.1",
"vitest": "4.1.5"
},
"engines": {
@@ -11170,13 +11169,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/globrex": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
"integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==",
"dev": true,
"license": "MIT"
},
"node_modules/goober": {
"version": "2.1.18",
"resolved": "https://registry.npmjs.org/goober/-/goober-2.1.18.tgz",
@@ -17813,58 +17805,6 @@
"vite": ">=3.0.0"
}
},
"node_modules/vite-tsconfig-paths": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-6.1.1.tgz",
"integrity": "sha512-2cihq7zliibCCZ8P9cKJrQBkfgdvcFkOOc3Y02o3GWUDLgqjWsZudaoiuOwO/gzTzy17cS5F7ZPo4bsnS4DGkg==",
"dev": true,
"license": "MIT",
"dependencies": {
"debug": "^4.1.1",
"globrex": "^0.1.2",
"tsconfck": "^3.0.3"
},
"peerDependencies": {
"vite": "*"
}
},
"node_modules/vite-tsconfig-paths/node_modules/tsconfck": {
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/tsconfck/-/tsconfck-3.1.6.tgz",
"integrity": "sha512-ks6Vjr/jEw0P1gmOVwutM3B7fWxoWBL2KRDb1JfqGVawBmO5UsvmWOQFGHBPl5yxYz4eERr19E6L7NMv+Fej4w==",
"dev": true,
"license": "MIT",
"bin": {
"tsconfck": "bin/tsconfck.js"
},
"engines": {
"node": "^18 || >=20"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/vite-tsconfig-paths/node_modules/typescript": {
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true,
"license": "Apache-2.0",
"optional": true,
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/vite/node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
-1
View File
@@ -131,7 +131,6 @@
"tailwindcss": "4.2.4",
"typescript": "6.0.3",
"vite-plugin-svgr": "5.2.0",
"vite-tsconfig-paths": "6.1.1",
"vitest": "4.1.5"
},
"packageManager": "npm@10.5.0",
+23 -3
View File
@@ -2,7 +2,6 @@
/// <reference types="vite-plugin-svgr/client" />
import { fileURLToPath } from "node:url";
import { defineConfig, loadEnv } from "vite";
import viteTsconfigPaths from "vite-tsconfig-paths";
import svgr from "vite-plugin-svgr";
import { reactRouter } from "@react-router/dev/vite";
import { configDefaults } from "vitest/config";
@@ -21,6 +20,25 @@ const LIB_EXTERNALS = [
"react/jsx-dev-runtime",
"react-router",
];
const APP_CHUNK_MAX_BYTES = 450 * 1024;
const appBuildConfig = {
rolldownOptions: {
output: {
codeSplitting: {
groups: [
{
name: "vendor",
test: /node_modules[\\/]/,
maxSize: APP_CHUNK_MAX_BYTES,
minSize: 20 * 1024,
entriesAware: true,
},
],
},
},
},
};
export default defineConfig(({ mode }) => {
const {
@@ -43,10 +61,12 @@ export default defineConfig(({ mode }) => {
return {
plugins: [
!process.env.VITEST && !isLibraryBuild && reactRouter(),
viteTsconfigPaths(),
svgr(),
tailwindcss(),
],
resolve: {
tsconfigPaths: true,
},
css: {
postcss: {
plugins: [
@@ -99,7 +119,7 @@ export default defineConfig(({ mode }) => {
],
},
}
: undefined,
: appBuildConfig,
copyPublicDir: !isLibraryBuild,
optimizeDeps: {
include: [