remarkjs / react-markdown

Markdown component for React
https://remarkjs.github.io/react-markdown/
MIT License
13.25k stars 874 forks source link

[vite]: Rollup failed to resolve import "#minpath" from "node_modules/vfile/lib/index.js". #864

Closed ahmedrowaihi closed 1 month ago

ahmedrowaihi commented 1 month ago

Initial checklist

Affected packages and versions

react-markdown@9.0.1, vfile@6.x.x

Link to runnable example

scaffold a react app with vite

Steps to reproduce

Expected behavior

it should use the minpath.browser, minproc.browser, minurl.browser imports

Actual behavior

it fails to use correct imports

Affected runtime and version

node@v22.3.0, vite@3.x.x

Affected package manager and version

No response

Affected OS and version

No response

Build and bundle tools

Rollup

ahmedrowaihi commented 1 month ago

a temporary fix, is patching the vfile package

diff --git a/node_modules/vfile/lib/index.js b/node_modules/vfile/lib/index.js
index 68db7f9..84cebfd 100644
--- a/node_modules/vfile/lib/index.js
+++ b/node_modules/vfile/lib/index.js
@@ -9,9 +9,9 @@
  */

 import {VFileMessage} from 'vfile-message'
-import {minpath} from '#minpath'
-import {minproc} from '#minproc'
-import {urlToPath, isUrl} from '#minurl'
+import {minpath} from './minpath.browser'
+import {minproc} from './minproc.browser'
+import {urlToPath, isUrl} from './minurl.browser'

 /**
  * Order of setting (least specific to most), we need this because otherwise

you can use it with patch-package or whatever

ChristianMurphy commented 1 month ago

It's a bug in vite's export resolution. This was fixed several major versions ago in vite. Upgrade your vite version.

github-actions[bot] commented 1 month ago

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

ahmedrowaihi commented 1 month ago

yes, I added it for the community in case someone will hit this issue and have no option to migrate vite

gabrieljablonski commented 1 month ago

yes, I added it for the community in case someone will hit this issue and have no option to migrate vite

and thanks for that. I'm running v3, and there's no way in hell i'm upgrading my bundler because of 3 lines of code on a dependency of a dependency 😂