diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts index a520920cf..6fb96de9a 100644 --- a/packages/integrations/mdx/src/index.ts +++ b/packages/integrations/mdx/src/index.ts @@ -66,11 +66,11 @@ export default function mdx(partialMdxOptions: Partial = {}): Integr }); const extendMarkdownConfig = - partialMdxOptions.extendMarkdownConfig ?? defaultOptions.extendMarkdownConfig; + partialMdxOptions.extendMarkdownConfig ?? defaultMdxOptions.extendMarkdownConfig; const mdxOptions = applyDefaultOptions({ options: partialMdxOptions, - defaults: extendMarkdownConfig ? config.markdown : defaultOptions, + defaults: withDefaultMdxOptions(extendMarkdownConfig ? config.markdown : markdownConfigDefaults), }); const mdxPluginOpts: MdxRollupPluginOptions = { @@ -185,14 +185,20 @@ export default function mdx(partialMdxOptions: Partial = {}): Integr }; } -const defaultOptions: MdxOptions = { - ...markdownConfigDefaults, +const defaultMdxOptions = { extendMarkdownConfig: true, recmaPlugins: [], remarkPlugins: [], rehypePlugins: [], remarkRehype: {}, -}; +} + +function withDefaultMdxOptions(markdownConfig: typeof markdownConfigDefaults): MdxOptions { + return { + ...markdownConfig, + ...defaultMdxOptions, + }; +} function applyDefaultOptions({ options, diff --git a/packages/integrations/mdx/src/plugins.ts b/packages/integrations/mdx/src/plugins.ts index a7d24d3f2..cff09eae8 100644 --- a/packages/integrations/mdx/src/plugins.ts +++ b/packages/integrations/mdx/src/plugins.ts @@ -179,7 +179,7 @@ export function getRehypePlugins(mdxOptions: MdxOptions): MdxRollupPluginOptions return rehypePlugins; } -function ignoreStringPlugins(plugins: any[]) { +function ignoreStringPlugins(plugins: any[]): PluggableList { let validPlugins: PluggableList = []; let hasInvalidPlugin = false; for (const plugin of plugins) {