Skip to content

Commit 294d706

Browse files
authored
Get rid of some Vite warnings (#3420)
Get rid of some annoying warnings we don't care about. I also turned off route module splitting, which splits the `clientLoader` from the rest of a route module, because it mostly creates a bunch of tiny files in the bundle that are never actually loaded by the browser. <img width="747" height="290" alt="image" src="https://github.com/user-attachments/assets/13f5241a-892e-4f74-8d7a-36eecabb870f" /> <img width="759" height="248" alt="image" src="https://github.com/user-attachments/assets/740ebd55-ecf3-4091-87c9-b6bf8d545acc" />
1 parent 31b93cb commit 294d706

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎react-router.config.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import { externalizeSpaScripts } from './tools/externalize-spa-scripts'
1111

1212
export default {
1313
ssr: false,
14+
// Splitting (on by default in v8) emits a separate clientLoader chunk per
15+
// route so the loader can start before the component downloads. Few of our
16+
// loaders can be split, and the rest leave dead placeholder chunks, so it
17+
// mostly adds files.
18+
splitRouteModules: false,
1419
routeDiscovery: { mode: 'initial' },
1520
async buildEnd({ reactRouterConfig }) {
1621
await externalizeSpaScripts(`${reactRouterConfig.buildDirectory}/client`)

‎vite.config.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { defineConfig } from 'vite'
1616
import { configDefaults } from 'vitest/config'
1717
import { z } from 'zod/v4'
1818

19-
import { nexusSecurityHeaders } from './app/api/__generated__/nexus-console'
19+
import { nexusSecurityHeaders } from './app/api/__generated__/nexus-console.ts'
2020

2121
const ApiMode = z.enum(['msw', 'remote', 'nexus'])
2222

@@ -79,6 +79,9 @@ export default defineConfig(({ mode }) => ({
7979
// minify: false, // uncomment for debugging
8080
// prevent inlining assets as `data:`, which is not permitted by our Content-Security-Policy
8181
assetsInlineLimit: 0,
82+
// the metrics explorer route chunk is ~600 kB. It's lazy loaded, so it
83+
// only costs anything on that page
84+
chunkSizeWarningLimit: 700,
8285
},
8386
environments: {
8487
ssr: {
@@ -94,7 +97,7 @@ export default defineConfig(({ mode }) => ({
9497
'process.env.VERCEL_ENV': JSON.stringify(process.env.VERCEL_ENV),
9598
'process.env.THEME_INIT_HASH': JSON.stringify(
9699
createHash('sha256')
97-
.update(readFileSync(resolve(__dirname, 'public/assets/theme-init.js')))
100+
.update(readFileSync(resolve(import.meta.dirname, 'public/assets/theme-init.js')))
98101
.digest('hex')
99102
.slice(0, 8)
100103
),

0 commit comments

Comments
 (0)