-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
FEATURE: CSS build refactor (make react-ui-components easy to use) #3366
Conversation
we need this https://github.com/evanw/esbuild/releases/tag/v0.15.15 will only work in production build though ...
When a nested rule starts with an element selector, it may be ambiguous with a property. In these cases, the spec requires the selector be prefixed with a nesting selector (&). https://drafts.csswg.org/css-nesting/#nest-selector
my esbuild plugin @mhsdesign/esbuild-composes-from-css-modules works better than the previously used esbuild-style-plugin
- source maps - full build css (applied cssmodules, nesting, cssvariables) - typescript declarations - able to import only certain components - api surface should not change
…pm published package
…ld-essentials/src/neos-ui';`
…les plugin remove old styleConstants.js
3898b9c
to
c6c8f59
Compare
c6c8f59
to
f67ce2d
Compare
59ed784
to
fd993bd
Compare
Is now completely ready for review ;) See https://github.com/neos/neos-ui/blob/d8ab716a5753a00bec648cfd480bd0aa3e347abc/packages/react-ui-components/README.md for a new documentation of the react-ui-components ;) |
4636db5
to
380def9
Compare
… file separately the advantage is we dont have so many empty chunks and less files to publish. Also previously with importing from the unstyled compontents would still include css as the chunking wasnt optimal.
380def9
to
eefb66d
Compare
TASK: Analyze bundle size and health `node esbuild.js --production --analyze`
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.
Looks good to me, if we have bugs left, we need to fix them anyways.
solves #3213
solves #3330
Puhh im happy to finally present you this pr.
I have been working on this concept since we started the esbuild pr but now everything just fell in place and ive got a fully working* improved css build and react-ui-components build.
*I currently cant find any style shifts in a side to side comparison :D
I took my previous refactoring at #3358 even further, now with a better written cssModules plugin https://github.com/neos/neos-ui/blob/aa9f5497678225b8b9414b247f97042aaa165447/cssModules.js and an actual consumer (dev) friendly build of the
@neos-project/react-ui-components
What I did
@extends
with css-modulescomposes
https://github.com/css-modules/css-modules#compositioncomposes from "./file.css"
usable as esbuild plugin: see: https://github.com/neos/neos-ui/blob/aa9f5497678225b8b9414b247f97042aaa165447/cssModules.jsOuredit i reverted to not using.reset
css modules compose mixin now uses the:where()
selector, to force a low specificity at all time (just in case somehow the reset class lands at the bottom at the stylesheet, where it would have a higher specificity otherwise, which was our problem in the first place so we used sass. But after investigating if found out that since using my esbuild plugin the css class is as wanted at the top so it would be fine either way for now):where
as we dont need it atmreact-ui-components
:global
pseudo class: https://lightningcss.dev/css-modules.html#unsupported-featurespackages/build-essentials/src/styles/styleConstants.js
tocssVariables.css
cssVariables.js
creates a plugin for lightningcss which embeddes the css variables as usualpackages/react-ui-components/src/index.js
to a typescript file so we have types when usingimport {Button} from "index.js"
Todos
import style from "./style.css"
tostyle.module.css
#3217 (after this one ;))packages/build-essentials/src/styles/styleConstants.js
-> it is currently used by the neos-ui-extensibility plugin build ... by accident?import {isNil} from '@neos-project/utils-helpers';
: due toisNil
beeing in@neos-project/utils-helpers
and this package not beeing on npm we cant properly use the react-ui-components as declaring it a dependecy alone would solve it. Regression from BUGFIX: Allow zero as value in selectbox #3069. use value == null;value == null
extract css grid declaration in another better named css filerevert to [name]-[hash] css classes (for easier selecting in e2e (or place data-testid) )@neos-project/react-ui-components/dist/Button/index.js
or even unthemend?@neos-project/react-ui-components/dist/Button/button.js
How I did it
blood. sweat. tears.
How to verify it
use the lib-esm build in the ui ^^
react-ui-components build
see if it works correctly, as you have used before (by linking the package locally or some other hack)
or create a js and html file like:
build it with
yarn esbuild test.jsx --outdir=dist --bundle
and view the html in the browser.Upgrade instructions for Neos Ui components @neos-project/react-ui-components:
With this change the CSS build stack of the Neos Ui was modernized, due to this it became possible to make the package react-ui-components easier to use: Developers requiring the npm package will no longer need to worry about the required CSS preprocessing from the sources (lowering nesting and applying css-modules). A prepack script will build the css to native css and also take care of css modules. This means that for consumption of the components you will only need a simple bundler to load the vanilla css - nothing else. It is advised to read the new readme before updating so you can identify any other changes.