use alternative Set concatenation syntax to avoid babel spread bug #2680
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 one-line PR to fix an unusual babel issue created by the
Set()
syntax added in #2452Background: that prior PR worked and tested without issue, and was fine in my local application when running against a source copy of gatsby. But when installing the latest gatsby release normally, the recursion prevention was behaving very differently.
After much headache, I finally tracked it down to mangled syntax coming out of babel when using the
loose:true
option and creating a Set() using spread syntax. The tests were running fine, as was anything against thesrc/
, but thedist/
created by babel was distorting the line in question.This line (https://github.com/jasonphillips/gatsby/blob/3e96d498cc42b0268c7aa8e113236e0346eab5b2/packages/gatsby/src/schema/infer-graphql-input-fields-from-fields.js#L47):
Was being converted by babel to this:
-- and the latter does not equate to the former. Since the erroneous code is only in the babel
dist/
output, thejest
testing wasn't running into it. This mangling only occurs whenloose
mode is set to true. I documented a minimal reproduction of this issue here in a gist: https://gist.github.com/jasonphillips/57c1f8f9dbcd8b489dafcafde4fcdba6The alternative syntax in this PR survives babel's transformation unchanged, and
Array.from()
should be perfectly safe in all versions of node supported.