The best way to control Claude Code, Codex and more from any computer or phone
fix(web): app loads again after a chunk cycle blanked it at boot (#25295)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Theo Browne committed
Oct 25, 2026 at 21:12 UTC
04a21bb1c1cec0e60aa831bef11e67feae95885e
1 file changed
+25
-15
apps/web/vite.config.ts
+25
-15
@@ -221,6 +221,30 @@ function devCompressionPlugin(): Plugin {
221
};
222
}
223
224
+// A static import cycle between chunks can run a chunk before the values it imports exist,
225
+// which blanks the app at boot. Fail the build instead of shipping it.
226
+function chunkCycleGuardPlugin(): Plugin {
227
+ return {
228
+ name: "t3code:chunk-cycle-guard",
229
+ apply: "build",
230
+ generateBundle(_options, bundle) {
231
+ const done = new Set<string>();
232
+ const visit = (fileName: string, path: string[]) => {
233
+ if (done.has(fileName)) return;
234
+ const start = path.indexOf(fileName);
235
+ if (start !== -1) {
236
+ this.error(`Chunk import cycle: ${[...path.slice(start), fileName].join(" -> ")}`);
237
+ }
238
+ const chunk = bundle[fileName];
239
+ if (chunk?.type !== "chunk") return;
240
+ for (const imported of chunk.imports) visit(imported, [...path, fileName]);
241
+ done.add(fileName);
242
+ };
243
+ for (const fileName of Object.keys(bundle)) visit(fileName, []);
244
+ },
245
+ };
246
+}
247
+
248
// Allow Tailnet hosts for sharing; Tailscale-controlled DNS prevents attacker rebinding.
249
const configuredAllowedHosts = (process.env.T3CODE_DEV_ALLOWED_HOSTS ?? "")
250
.split(",")
@@ -242,6 +266,7 @@ export default defineConfig(() => {
266
assetsInclude: ["**/*.wasm"],
267
plugins: [
268
devCompressionPlugin(),
269
+ chunkCycleGuardPlugin(),
270
builtDev
271
? undefined
272
: thirdPartyLicensesPlugin({
@@ -359,21 +384,6 @@ export default defineConfig(() => {
384
asset.originalFileNames.some((path) => /[/\\]pdfjs-dist[/\\]wasm[/\\]/.test(path))
385
? `assets/pdfjs-${pdfjsPkg.version}/[name][extname]`
386
: "assets/[name]-[hash][extname]",
362
- codeSplitting: {
363
- // Preview imports must not fold shared file icons back into main.
364
- groups: [
365
- {
366
- name: "react",
367
- test: /\/node_modules\/(?:react|react-dom|scheduler)\//,
368
- includeDependenciesRecursively: false,
369
- },
370
- {
371
- name: "icons",
372
- test: /\/(?:components\/chat\/PierreEntryIcon\.tsx|pierre-icons\.ts|mediaPreview\.ts)$/,
373
- includeDependenciesRecursively: false,
374
- },
375
- ],
376
- },
387
},
388
},
389
},