Skip to content
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 inconsistent hashes using development vs production bundles/exports conditions #3270

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

emmatown
Copy link
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.

Copy link

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

Copy link

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
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
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
13 checks passed
@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