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

fix(gatsby): add error for missing config in theme #10739

Closed
wants to merge 2 commits into from

Conversation

jbolda
Copy link
Contributor

@jbolda jbolda commented Dec 31, 2018

Description

Adding another error to throw before nearMatch if you forget to add a gatsby-config.js to your theme. It avoids a cryptic error that nearMatch would otherwise throw.

Related Issues

None

@jbolda jbolda requested a review from DSchau December 31, 2018 17:04
@jbolda jbolda requested a review from a team as a code owner December 31, 2018 17:04
@pieh
Copy link
Contributor

pieh commented Jan 2, 2019

This will also panic when main (not theme's) gatsby-config.js is missing? If so that's not good gatsby-config is optional - ie. https://github.com/gatsbyjs/gatsby-starter-hello-world doesn't have gatsby-config file

@jbolda
Copy link
Contributor Author

jbolda commented Jan 2, 2019

Oh, I didn't realize main was optional. Yes, this will panic on main as well.

Perhaps we need to make it optional for themes then. ( If that is the intention, then we have a bug, but this example seems to imply that it is required: ChristopherBiscardi/gatsby-theme-minimal/gatsby-config.js.) /cc @ChristopherBiscardi because they said they are in the middle of a rewrite.

@pieh
Copy link
Contributor

pieh commented Jan 2, 2019

It's optional for "main site" - I don't think it makes much sense for it to be optional for themes (otherwise themes don't do anything).

@ChristopherBiscardi
Copy link
Contributor

If you don't have a gatsby-config in your theme's directory then you're really building a plugin because you're not using the theming gatsby-config composition and also not using Component Shadowing. This points at an interesting dynamic that we're sort of sidestepping right now in that plugins and themes are extremely similar. We're sidestepping that conversation because themes are under an experimental flag anyway, so they're "different" for now by nature of that "feature flag".

I'll put the branch up and PR it so that you can follow the rewrite of this area @jbolda so that you aren't in the dark on what I'm doing :)

@DSchau DSchau changed the title add error for missing config in theme fix(gatsby): add error for missing config in theme Jan 3, 2019
@jbolda
Copy link
Contributor Author

jbolda commented Jan 4, 2019

So my initial expectation was when themes move out of experimental that they would be listed in the plugins array. As it is implemented now, I don't think that is really realistic. @ChristopherBiscardi makes the point that stuck in my mind as well. A theme really is a kind of plugin, just that it has the option to use gatsby-config.js as well.

For some context why I initially thought to add this error, I was making a theme and one of the "plugins" uses gatsby-config.js to bring in the "core" components. The next "plugin" where I ran into this error is the navigation and comprises just a few components with a StaticQuery or two. Pieces of that may be something you would be interested in using the component shadowing on, so I think it makes sense to keep it more within the context of a theme. Really there is no need for a gatsby-config.js though as it is just a handful of React components.

I think it is pretty clear that this specific PR should be closed, but it feels like we should head towards making themes a new second level plugin (e.g. gastby-theme). Assuming that, all of the other top level API files (node, browser, SSR) are all optional. However, also assuming that, we do need to deal with themes slightly different and then we need to be able to assume if it is actually a theme or not somehow... do we enforce the actual naming scheme and rely on that? I think I saw @DSchau head down that route in #10786. I still need to catch up on what others are doing here, but just talking out loud a bit.

Anyways, closed.

@jbolda jbolda closed this Jan 4, 2019
@DSchau
Copy link
Contributor

DSchau commented Jan 4, 2019

@jbolda to be clear--I don't want to enforce that naming standard, that's just the best way I have now (until a @ChristopherBiscardi PR is merged) to guess that a theme is a theme.

@jbolda
Copy link
Contributor Author

jbolda commented Jan 5, 2019

It was totally clear @DSchau 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants