Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,22 @@ export default defineConfig({
emptyOutDir: true,
rollupOptions: {
output: {
// Keep Shiki and its first-party packages in a single chunk. pnpm's
// symlinks + Vite's default split expose a top-level cyclic import
// between the full language bundle and the alias-map chunk that ends
// up executing before its data dependency is initialized, producing
// "Cannot read properties of undefined (reading 'flatMap')" and a
// blank Monaco/file-viewer screen.
manualChunks(id) {
const normalized = id.replaceAll("\\", "/");
// Shiki lazily imports each language grammar (`@shikijs/langs/<lang>`)
// via dynamic import; leave those as their own on-demand chunks
// instead of folding ~200 grammars into the eagerly-loaded core.
if (normalized.includes("/@shikijs/langs/")) {
return;
}
// Keep Shiki's core, engines, and bundle glue (incl. the language
// index + alias map) in one chunk. pnpm's symlinks + Vite's default
// split otherwise expose a top-level cyclic import between the
// language bundle and the alias-map chunk that executes before its
// data dependency is initialized, producing "Cannot read properties
// of undefined (reading 'flatMap')" and a blank Monaco/file-viewer
// screen. The engines must stay here too: excluding them splits the
// cyclic core across chunks and reintroduces the bug.
if (normalized.includes("/shiki") || normalized.includes("/@shikijs/")) {
return "shiki";
}
Expand Down
Loading