Skip to content

Commit e0b4466

Browse files
🐛 fix(compiler): bridge @mdx-js/rollup Plugin types for Vite 8
Vite 8 Plugin is rolldown-typed while @mdx-js/rollup still exports rollup.Plugin; SourceMapInput shapes diverge at the type level. Bridge through unknown so createMdxPlugin can return Plugin[] without weakening the rest of the Vite plugin surface. Keeps tsrs --noEmit green.
1 parent 883645c commit e0b4466

1 file changed

Lines changed: 27 additions & 15 deletions

File tree

‎site/compiler/content/mdxPlugin.ts‎

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,35 @@ function mdxHmrPlugin(): Plugin {
5050
};
5151
}
5252

53+
// @mdx-js/rollup is typed as rollup.Plugin; Vite 8's Plugin is rolldown-based.
54+
// Runtime is fine (Vite still consumes rollup-shaped hooks), but SourceMapInput
55+
// diverges at the type level, so bridge through unknown instead of weakening
56+
// the rest of the Vite plugin surface.
57+
function asVitePlugin(plugin: object): Plugin {
58+
return plugin as unknown as Plugin;
59+
}
60+
5361
export function createMdxPlugin(): Plugin[] {
5462
return [
55-
mdx({
56-
include: /\.(md|mdx)$/,
57-
providerImportSource: normalizePath(resolve(import.meta.dirname, '../../app/mdx-components')),
58-
// rehype-raw expands the raw HTML nodes that `.md` format keeps around
59-
// (details/summary/kbd/div, entities); without it @mdx-js/mdx's
60-
// rehypeRemoveRaw silently drops that markup for `format: 'md'` files
61-
// such as the CHANGELOG.md fallback. It is a no-op for `.mdx` since
62-
// authored JSX never produces `raw` hast nodes.
63-
rehypePlugins: [
64-
[rehypeRaw, { passThrough: mdxPassThroughNodeTypes }],
65-
rehypeHeadingIds,
66-
rehypeTocExport,
67-
],
68-
remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter, remarkGfm, remarkApi],
69-
}),
63+
asVitePlugin(
64+
mdx({
65+
include: /\.(md|mdx)$/,
66+
providerImportSource: normalizePath(
67+
resolve(import.meta.dirname, '../../app/mdx-components'),
68+
),
69+
// rehype-raw expands the raw HTML nodes that `.md` format keeps around
70+
// (details/summary/kbd/div, entities); without it @mdx-js/mdx's
71+
// rehypeRemoveRaw silently drops that markup for `format: 'md'` files
72+
// such as the CHANGELOG.md fallback. It is a no-op for `.mdx` since
73+
// authored JSX never produces `raw` hast nodes.
74+
rehypePlugins: [
75+
[rehypeRaw, { passThrough: mdxPassThroughNodeTypes }],
76+
rehypeHeadingIds,
77+
rehypeTocExport,
78+
],
79+
remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter, remarkGfm, remarkApi],
80+
}),
81+
),
7082
mdxHmrPlugin(),
7183
];
7284
}

0 commit comments

Comments
 (0)