From 207cc7b1906b5e85e599ad0a65b99b1b039db9f0 Mon Sep 17 00:00:00 2001 From: Seydi Charyyev Date: Wed, 20 May 2026 10:31:42 +0500 Subject: [PATCH] Addon-Docs: Resolve providerImportSource to a path instead of a file:// URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `import.meta.resolve()` returns a file:// URL in Node ESM. The MDX compiler emits that value verbatim as the import specifier for `providerImportSource`, and Vite's import-analysis plugin cannot resolve file:// URL specifiers — so .mdx files fail to compile. Wrap both `providerImportSource` resolutions (the Vite plugin and the webpack preset) in `fileURLToPath()`, matching how `mdx` and the MDX `loader` are already resolved in the same files. Fixes #34545 --- code/addons/docs/src/mdx-plugin.ts | 6 +++++- code/addons/docs/src/preset.ts | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/code/addons/docs/src/mdx-plugin.ts b/code/addons/docs/src/mdx-plugin.ts index 3873da8bae31..49f8a0969038 100644 --- a/code/addons/docs/src/mdx-plugin.ts +++ b/code/addons/docs/src/mdx-plugin.ts @@ -1,3 +1,5 @@ +import { fileURLToPath } from 'node:url'; + import type { Options } from 'storybook/internal/types'; import { createFilter } from '@rollup/pluginutils'; @@ -36,7 +38,9 @@ export async function mdxPlugin(options: Options): Promise { const mdxLoaderOptions: CompileOptions = await presets.apply('mdxLoaderOptions', { ...mdxPluginOptions, mdxCompileOptions: { - providerImportSource: import.meta.resolve('@storybook/addon-docs/mdx-react-shim'), + providerImportSource: fileURLToPath( + import.meta.resolve('@storybook/addon-docs/mdx-react-shim') + ), ...mdxPluginOptions?.mdxCompileOptions, rehypePlugins: [ ...(mdxPluginOptions?.mdxCompileOptions?.rehypePlugins ?? []), diff --git a/code/addons/docs/src/preset.ts b/code/addons/docs/src/preset.ts index f65bf06b228a..315489865720 100644 --- a/code/addons/docs/src/preset.ts +++ b/code/addons/docs/src/preset.ts @@ -49,7 +49,9 @@ async function webpack( const mdxLoaderOptions: CompileOptions = await options.presets.apply('mdxLoaderOptions', { ...mdxPluginOptions, mdxCompileOptions: { - providerImportSource: import.meta.resolve('@storybook/addon-docs/mdx-react-shim'), + providerImportSource: fileURLToPath( + import.meta.resolve('@storybook/addon-docs/mdx-react-shim') + ), ...mdxPluginOptions.mdxCompileOptions, rehypePlugins: [ ...(mdxPluginOptions?.mdxCompileOptions?.rehypePlugins ?? []),