GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): app loads again after a chunk cycle blanked it at boot (#25… · incognitojam/styal@04a21bb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web
    • vite.config.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/vite.config.ts‎

Copy file name to clipboardExpand all lines: apps/web/vite.config.ts
+25-15Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,30 @@ function devCompressionPlugin(): Plugin {
221221
};
222222
}
223223

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+
224248
// Allow Tailnet hosts for sharing; Tailscale-controlled DNS prevents attacker rebinding.
225249
const configuredAllowedHosts = (process.env.T3CODE_DEV_ALLOWED_HOSTS ?? "")
226250
.split(",")
@@ -242,6 +266,7 @@ export default defineConfig(() => {
242266
assetsInclude: ["**/*.wasm"],
243267
plugins: [
244268
devCompressionPlugin(),
269+
chunkCycleGuardPlugin(),
245270
builtDev
246271
? undefined
247272
: thirdPartyLicensesPlugin({
@@ -359,21 +384,6 @@ export default defineConfig(() => {
359384
asset.originalFileNames.some((path) => /[/\\]pdfjs-dist[/\\]wasm[/\\]/.test(path))
360385
? `assets/pdfjs-${pdfjsPkg.version}/[name][extname]`
361386
: "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-
},
377387
},
378388
},
379389
},

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.