-
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-plugin-sharp): Handle diff duotone settings #35075
Conversation
Should we also try to fix it in the upstream dependency because there might be other cases we're not aware of |
A "fix" for it would be |
Here's a working change at https://github.com/SkeLLLa/node-object-hash/blob/master/src/objectSorter.ts#L208:
I think it may be worth asking so we don't get bit by this again. I could also see it as an opt-in flag on their config. |
const { pathPrefix, duotone, ...rest } = args | ||
const options = Object.assign(rest, duotone) |
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.
is this correct ? It seems to me like it would "flatten" duotone
:
// some example
const args = { foo: `bar`, duotone: { wat: true }, a: 5 }
const { pathPrefix, duotone, ...rest } = args
const TEST = Object.assign(rest, duotone)
// TEST = {foo: 'bar', a: 5, wat: true}
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.
options is only used for the digest, args
is used for options
return so should be fine
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.
oh, right - then my suggestions would be to rename options
to something else just to indicate it's not really "options" anymore as shape is different (just to avoid confusion as I had above if someone read it some time later). Ideally with some comment with context
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.
@pieh Done
I wonder if instead we should adjust hasher to handle |
Description
The
createArgsDigest(options)
receives anoptions
with the following input:The
node-object-hash
doesn't recognize the[Object: null prototype]
as an object an gives it theunknown
type. So in the hashing then the contents ofduotone
don't make a difference.We probably didn't catch this yet as while
transformOptions
also has the same null prototype (Googling pointed me towards GraphQL), we spread it: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-sharp/src/image-data.ts#L220Since
duotone
is the only key that is an object, the one-off destructuring for duotone is fine IMORelated Issues
Fixes #35054