Skip to content
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 doesn't find local plugins? #23194

Closed
kylegillen opened this issue Apr 16, 2020 · 5 comments
Closed

gatsby-plugin-mdx doesn't find local plugins? #23194

kylegillen opened this issue Apr 16, 2020 · 5 comments
Labels
help wanted Issue with a clear description that the community can help with.

Comments

@kylegillen
Copy link

kylegillen commented Apr 16, 2020

Is this expected? Known issue?

{
  resolve: `gatsby-plugin-mdx`,
  options: {
    gatsbyRemarkPlugins: [
      `my-local-plugin`, // doesn't work
      {
        resolve: require.resolve('path-to-my-local-plugin') // works
      }
    ]
  }
}
@kylegillen kylegillen added the type: bug An issue or pull request relating to a bug in Gatsby label Apr 16, 2020
@gatsbot gatsbot bot added the type: question or discussion Issue discussing or asking a question about Gatsby label Apr 16, 2020
@wardpeet
Copy link
Contributor

Hey @nextriot, it's more like a feature request. This can be handled by gatsby-plugin-mdx.

We're happy to get pull requests.

@wardpeet wardpeet added help wanted Issue with a clear description that the community can help with. and removed type: bug An issue or pull request relating to a bug in Gatsby type: question or discussion Issue discussing or asking a question about Gatsby labels Apr 17, 2020
@Js-Brecht
Copy link
Contributor

@wardpeet do you think it would it make sense to export resolvePlugin() from Gatsby core (or gatsby-core-utils, maybe?), effectively making it a public API? Any plugins that can be extended by additional plugins could then use it to resolve those extensions, and easily remain consistent with Gatsby's behavior.

@pieh
Copy link
Contributor

pieh commented Apr 20, 2020

There are lots of interconnected issues here. Especially if the gatsby-plugin-mdx is declared in theme and not in top-level gatsby-config:

Note that the issues mostly talk about subplugins being npm packages, but it's actually the same problem for local plugins

Exporting resolvePlugin alone wouldn't be enough - there would also need to be some metadata of location of gatsby-config that declare given plugin to be able to resolve correctly (to use as rootDir param of `resolvePlugin).

On top of that, check this comment #8379 (comment) about work on "selective cache invalidation" - for this to work Gatsby core will need to know about relationships between plugins/subplugins to properly clear caches and exporting resolvePlugin will "hide" this information from core, meaning that "selective cache invalidation" won't have enough information to work properly.

@Js-Brecht
Copy link
Contributor

Js-Brecht commented Apr 20, 2020

Definitely a lot more going on than it appears at first glance 😄

for this to work Gatsby core will need to know about relationships between plugins/subplugins to properly clear caches and exporting resolvePlugin will "hide" this information from core, meaning that "selective cache invalidation" won't have enough information to work properly.

I hadn't even thought about Gatsby needing to track what was resolving the sub-plugins! It makes perfect sense, though, how an export wouldn't work.

@pieh
Copy link
Contributor

pieh commented Apr 21, 2020

I'll close this issue, because the problem is already captured in #21592 and there's no point in having duplicates.

The resolvePlugin option is also already mention there (as well as some limitation of this approach)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issue with a clear description that the community can help with.
4 participants