mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-04 21:52:14 +00:00
fix: pre-bundle shiki/@pierre deps to stop dev dynamic-import failures (#1643)
* fix(ui): pre-bundle shiki/@pierre deps to stop dev dynamic-import failures shiki lazy-imports a grammar per language and these libs only live inside lazy route components, so Vite's startup scanner never sees them. They get discovered on first thread navigation, triggering a dep re-optimize + force-reload that aborts the in-flight route-chunk import, surfacing as "Failed to fetch dynamically imported module: .../$threadId.tsx". Pre-bundle them (and the github themes + common code-block languages) via optimizeDeps.include so the optimize happens once at startup. Dev-only; production bundles are unaffected. * fix: pre-bundle canonical shiki docker/make langs instead of aliases --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
This commit is contained in:
parent
92dbf6f932
commit
db2ae58edb
1 changed files with 55 additions and 1 deletions
|
|
@ -74,8 +74,62 @@ function mockHarnessProxy(): Plugin | null {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shiki lazily `import()`s one grammar per language on first render. These libs
|
||||||
|
// also only live inside lazy route components, so Vite's startup scanner never
|
||||||
|
// reaches them — it discovers them on first thread navigation, re-optimizes deps,
|
||||||
|
// and force-reloads, aborting the in-flight route-chunk import ("Failed to fetch
|
||||||
|
// dynamically imported module"). Pre-bundling them up front avoids the reload.
|
||||||
|
// Uncommon languages not listed just trigger a one-time, graceful re-optimize.
|
||||||
|
const SHIKI_LANGS = [
|
||||||
|
"bash",
|
||||||
|
"c",
|
||||||
|
"cpp",
|
||||||
|
"csharp",
|
||||||
|
"css",
|
||||||
|
"diff",
|
||||||
|
"docker",
|
||||||
|
"go",
|
||||||
|
"graphql",
|
||||||
|
"html",
|
||||||
|
"java",
|
||||||
|
"javascript",
|
||||||
|
"json",
|
||||||
|
"jsonc",
|
||||||
|
"jsx",
|
||||||
|
"kotlin",
|
||||||
|
"lua",
|
||||||
|
"make",
|
||||||
|
"markdown",
|
||||||
|
"php",
|
||||||
|
"python",
|
||||||
|
"ruby",
|
||||||
|
"rust",
|
||||||
|
"scala",
|
||||||
|
"shellscript",
|
||||||
|
"sql",
|
||||||
|
"swift",
|
||||||
|
"toml",
|
||||||
|
"tsx",
|
||||||
|
"typescript",
|
||||||
|
"xml",
|
||||||
|
"yaml",
|
||||||
|
]
|
||||||
|
|
||||||
const config = defineConfig({
|
const config = defineConfig({
|
||||||
optimizeDeps: { include: ["workbox-window"] },
|
optimizeDeps: {
|
||||||
|
include: [
|
||||||
|
"workbox-window",
|
||||||
|
"streamdown",
|
||||||
|
"shiki",
|
||||||
|
"@pierre/diffs",
|
||||||
|
"@pierre/diffs/react",
|
||||||
|
"@pierre/trees",
|
||||||
|
"@pierre/trees/react",
|
||||||
|
"@shikijs/themes/github-light",
|
||||||
|
"@shikijs/themes/github-dark",
|
||||||
|
...SHIKI_LANGS.map((lang) => `@shikijs/langs/${lang}`),
|
||||||
|
],
|
||||||
|
},
|
||||||
worker: { format: "es" },
|
worker: { format: "es" },
|
||||||
plugins: [
|
plugins: [
|
||||||
mockHarnessProxy(),
|
mockHarnessProxy(),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue