-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
feat: Create utils package to share logic across runtime and bundler #345
base: master
Are you sure you want to change the base?
Conversation
b30ef1e
to
4003aa6
Compare
e1c0ebc
to
903cc78
Compare
@@ -1,8 +1,7 @@ | |||
{ | |||
"extends": "../../tsconfig.json", | |||
"compilerOptions": { | |||
"resolveJsonModule": true, | |||
"target": "ES2015" | |||
"skipLibCheck": true |
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.
Why was this required?
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.
Without it, it was typechecking for stuff inside unplugin
package that does not affect our package.
../../node_modules/.pnpm/unplugin@1.15.0_webpack-sources@3.2.3/node_modules/unplugin/dist/index.d.mts(1,31): error TS2307: Cannot find module '@farmfe/core' or its corresponding type declarations.
../../node_modules/.pnpm/unplugin@1.15.0_webpack-sources@3.2.3/node_modules/unplugin/dist/index.d.mts(2,46): error TS2307: Cannot find module '@farmfe/core' or its corresponding type declarations.
../../node_modules/.pnpm/unplugin@1.15.0_webpack-sources@3.2.3/node_modules/unplugin/dist/index.d.mts(3,47): error TS2307: Cannot find module '@rspack/core/dist/config/zod' or its corresponding type declarations.
../../node_modules/.pnpm/unplugin@1.15.0_webpack-sources@3.2.3/node_modules/unplugin/dist/index.d.mts(7,45): error TS2307: Cannot find module 'rolldown/dist/types/plugin' or its corresponding type declarations.
../../node_modules/.pnpm/unplugin@1.15.0_webpack-sources@3.2.3/node_modules/unplugin/dist/index.d.mts(14,126): error TS2307: Cannot find module '@rspack/core' or its corresponding type declarations.
../../node_modules/.pnpm/unplugin@1.15.0_webpack-sources@3.2.3/node_modules/unplugin/dist/index.d.mts(15,66): error TS2307: Cannot find module '@rspack/core' or its corresponding type declarations.
../../node_modules/.pnpm/unplugin@1.15.0_webpack-sources@3.2.3/node_modules/unplugin/dist/index.d.mts(19,36): error TS2307: Cannot find module 'rolldown' or its corresponding type declarations.
../../node_modules/.pnpm/unplugin@1.15.0_webpack-sources@3.2.3/node_modules/unplugin/dist/index.d.mts(20,42): error TS2307: Cannot find module 'rolldown' or its corresponding type declarations.
ELIFECYCLE Command failed with exit code 2.
This check can be safely ignored since at the moment we don't care about farm/rolldown/rspack etc.
>; | ||
defaultVariants?: Record<string, string | number>; | ||
}; | ||
type BaseStyleObject = ExtendedStyleObj & Record<string, string | object>; |
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.
Don't we miss here the CSS template string type?
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.
Template string doesn't need any pre-processing as we are not extending the css string syntax, only the object syntax. Template strings are just string concatenation with some js values in-between.
}, | ||
}, | ||
variables: { | ||
'--var-1': [style[`.cls1`].color, 0], |
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.
Where would this style[`.cls1`].color
be defined?
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'm just using the original style
object passed to the processStyle
function to compare the function equality check by comparing the references.
$$hello: 'world', | ||
$hello1: 'world', |
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.
$$hello: 'world', | |
$hello1: 'world', | |
$$hello: 'world', | |
$hello1: 'world', |
What's the difference betweem $ and $$?
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 convention here is that $$
is more like private variables an it'll have 3 dashes ---var
and doesn't need to be exposed to users for customization. $
is public variables that can be exposed through documentation to customize the style and it'll have 2 dashes --var
a4b05a1
to
8dcf767
Compare
35d32d4
to
7508d32
Compare
644227a
to
9f01dd5
Compare
…packages
For reference, here's the next PR that uses this package.
This PR has the following utils -
$$value
keys in the css object to convert to css variables---value
variants
,compoundVariants
anddefaultVariants
keysvalueToLiteral
- Copied over from@pigment-css/react
to convert JS values to equivalent AST.evaluateClassNameArg
- Evaluates JS string to get the actual JS value.Also, fixes tsconfig to used the latest config from core and updated the script to actually run typecheck in the CI which was not happening right now.