-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Change webpack peer dependency to optional in loader #2440
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all modern package managers install peer dependencies. They don’t install optional peer dependencies. The ones that don’t install peer dependencies merely show a warning, which is annoying, but not an error.
The webpack
peer dependency exists for 2 reasons:
- To indicate this is only compatible with Webpack versions 5 or greater.
- For the type definitions, which users may or may not use. This is really similar to the
@types/react
peer dependency, which was discussed in react: fix to classify@types/react
as a peer dependency #2281. We ended up not using optional peer dependencies there.
typescript users that use rspack should likely still have webpack for types to work? If rspack supports webpack loaders, we don’t have to change the docs from webpack loader to webpack or rspack loader. Rspack users know that they can use webpack loaders. |
Co-authored-by: Remco Haszing <[email protected]> Signed-off-by: neverland <[email protected]>
Thank you for all the review comments, I have updated the PR content, just treating webpack as an optional peer dependency. |
How do you configure loaders such as this in rspack then? |
The loader configuration in Rspack is completely the same as webpack. As far as I know, at present, both webpack and Rspack do not provide type inference for loaders because loaders are registered in the webpack configuration through the loader's name or path, not by importing a loader package. In my use case, I manually imported the type exported by https://github.com/web-infra-dev/rsbuild/blob/main/packages/plugin-mdx/src/index.ts#L2-L14 |
You can use TS outside of |
This is a great method 👍🏻 As far as I know, |
This is true. However, the package also exports the type of the loader, which does depend on the webpack types. I’m indifferent on whether or not the webpack peer dependency should be optional. I do welcome the documentation change. |
I’m fine with trying this out. But I am very worried about things breaking. |
Thank you :) |
Thank you for your time ❤️ |
Initial checklist
Description of changes
Rspack is a fast Rust-based web bundler and it is compatible with the architecture and ecosystem of webpack.
The
@mdx-js/loader
can be used with Rspack, but users will get a peer dependency warning, adding peerDependenciesMeta can resolve it.The same as: jantimon/html-webpack-plugin#1829