-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[gatsby-plugin-mdx] create-webpack-config loader paths in pnpm context #23265
Comments
IMO, those loaders should be resolved to absolute paths. I'd probably do it like this, but it amounts to the same thing: loader: require.resolve(
`gatsby-plugin-mdx/loaders/mdx-components`
),
Those are peer dependencies for Your plugin could easily add them to the webpack config, though: // gatsby-node.js
const path = require('path');
const resolve = (pkg) => path.dirname(require.resolve(`${pkg}/package.json`))
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
resolve: {
alias: {
'@mdx-js/mdx': resolve('@mdx-js/mdx'),
'@mdx-js/react': resolve('@mdx-js/react'),
}
}
});
} |
However, I think you might be able to solve the issues with export { MDXRenderer } from 'gatsby-plugin-mdx'; And import that from the consumer of your plugin? Theoretically, that should take care of the context of |
The onCreateWebpackConfig worked great for pushing the peer dependencies up into my plugin, thank you. The concrete site is actually not using the MDXRenderer directly, as all the templates are provided by my plugin. I am not sure what you mean with "those loaders should be resolved to absolute paths" as they already are in that format currently.
|
Maybe it would help to see your repo, or a simplified example.
FS absolute, not “Node” absolute. Using a (real) absolute path means Webpack doesn’t have to do any resolution to find the file. |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Thanks again for being part of the Gatsby community! 💪💜 |
Coming from #21950
In a pnpm context with a site depending on a plugin which depends on gatsby-plugin-mdx the gatsby-plugin-mdx config wont work.
Original
Has the problem that webpack running within the actual site root can't resolve the loader at that path, as the actual path would be:
node_modules/other_plugin/node_modules/gatsby-plugin-mdx/loaders/mdx-components
.Changing to the following seems to fix these loaders.
Though building the site will still require adding these to its package.json
as they are not added to the resolve config.
The text was updated successfully, but these errors were encountered: