fix(gatsby): fallback for non-existing config #13948
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a proposed way of doing it, I would love to have feedback or a conversation on how to fix/address this in a more Gatsby way.
Description
I found that with changing from Gatsby
v2.3.36
tov2.4.2
, a Gatsby website would not be able to be served usinggatsby serve
when there is nogatsby-config.js
file in the root folder of the project. This was due to the destructuring on line 72 in thegatsby/src/commands/serve.js
file, which threw aTypeError
when the command tried to destructure fromundefined
.I tried to solve this error by having a fallback to an empty object. But another (and maybe better) approach could also be that it is clearly documented as a needed file in the structure and to add it to the
gatsby-starter-hello-world
Starter project.Related Issues
This issue was addressed in #13910