-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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-remark-images): regenerate markdown when used image changes #34433
Merged
Conversation
This file contains 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
gatsbot
bot
added
the
status: triage needed
Issue or pull request that need to be triaged and assigned to a reviewer
label
Jan 9, 2022
imjoshin
commented
Jan 11, 2022
pieh
reviewed
Jan 11, 2022
LekoArts
added
topic: remark/mdx
Related to Markdown, remark & MDX ecosystem
and removed
status: triage needed
Issue or pull request that need to be triaged and assigned to a reviewer
labels
Jan 11, 2022
imjoshin
changed the title
WIP: fix(gatsby): Fix no change seen in gatsby-transformer-remark/gatsby-remark-images integration when an image dependency changes
fix(gatsby): Fix no change seen in gatsby-transformer-remark/gatsby-remark-images integration when an image dependency changes
Jan 13, 2022
imjoshin
force-pushed
the
fix/remark-image-cache
branch
from
January 13, 2022 21:55
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
imjoshin
force-pushed
the
fix/remark-image-cache
branch
from
January 17, 2022 14:21
db0352e
to
1ba3282
Compare
pieh
reviewed
Jan 18, 2022
imjoshin
force-pushed
the
fix/remark-image-cache
branch
from
January 18, 2022 20:05
b03db8a
to
3ec061b
Compare
pieh
changed the title
fix(gatsby): Fix no change seen in gatsby-transformer-remark/gatsby-remark-images integration when an image dependency changes
fix(gatsby-remark-images): regenerate markdown when used image changes
Jan 18, 2022
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:
getRemarkFileDependency
function fromgatsby-transformer-remark
down togatsby-remark-images
which 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-remark
that, 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 comparingcontentDigest
s from what they were previously)This change is also backwards compatible both ways. If
gatsby-transformer-remark
is not up to date, it will not passgetRemarkFileDependency
andgatsby-remark-images
will use the old method. Ifgatsby-remark-images
is not up to date, it will ignore the passedgetRemarkFileDependency
and 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-images
plugin 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-blog
yarn watch --scope={gatsby,gatsby-transformer-remark,gatsby-remark-images}
in your gatsby repogatsby-dev
in your blog sitegatsby-develop
in your blog sitesalty_egg.jpg
imageRelated Issues
[sc-35770]