-
Notifications
You must be signed in to change notification settings - Fork 67
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
CSS Map alternative compilation approach #1496
Conversation
Co-authored-by: Jake Lane <[email protected]>
Co-authored-by: Jake Lane <[email protected]>
🦋 Changeset detectedLatest commit: 717b429 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
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 |
ef4bcce
to
4738f0d
Compare
foo && styles["danger"], | ||
props.foo && styles["danger"], | ||
styles.success, | ||
styles["danger"], |
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 it worth statically embedding this? We can reduce the amount of runtime code by directly injecting the classnames we know here
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.
Good idea 👍
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.
I want to minimise statical evaluation (which is 🐰🕳️). I am going to leave this job to the bundler.
I just tested a JFE Webpack/Parcel prod build. It inlines the variable well.
const foo = { bar: '.aaaabbbb' }
<div className={foo.bar} />
to
<div className={'.aaaabbbb'} />
Co-authored-by: Jake Lane <[email protected]>
Can you please add some unit tests for correct usage of the API and some VR tests? |
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.
What happens if the key is not in the css map?
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.
then class name will be undefined and stripped out by ax
. The idea is to reply on type safety to detect problems, instead of build-time errors.
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.
makes sense, I assume that should help reduce the impact on build time
Sure! |
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.
Nice work!
This PR presents a different compilation approach compared to #1492.
It transforms
to
The benefits are:
styles[variant]
.css
the same way ascssMap
.In the future, we can transform
to