atlassian-labs / compiled

A familiar and performant compile time CSS-in-JS library for React.
https://compiledcssinjs.com
Apache License 2.0
1.99k stars 67 forks source link

Throw an error when mixing `extract: true` and `classHashPrefix` configuration options to avoid unsupported usage and bundle size bloat. #1724

Closed kylorhall-atlassian closed 1 week ago

kylorhall-atlassian commented 2 weeks ago

What is this change?

Following https://github.com/atlassian-labs/compiled/pull/1717, throws an error when Parcel attempts to transform or Webpack's CompiledExtractPlugin is initialized with both extract: true and classHashPrefix being defined.

Why are we making this change?

To avoid unsupported usage and bundle size creep as adding 5 bytes to every class is not something we want to generally promote and instead classHashPrefix is only desired as a temporary workaround to avoid conflicts in scenarios where non-extraction is used.

How are we making this change?

Into the Parcel Transformer and Webpack Loader, the entrypoints where this configuration bleeds in. Technically this wasn't documented properly for @compiled/webpack-loader, so I adjusted it briefly, but kept the throw new Error in place to avoid this (as it would still be passed through, I'd gather).


PR checklist

changeset-bot[bot] commented 2 weeks ago

🦋 Changeset detected

Latest commit: 035de35ea13d48a0c79e3177022cef21e14a6752

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

This PR includes changesets to release 4 packages | Name | Type | | ---------------------------- | ----- | | @compiled/parcel-transformer | Minor | | @compiled/webpack-loader | Minor | | @compiled/babel-plugin | Patch | | @compiled/parcel-config | 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

netlify[bot] commented 2 weeks ago

Deploy Preview for compiled-css-in-js ready!

Name Link
Latest commit 035de35ea13d48a0c79e3177022cef21e14a6752
Latest deploy log https://app.netlify.com/sites/compiled-css-in-js/deploys/6711cbb670de5c000838e143
Deploy Preview https://deploy-preview-1724--compiled-css-in-js.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.