-
-
Notifications
You must be signed in to change notification settings - Fork 885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using react-markdown with Webpack 5 is not possible as path dependency/polyfill is missing #514
Labels
Comments
ceisele-r
added
🐛 type/bug
This is a problem
🙉 open/needs-info
This needs some more info
labels
Nov 25, 2020
ceisele-r
changed the title
Using react-markdown with Webpack 5 is straightforward as path dependency/polyfill is missing
Using react-markdown with Webpack 5 is not possible as path dependency/polyfill is missing
Nov 25, 2020
Duplicate of vfile/vfile#57 (comment) |
ChristianMurphy
added
👯 no/duplicate
Déjà vu
🙋 no/question
This does not need any changes
and removed
🐛 type/bug
This is a problem
🙉 open/needs-info
This needs some more info
labels
Nov 25, 2020
wooorm
added a commit
to vfile/vfile
that referenced
this issue
Dec 6, 2020
Many new developers do not know how to configure webpack. When they use a package that somewhere deep down uses `path` or `process` or whatnot, through webpack 5, they mistakingly think this package does not work in browsers. This infuriating mistake by webpack leads to superfluous work for maintainers and bigger bundles for users because polyfills add bloat. See: * <https://blog.sindresorhus.com/webpack-5-headache-b6ac24973bf1> * <vercel/next.js#16022> Note that this change shaves off 40% from the bundle size compared to including `path` and `process`, however, it will double the bundlephobia size (because it normally does not include path/process) and will hurt folks who depend on another project that includes `path`. Related to #16. Related to #28. Related to #38. Related to #35. Related to #56. Related to #57. Related to #58. Related to remarkjs/react-markdown#492. Related to remarkjs/react-markdown#514. Reviewed-by: Christian Murphy <[email protected]>
FWIW, fixed with
and adding to the webpack config: module.exports = {
resolve: {
fallback: { 'path': require.resolve('path-browserify') },
},
}; |
Also see https://github.com/vfile/vfile/releases/tag/4.2.1 which offers an alternative to polyfilling path |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Subject of the issue
After upgrading a project using
react-markdown
to Webpack 5, webpack compile fails because a polyfill forpath
is missing.The reason for this is that webpack 5 does no longer automatically include polyfills for core node modules.
The affected dependency tree results from
There is an issue for the underlying issue in vfile where a recent comment references the same issue ( vfile/vfile#16 (comment) ) where it seems that setting up unified to be able to run in browser now with Webpack 5 is not straightforward.
=> As a result it means that
react-markdown
is not able to be used in react projects with webpack 5 easil. Therefore, I'm creating this issue here.If changing dependencies (to avoid the dependency tree to the
path
dependency) is not an option, I think somewhere in the docs should be documented how to use react-markdown with Webpack 5.Your environment
Steps to reproduce
webpack
4 andreact-markdown
Expected behavior
react-markdown
is frontend-compatible and works without further modifications to dependencies / webpack polyfills with webpack 5.Actual behavior
See above.
The text was updated successfully, but these errors were encountered: