astahmer / box-extractor Goto Github PK
View Code? Open in Web Editor NEWStatic code extraction. Zero-runtime CSS-in-TS `<Box />` -> became a part of Panda CSS
Home Page: https://panda-css.com/
Static code extraction. Zero-runtime CSS-in-TS `<Box />` -> became a part of Panda CSS
Home Page: https://panda-css.com/
this might not be possible since a sprinkles fn can come from a user-defined fn, like createBoxSprinkles
that we have in @box-extractor/vanilla-extract
:
box-extractor/packages/vanilla-extract/src/createBoxSprinkles.ts
Lines 5 to 17 in a9ede48
if, for some reason, a theme's prop value is un-extractable then we need an escape hatch to ignore some props/values so that it doesn't get removed from the used class names list (and therefore not in the vanilla-extract .css/js output)
not sure yet about the granularity level that should be available :
it could look like this, a forceInclude
option:
createViteVanillaExtractSprinklesExtractor({
components: ["Box", "Stack"],
functions: ["themeSprinkles"],
forceInclude: [
{ value: "*", prop: "*", function: "specialSprinkleFn" },
{ value: "*", prop: "color", component: "Box" },
{ value: ["blue.100", "red.300", "primary"], prop: ["color", "backgroundColor"], component: "*", functions: "*" }
],
}),
which means:
specialSPrinkleFn
will be includedcolor
prop for the component <Box />
will be includedblue.100
& red.300
values will be included for the color
and backgroundColor
props of all components & functions (in addition to those extracted as usual ofc)also, a forceIncludeDev
option could be used so that some props values would be included just in dev mode in order to skip the whole process of AST-parsing+invalidation+serialization (which means quicker HMR = quicker feedback = better DX)
this could be used in implementation phase where you might be playing with different margin spaces, or colors, etc..
it would be nice to have those integrations tests, just to be sure nothing breaks between releases since behaviours differs quite a lot
rakkas({ filterRoutes: (_route) => "server" })
/ vite-plugin-ssr with xxx.page.server.ts only = no xxx.page.ts)and each of those should test that:
.css.ts
) providing this color+yyy combinationfinally, it should test this for 3 different kind of sources :
.css.ts
coming from user-code : ./src/sprinkle.css.ts
.css.ts
coming from user-code in another package : @monorepo/ui-lib
.css.ts
coming from node_modules : @npm-package/sprinkles
not sure if this is useful, at least not in the vanilla-extract
context
atm we invalidate all .css.ts
cause I haven't made a link between what changed & where does the prop changed value comes from
ex:
we have a (box.ts
) component using themeSprinkles
(theme.css.ts
), itself using colors
(colors.css.ts
) props (made with VE defineProperties
)
we also have other .css.ts like color-mode.css.ts
& button.css.ts
used in other places (but not box.ts
)
initial code: <Box color="blue.100" />
after change: <Box color="red.300" />
we can see only the color prop value has changed, and we know the color prop comes from the sprinkle prop defined in colors.css.ts
currently: we invalidate all modules ending with .css.ts
(theme.css.ts, colors.css.ts, color-mode.css.ts, button.css.ts)
TODO: invalidate only colors.css.ts (and maybe theme.css.ts, if needed ?)
allow extracting values in a condition that is not a ternary (only those are supported atm, like cond ? whenTrue : whenFalse
) :
valueOrNullable ?? fallback
valueOrFalsy || fallback
valueOrFalsy && fallback
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.