Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .github/workflows/dashboard-deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [main]
paths:
- "apps/dashboard/**"
- "packages/ui/**"
- "packages/icons/**"
- "packages/typescript-config/**"
- "scripts/generate-wrangler-dashboard-config.mjs"
- "scripts/run-d1-migrations.mjs"
- ".github/workflows/dashboard-deploy-production.yml"
Expand Down
51 changes: 48 additions & 3 deletions apps/dashboard/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function getTunnelServerConfig(): import("vite").UserConfig["server"] {
// client-side so the server never needs the real implementation.
function shikiSSRStub(): import("vite").Plugin {
const SHIKI_RE = /^(shiki|@shikijs\/)/;
const STUB = `
const DEFAULT_STUB = `
export const bundledLanguages = {};
export const bundledThemes = {};
export const createHighlighter = () => Promise.resolve({});
Expand All @@ -105,6 +105,36 @@ export const stringifyTokenStyle = () => "";
export const transformerStyleToClass = () => ({});
export default {};`;

// "shiki/core" re-exports "@shikijs/core" (fine-grained / createHighlighterCore).
// "@shikijs/rehype" imports isSpecialLang from "shiki/core" during SSR analysis.
const CORE_STUB = `
const mockHighlighter = {};
export async function createHighlighterCore() {
return mockHighlighter;
}
export function createHighlighterCoreSync() {
return mockHighlighter;
}
export const getSingletonHighlighterCore = createHighlighterCore;
export function makeSingletonHighlighterCore(fn) {
return (opts) => fn(opts);
}
export function isPlainLang(lang) {
return !lang || ["plaintext", "txt", "text", "plain"].includes(lang);
}
export function isSpecialLang(lang) {
return lang === "ansi" || isPlainLang(lang);
}
export function isNoneTheme(theme) {
return theme === "none";
}
export function isSpecialTheme(theme) {
return isNoneTheme(theme);
}`;

const LANG_STUB = "export default [];";
const THEME_STUB = "export default Object.freeze({});";

return {
name: "shiki-ssr-stub",
enforce: "pre",
Expand All @@ -116,9 +146,24 @@ export default {};`;
},
},
load(id) {
if (id.startsWith("\0shiki-stub:")) {
return STUB;
if (!id.startsWith("\0shiki-stub:")) {
return;
}
const source = id.slice("\0shiki-stub:".length);
if (
source === "shiki/core" ||
source === "@shikijs/core" ||
source.startsWith("@shikijs/core/")
) {
return CORE_STUB;
}
if (source.startsWith("@shikijs/langs/")) {
return LANG_STUB;
}
if (source.startsWith("@shikijs/themes/")) {
return THEME_STUB;
}
return DEFAULT_STUB;
},
};
}
Expand Down
Loading