Skip to content

Fix inconsistent hashes using development vs production bundles/exports conditions#3270

Merged
emmatown merged 2 commits intomainfrom
consistent-hashes-dev-prod
Nov 20, 2024
Merged

Fix inconsistent hashes using development vs production bundles/exports conditions#3270
emmatown merged 2 commits intomainfrom
consistent-hashes-dev-prod

Conversation

@emmatown
Copy link
Copy Markdown
Member

@emmatown emmatown commented Nov 12, 2024

Fixes #3222

Arguably this isn't really a bug in Emotion since tools like Next should use the conditions on external code correctly (it works correctly with the App Router since they bundle everything) but the reality is like this and the fix makes it less complex anyway imo.

This will sort of "break" source maps in older versions of the babel plugin with new versions of the runtime and vice versa but since it's only breaking source maps, I think that's fine.

Also, I checked the swc emotion plugin and it doesn't seem to do the particular optimisations that the Babel plugin does so it doesn't need to change.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Nov 12, 2024

🦋 Changeset detected

Latest commit: 0398290

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@emotion/serialize Patch
@emotion/styled Patch
@emotion/cache Patch
@emotion/utils Patch
@emotion/css Patch
@emotion/react Patch
@emotion/babel-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci Bot commented Nov 12, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Comment on lines +2 to +8
'@emotion/serialize': patch
'@emotion/styled': patch
'@emotion/cache': patch
'@emotion/utils': patch
'@emotion/css': patch
'@emotion/react': patch
'@emotion/babel-plugin': patch
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm releasing extra packages than necessary just so people can more easily can bump the thing they directly depend on rather than refreshing whole lock files.

Comment on lines -434 to -439
if (isDevelopment) {
styles = styles.replace(sourceMapPattern!, match => {
sourceMap = match
return ''
})
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual part that makes the hashes consistent

@emmatown emmatown marked this pull request as ready for review November 13, 2024 00:17
@emmatown emmatown requested a review from Andarist November 13, 2024 00:21
@emmatown emmatown merged commit 77d930d into main Nov 20, 2024
@emmatown emmatown deleted the consistent-hashes-dev-prod branch November 20, 2024 01:05
@github-actions github-actions Bot mentioned this pull request Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hydration errors in development for Next.js app with MUI Material v5 after updating emotion dependencies

1 participant