missing dependency makes import fail with yarn 2
It is important with yarn v2+ that all your dependencies you use are included in your package.json
By default right now this fails due to a requirement for module rehype-prism-plus. That is not in your dependencies. I am guessing it is depended on by another dependency, which is no longer allowed with yarn v2.
It would be ideal if y'all could simply add that as a dependency.
Once I did this, everything worked fine with my setup. Thanks!
For those running into this, had to edit .yarnrc.yml and have:
packageExtensions:
"@uiw/react-md-editor@*":
dependencies:
"rehype-prism-plus": "*"
I'm not using yarn 2 and I'm not sure why the problem occurs.
@uiw/[email protected]
└─┬ @uiw/[email protected]
└── [email protected]
It doesn't seem to lack rehype-prism-plus dependencies.
@bradennapier
react-md-editor imports it directly, making it a dependency of this package as well as of the markdown preview so it should be in the dependencies.
My understanding is not so. Whether to depend on rehype-prism-plus depends on @uiw/react-markdown-preview.
@bradennapier
Previously, we also replaced @mapbox/rehype-prism with the dependency rehype-prism-plus。
- https://github.com/uiwjs/react-markdown-preview/commit/47a681cea4c33334d6f39b1c9e44c46a6390fd9a
https://github.com/uiwjs/react-md-editor/blob/master/src/components/TextArea/Markdown.tsx#L3
react-md-editor directly depends on the package here, making it a direct dependency of react-md-editor as well. While previously yarn and npm still allow it as long as one of the dependencies of yours has it as their dependency, but it is still invalid and with yarn 2 they made it an error (which has to be resolved by adding a package extension that fixes your package json).
No one can use this package if they use yarn 2.
Main Information: https://yarnpkg.com/advanced/rulebook#packages-should-only-ever-require-what-they-formally-list-in-their-dependencies
https://yarnpkg.com/getting-started/migration#fix-dependencies-with-packageextensions
and
https://yarnpkg.com/getting-started/migration#a-package-is-trying-to-access-another-package-
@bradennapier How should I fix it to support yarn 2?
I'm also encountering this issue while trying to migrate from npm to pnpm, which treats dependencies in a similarly strict fashion.
Like @bradennapier said, modules directly imported from this library need to be included as a dependency in your package.json file.
@data-enabler This issue has been resolved.
I believe this commit is actually breaking my jest tests. "SyntaxError: Cannot use import statement outside a module"
The previous version of react-md-editor (3.23.3) did not have a /node_modules/@uiw/react-markdown-preview/node_modules directory, but this update (3.23.4) does and it contains refractor and rehype-prism-plus. If I manually delete that directory, my tests pass. Clearly, that's not the right way to do it. :)
Also of note: /node_modules/@uiw/react-markdown-preview/package.json specifies "rehype-prism-plus": "~1.5.0" and /node_modules/@uiw/react-md-editor/package.json (which I believe is the troublemaker?) specifies "rehype-prism-plus": "~1.6.1"
Maybe it's a version mismatch, maybe something else.
I'm on Yarn v1.22.19.
@bradennapier Synchronized the version of rehype-prism-plus.
@bradennapier Synchronized the version of
rehype-prism-plus.
Worked great! Thank you!