{"record":{"id":"cf9465426b43bc96","repo":"withastro/astro","slug":"to-inherit-markdown-plugins-in-mdx-please-use-exp","errorCode":null,"errorMessage":"To inherit Markdown plugins in MDX, please use explicit imports in your config instead of \"strings.\" See Markdown docs: https://docs.astro.build/en/guides/markdown-content/#markdown-plugins","messagePattern":"To inherit Markdown plugins in MDX, please use explicit imports in your config instead of \"strings\\.\" See Markdown docs: https://docs\\.astro\\.build/en/guides/markdown-content/#markdown-plugins","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/integrations/mdx/src/utils.ts","lineNumber":103,"sourceCode":"\t};\n}\n\nexport function ignoreStringPlugins(plugins: any[], logger: AstroIntegrationLogger): PluggableList {\n\tlet validPlugins: PluggableList = [];\n\tlet hasInvalidPlugin = false;\n\tfor (const plugin of plugins) {\n\t\tif (typeof plugin === 'string') {\n\t\t\tlogger.warn(`${colors.bold(plugin)} not applied.`);\n\t\t\thasInvalidPlugin = true;\n\t\t} else if (Array.isArray(plugin) && typeof plugin[0] === 'string') {\n\t\t\tlogger.warn(`${colors.bold(plugin[0])} not applied.`);\n\t\t\thasInvalidPlugin = true;\n\t\t} else {\n\t\t\tvalidPlugins.push(plugin);\n\t\t}\n\t}\n\tif (hasInvalidPlugin) {\n\t\tlogger.warn(\n\t\t\t`To inherit Markdown plugins in MDX, please use explicit imports in your config instead of \"strings.\" See Markdown docs: https://docs.astro.build/en/guides/markdown-content/#markdown-plugins`,\n\t\t);\n\t}\n\treturn validPlugins;\n}\n","sourceCodeStart":85,"sourceCodeEnd":109,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/integrations/mdx/src/utils.ts#L85-L109","documentation":"This is the one-time follow-up guidance emitted by ignoreStringPlugins() in @astrojs/mdx after at least one string-named markdown plugin was discarded. It explains why the preceding 'not applied' warnings happened: MDX cannot inherit string plugins from the markdown config, and points to the Markdown docs section on plugin imports. It is purely informational on top of the real problem (plugins were dropped).","triggerScenarios":" Any build or dev run where config.markdown.remarkPlugins/rehypePlugins contained at least one string or string-headed tuple, causing hasInvalidPlugin to be set true in ignoreStringPlugins() when the MDX integration reads the markdown config.","commonSituations":" Seen together with the per-plugin 'not applied' warnings; typically the first symptom a developer notices that their GFM tables, external-link handling, or math rendering work in .md pages but not in .mdx pages.","solutions":["Fix the underlying issue: convert every string plugin in markdown.remarkPlugins/rehypePlugins to an imported function (this warning disappears with them).","If a plugin cannot be imported (e.g. CJS-only), import it via createRequire or use its ESM entry, still passing the function value.","Verify by rebuilding: no 'not applied' lines and no 'To inherit Markdown plugins' guidance should print."],"exampleFix":"// before\nremarkPlugins: ['remark-gfm', ['remark-math', {}]]\n\n// after\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\nremarkPlugins: [remarkGfm, [remarkMath, {}]]","handlingStrategy":"validation","validationCode":"// fail fast in a config-check script\nimport { remarkPlugins, rehypePlugins } from './astro.config.mjs';\nconst offenders = [...remarkPlugins, ...rehypePlugins].filter(\n  (p) => typeof p === 'string' || (Array.isArray(p) && typeof p[0] === 'string'),\n);\nif (offenders.length) {\n  throw new Error(`String plugins will not apply to MDX: ${offenders.join(', ')}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fix the string plugins flagged by the per-plugin 'not applied' warnings; this guidance warning disappears with them.","Keep a shared plugins.ts module exporting only imported functions and spread it into the config.","Review the markdown-content docs plugin section when adding new remark/rehype packages."],"tags":["mdx","plugins","guidance","markdown","config"],"backgroundTag":"invalid-plugin-config","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}