-
Notifications
You must be signed in to change notification settings - Fork 4.1k
bento jss: transform the CSS and useStyles exports. #29777
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
Conversation
c36b42c to
3cd59ae
Compare
|
hack alert
@jridgewell: wdyt about this approach? a cleaner (but slower) method would be to first run the |
|
Woot! After discussing with @jridgewell he informed me about path.evaluate(), which does exactly what we want. It allows us to statically retrieve the value of We just can't get too fancy with our .jss.js files, which we wouldn't have wanted anyway. Hack is solved :) |
|
Hey @erwinmombay, @jridgewell! These files were changed: Hey @wassgha! These files were changed: |
dvoytenko
left a comment
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.
This looks really nice!
...ns/babel-plugin-transform-jss/test/fixtures/transform-assertions/should-transform/output.mjs
Outdated
Show resolved
Hide resolved
...gins/babel-plugin-transform-jss/test/fixtures/transform-assertions/should-transform/input.js
Outdated
Show resolved
Hide resolved
| <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> | ||
| <link href='https://fonts.googleapis.com/css?family=Questrial' rel='stylesheet' type='text/css'> | ||
| <script async custom-element="amp-base-carousel" src="https://cdn.ampproject.org/v0/amp-base-carousel-0.1.js"></script> | ||
| <script async custom-element="amp-base-carousel" src="https://cdn.ampproject.org/v0/amp-base-carousel-1.0.js"></script> |
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.
The 0.1 might be needed for some particular tests, especially since 0.1 is still the PROD version. Can we test via storybook? I like those a lot better now.
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.
err, yeah I didn't mean to include this. will revert.
Do you even use storybook to test bento components in amp mode?
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.
We do. However, there's a known issue there that I'm fixing right now. See ampproject/storybook-addon-amp#2
dvoytenko
left a comment
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.
Approved, but I think there are issues with CSS string
...-plugin-transform-jss/test/fixtures/transform-assertions/should-transform-jss-var/output.mjs
Outdated
Show resolved
Hide resolved
| @@ -0,0 +1,23 @@ | |||
| var _classes = JSON.parse("{\"button\":\"button-0-2-1\",\"CSS\":\".button-0-2-1 {\\n font-size: 12px;\\n}\"}"); | |||
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.
Can we minify this CSS at all?
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.
Yes, but I'd like to defer that
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 hope that eventually we can run our CSS optimizer/prefixer code on these stylesheets.
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
|
\o/\o/\o/ |
|
@samouri Please tag the ITI that you created to this pull request. |
|
Sure, here's the I2I #29862. We still have a couple of things to iron out before this story is complete:
|
* build-system: teach buildExtension how to build jss * remove style-loader from main deps * make work with watch mode * add babel transform * delete jss build, perform at babel time * lint * dd todo * also convert the module.exports into named exports * copyright * Thank you justin, path.evaluate is gold. * Update with smarter xform * extract classes var, no longer jss required export * another test * remove rest operator * fix, bad interpolation * improve two comments * lint * updates, tanks justin * lint * Update build-system/babel-plugins/babel-plugin-transform-jss/index.js Co-authored-by: Justin Ridgewell <[email protected]> * Update build-system/babel-plugins/babel-plugin-transform-jss/index.js Co-authored-by: Justin Ridgewell <[email protected]> * remove outdated option * lint * remove computer properties for browserify * Allow JSON.parse in jss files for conformance-config * test code also needs transform Co-authored-by: Justin Ridgewell <[email protected]>
summary
Creates a new babel transform that compiles the jss file for amp modes. It does three things:
useStyleswith a side-effect free version that simply returns an object.CSSexport with a compiled string for inclusion in shadow.react-jss, since it is no longer used. Ideally it would have been removed via treeshaking, but I don't trust it fully due to module side-effects.For: #29862
Related to ampproject/wg-bento#7, ampproject/wg-bento#12, ampproject/wg-bento#13, ampproject/wg-bento#15, ampproject/wg-bento#15