-
Notifications
You must be signed in to change notification settings - Fork 10.3k
fix(gatsby-remark-images): regenerate markdown when used image changes #34433
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
imjoshin
commented
Jan 11, 2022
pieh
reviewed
Jan 11, 2022
7c53aaa to
3b2de17
Compare
pieh
reviewed
Jan 15, 2022
e2e-tests/development-runtime/cypress/integration/hot-reloading/non-js-file.js
Outdated
Show resolved
Hide resolved
pieh
reviewed
Jan 15, 2022
e2e-tests/development-runtime/cypress/integration/hot-reloading/non-js-file.js
Outdated
Show resolved
Hide resolved
db0352e to
1ba3282
Compare
pieh
reviewed
Jan 18, 2022
b03db8a to
3ec061b
Compare
pieh
approved these changes
Jan 18, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for this!
This was referenced Jan 26, 2022
This was referenced Feb 14, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Images seen in markdown are not actually registered as node dependencies for the given page. This PR does two things to solve this:
getRemarkFileDependencyfunction fromgatsby-transformer-remarkdown togatsby-remark-imageswhich uses the[findOne](https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/node-model.js#L365)query instead, which registers a dependency to the markdown node internally.gatsby-transformer-remarkthat, when a change is detected from the bullet point above, allows the transformer to check if any dependencies of the markdown node has changed (by comparingcontentDigests from what they were previously)This change is also backwards compatible both ways. If
gatsby-transformer-remarkis not up to date, it will not passgetRemarkFileDependencyandgatsby-remark-imageswill use the old method. Ifgatsby-remark-imagesis not up to date, it will ignore the passedgetRemarkFileDependencyand continue with the old method.Documentation
No documentation updates should be needed, as the external contract hasn't changed.
Testing
There's one unit test to validate that the
gatsby-remark-imagesplugin calls the passed function and generates the expected result. I also added an e2e snapshot test for development that will check if the image updates properly.If you'd like to validate this locally:
gatsby new blog https://github.com/gatsbyjs/gatsby-starter-blogyarn watch --scope={gatsby,gatsby-transformer-remark,gatsby-remark-images}in your gatsby repogatsby-devin your blog sitegatsby-developin your blog sitesalty_egg.jpgimageRelated Issues
[sc-35770]