-
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
plugins defined by themes can't be resolved in some cases #21589
Comments
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! 💪💜 |
Description
Gatsby is currently always using project directory when resolving absolute paths for plugins:
gatsby/packages/gatsby/src/bootstrap/load-plugins/load.js
Lines 87 to 102 in 9b2d51b
The
rootDir
is always project root even is given plugin was declared by a theme and a theme has it in list of dependencies.Confirmed after adding some custom debug logs (that's example from using our
e2e-tests/themes/production-runtime
- in particular I added marker forgatsby-plugin-page-creator
declared by theme we use (https://github.com/gatsbyjs/gatsby/blob/master/e2e-tests/themes/gatsby-theme-about/gatsby-config.js) - look forfrom-theme (hello)
in output. It still usesgatsby/e2e-tests/themes/production-runtime
as root, but it should use path to a theme (gatsby-theme-about) as root:Steps to reproduce
It's not quite clear how to reproduce when this cause actual build/develop errors. I have some reproduction ( https://github.com/pieh/gatsby-default-with-gatsby-theme-blog-version-missmatch ) but problem here there is another issue (
gatsby-plugin-mdx
specific, where fixing this error alone won't solve the issue in the reproduction - that's becausegatsby-plugin-mdx
uses custom fieldgatsbyRemarkPlugins
to define subplugins that is not processed by gatsby core - there will be separate issue for that).So only way to verify fix is manual logging I think (Unless we are able to create theme that would remark instead of mdx and maybe similar thing would happen)
How to fix
Without doing major refactoring of gatsby-config merging and plugin loading I think we can fix this issue by adding additional field during
gatsby-config
traversal ( https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/bootstrap/load-themes/index.js ) that would specifygatsby-config
location where given plugin instance was declared. This field would need to be ignore when we merge duplicate plugins ( https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/utils/merge-gatsby-config.js#L52-L55 ) and finally used inload-plugins
section to correctly usecreateRequireFromPath
using that field instead ofrootDir
always (might need to look out for main gatsby-config being special case)The text was updated successfully, but these errors were encountered: