forked from mui/pigment-css
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create UI library independent core package
- Loading branch information
Brijesh Bittu
committed
Dec 11, 2024
1 parent
e1c0ebc
commit 0cac903
Showing
36 changed files
with
1,938 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,330 @@ | ||
From 2fb18388873eef5abb6b09d3d3398ce9b261566e Mon Sep 17 00:00:00 2001 | ||
From: Brijesh Bittu <[email protected]> | ||
Date: Wed, 11 Dec 2024 14:49:06 +0530 | ||
Subject: [PATCH] TS fixes | ||
|
||
--- | ||
.eslintignore | 1 + | ||
packages/pigment-css-core/package.json | 4 +-- | ||
packages/pigment-css-core/tsconfig.build.json | 10 ++++++- | ||
packages/pigment-css-core/tsconfig.json | 25 +++--------------- | ||
.../pigment-css-nextjs-plugin/package.json | 2 +- | ||
.../pigment-css-nextjs-plugin/tsconfig.json | 3 ++- | ||
packages/pigment-css-theme/tsconfig.json | 10 ------- | ||
packages/pigment-css-unplugin/package.json | 2 +- | ||
packages/pigment-css-unplugin/tsconfig.json | 1 + | ||
packages/pigment-css-utils/package.json | 7 +---- | ||
.../pigment-css-utils/tsconfig.build.json | 8 +++++- | ||
packages/pigment-css-utils/tsconfig.json | 26 +++---------------- | ||
packages/pigment-css-vite-plugin/package.json | 2 +- | ||
.../pigment-css-vite-plugin/tsconfig.json | 6 ++--- | ||
tsconfig.json | 8 +++--- | ||
15 files changed, 40 insertions(+), 75 deletions(-) | ||
|
||
diff --git a/.eslintignore b/.eslintignore | ||
index e18ab25..a9382ec 100644 | ||
--- a/.eslintignore | ||
+++ b/.eslintignore | ||
@@ -9,6 +9,7 @@ | ||
/packages/pigment-css-react/exports/ | ||
/packages/pigment-css-react/theme/ | ||
/packages/pigment-css-react/tests/**/fixtures | ||
+/packages/pigment-css-core/tests/**/fixtures | ||
/packages/pigment-css-nextjs-plugin/loader.js | ||
# Ignore fixtures | ||
/packages-internal/scripts/typescript-to-proptypes/test/*/* | ||
diff --git a/packages/pigment-css-core/package.json b/packages/pigment-css-core/package.json | ||
index 3b9d123..79dbf6e 100644 | ||
--- a/packages/pigment-css-core/package.json | ||
+++ b/packages/pigment-css-core/package.json | ||
@@ -21,14 +21,14 @@ | ||
"url": "https://opencollective.com/mui-org" | ||
}, | ||
"scripts": { | ||
- "clean": "rimraf build types processors utils", | ||
+ "clean": "rimraf build", | ||
"watch": "tsup --watch --clean false", | ||
"copy-license": "node ../../scripts/pigment-license.mjs", | ||
"build": "tsup", | ||
"test": "cd ../../ && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=text mocha 'packages/pigment-css-core/**/*.test.{js,ts,tsx}'", | ||
"test:update": "cd ../../ && cross-env NODE_ENV=test UPDATE_FIXTURES=true mocha 'packages/pigment-css-core/**/*.test.{js,ts,tsx}'", | ||
"test:ci": "cd ../../ && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=lcov --report-dir=./coverage/pigment-css-core mocha 'packages/pigment-css-core/**/*.test.{js,ts,tsx}'", | ||
- "typescript": "tsc --noEmit -p ." | ||
+ "typescript": "tsc --build --noEmit ." | ||
}, | ||
"dependencies": { | ||
"@babel/types": "^7.25.8", | ||
diff --git a/packages/pigment-css-core/tsconfig.build.json b/packages/pigment-css-core/tsconfig.build.json | ||
index 2639ca1..dac5200 100644 | ||
--- a/packages/pigment-css-core/tsconfig.build.json | ||
+++ b/packages/pigment-css-core/tsconfig.build.json | ||
@@ -3,5 +3,13 @@ | ||
"compilerOptions": { | ||
"composite": false | ||
}, | ||
- "exclude": ["./tsup.config.ts", "src/**/*.d.ts"] | ||
+ "exclude": ["./tsup.config.ts", "src/**/*.d.ts"], | ||
+ "references": [ | ||
+ { | ||
+ "path": "../pigment-css-theme/tsconfig.build.json" | ||
+ }, | ||
+ { | ||
+ "path": "../pigment-css-utils/tsconfig.build.json" | ||
+ } | ||
+ ] | ||
} | ||
diff --git a/packages/pigment-css-core/tsconfig.json b/packages/pigment-css-core/tsconfig.json | ||
index 73d8060..92261c4 100644 | ||
--- a/packages/pigment-css-core/tsconfig.json | ||
+++ b/packages/pigment-css-core/tsconfig.json | ||
@@ -1,30 +1,13 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
- "compilerOptions": { | ||
- "target": "ES2015", | ||
- "allowJs": true, | ||
- "lib": ["ES2017", "ES2021.String", "DOM"], | ||
- "composite": true, | ||
- "noEmit": false, | ||
- "resolveJsonModule": true, | ||
- "types": ["node", "mocha"], | ||
- "jsx": "react-jsx" | ||
- }, | ||
"include": [ | ||
"src/**/*.tsx", | ||
- "src/**/*.js", | ||
"src/**/*.ts", | ||
+ "src/**/*.js", | ||
"tests/**/*.spec.ts", | ||
"tests/**/*.spec.tsx", | ||
- "src/exports/css.cjs" | ||
+ "../pigment-css-theme/src/**/*.ts", | ||
+ "../pigment-css-utils/src/**/*.ts" | ||
], | ||
- "exclude": ["./tsup.config.ts"], | ||
- "references": [ | ||
- { | ||
- "path": "../pigment-css-theme/" | ||
- }, | ||
- { | ||
- "path": "../pigment-css-shared/" | ||
- } | ||
- ] | ||
+ "exclude": ["./tsup.config.ts"] | ||
} | ||
diff --git a/packages/pigment-css-nextjs-plugin/package.json b/packages/pigment-css-nextjs-plugin/package.json | ||
index 7ccd6f8..21252bc 100644 | ||
--- a/packages/pigment-css-nextjs-plugin/package.json | ||
+++ b/packages/pigment-css-nextjs-plugin/package.json | ||
@@ -25,7 +25,7 @@ | ||
"watch": "tsup --watch --tsconfig tsconfig.build.json", | ||
"copy-license": "node ../../scripts/pigment-license.mjs", | ||
"build": "tsup --tsconfig tsconfig.build.json", | ||
- "typecheck": "tsc --noEmit -p ." | ||
+ "typescript": "tsc --noEmit -p ." | ||
}, | ||
"dependencies": { | ||
"@pigment-css/unplugin": "workspace:^" | ||
diff --git a/packages/pigment-css-nextjs-plugin/tsconfig.json b/packages/pigment-css-nextjs-plugin/tsconfig.json | ||
index ad4f42a..7e68102 100644 | ||
--- a/packages/pigment-css-nextjs-plugin/tsconfig.json | ||
+++ b/packages/pigment-css-nextjs-plugin/tsconfig.json | ||
@@ -2,7 +2,8 @@ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"resolveJsonModule": true, | ||
- "target": "ES2015" | ||
+ "target": "ES2015", | ||
+ "skipLibCheck": true | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["./tsup.config.ts"] | ||
diff --git a/packages/pigment-css-theme/tsconfig.json b/packages/pigment-css-theme/tsconfig.json | ||
index d730c25..5682dcf 100644 | ||
--- a/packages/pigment-css-theme/tsconfig.json | ||
+++ b/packages/pigment-css-theme/tsconfig.json | ||
@@ -1,15 +1,5 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
- "compilerOptions": { | ||
- "target": "ES2015", | ||
- "allowJs": true, | ||
- "lib": ["ES2017", "ES2021.String", "DOM"], | ||
- "composite": true, | ||
- "noEmit": false, | ||
- "resolveJsonModule": true, | ||
- "types": ["node", "mocha"], | ||
- "jsx": "react-jsx" | ||
- }, | ||
"include": ["src/**/*.js", "src/**/*.ts", "tests/**/*.spec.ts"], | ||
"exclude": ["./tsup.config.ts"] | ||
} | ||
diff --git a/packages/pigment-css-unplugin/package.json b/packages/pigment-css-unplugin/package.json | ||
index 846d08e..11ffa66 100644 | ||
--- a/packages/pigment-css-unplugin/package.json | ||
+++ b/packages/pigment-css-unplugin/package.json | ||
@@ -25,7 +25,7 @@ | ||
"watch": "tsup --watch --tsconfig tsconfig.build.json", | ||
"copy-license": "node ../../scripts/pigment-license.mjs", | ||
"build": "tsup --tsconfig tsconfig.build.json", | ||
- "typecheck": "tsc --noEmit -p .", | ||
+ "typescript": "tsc --noEmit -p .", | ||
"test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/pigment-css-unplugin/**/*.test.{js,ts,tsx}'", | ||
"test:ci": "cd ../../ && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=lcov --report-dir=./coverage/pigment-css-unplugin mocha 'packages/pigment-css-unplugin/**/*.test.{js,ts,tsx}'" | ||
}, | ||
diff --git a/packages/pigment-css-unplugin/tsconfig.json b/packages/pigment-css-unplugin/tsconfig.json | ||
index b11b8a6..1d6e980 100644 | ||
--- a/packages/pigment-css-unplugin/tsconfig.json | ||
+++ b/packages/pigment-css-unplugin/tsconfig.json | ||
@@ -4,6 +4,7 @@ | ||
"resolveJsonModule": true, | ||
"target": "ES2022", | ||
"lib": ["ES2021", "DOM"], | ||
+ "skipLibCheck": true, | ||
"paths": { | ||
"@babel/core": ["./node_modules/@babel/core"], | ||
"@pigment-css/react": ["./packages/pigment-css-react/src"], | ||
diff --git a/packages/pigment-css-utils/package.json b/packages/pigment-css-utils/package.json | ||
index 9337e14..3da095c 100644 | ||
--- a/packages/pigment-css-utils/package.json | ||
+++ b/packages/pigment-css-utils/package.json | ||
@@ -91,14 +91,9 @@ | ||
"build": { | ||
"outputs": [ | ||
"{projectRoot}/build" | ||
- ] | ||
- }, | ||
- "typescript": { | ||
+ ], | ||
"dependsOn": [ | ||
"^build" | ||
- ], | ||
- "outputs": [ | ||
- "{projectRoot}/build" | ||
] | ||
} | ||
} | ||
diff --git a/packages/pigment-css-utils/tsconfig.build.json b/packages/pigment-css-utils/tsconfig.build.json | ||
index 58bde1b..0754eed 100644 | ||
--- a/packages/pigment-css-utils/tsconfig.build.json | ||
+++ b/packages/pigment-css-utils/tsconfig.build.json | ||
@@ -3,5 +3,11 @@ | ||
"compilerOptions": { | ||
"composite": false | ||
}, | ||
- "exclude": ["./tsup.config.ts", "src/**/*.d.ts", "tests"] | ||
+ "exclude": ["./tsup.config.ts", "src/**/*.d.ts", "tests"], | ||
+ | ||
+ "references": [ | ||
+ { | ||
+ "path": "../pigment-css-theme/tsconfig.build.json" | ||
+ } | ||
+ ] | ||
} | ||
diff --git a/packages/pigment-css-utils/tsconfig.json b/packages/pigment-css-utils/tsconfig.json | ||
index a4af3bd..c1720fa 100644 | ||
--- a/packages/pigment-css-utils/tsconfig.json | ||
+++ b/packages/pigment-css-utils/tsconfig.json | ||
@@ -1,32 +1,12 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
- "compilerOptions": { | ||
- "target": "ES2015", | ||
- "allowJs": true, | ||
- "lib": ["ES2017", "ES2021.String"], | ||
- "composite": true, | ||
- "noEmit": false, | ||
- "resolveJsonModule": true, | ||
- "types": ["node", "mocha"], | ||
- "jsx": "react-jsx", | ||
- "skipLibCheck": true, | ||
- "paths": { | ||
- "@babel/parser": ["./node_modules/@babel/parser/typings/babel-parser.d.ts"], | ||
- "@pigment-css/theme": ["../pigment-css-theme/src"], | ||
- "@pigment-css/theme/*": ["../pigment-css-theme/src/*"] | ||
- } | ||
- }, | ||
"include": [ | ||
"src/**/*.tsx", | ||
"src/**/*.js", | ||
"src/**/*.ts", | ||
"tests/**/*.spec.ts", | ||
- "tests/**/*.spec.tsx" | ||
+ "tests/**/*.spec.tsx", | ||
+ "../pigment-css-theme/src/**/*.ts" | ||
], | ||
- "exclude": ["./tsup.config.ts"], | ||
- "references": [ | ||
- { | ||
- "path": "../pigment-css-theme" | ||
- } | ||
- ] | ||
+ "exclude": ["./tsup.config.ts"] | ||
} | ||
diff --git a/packages/pigment-css-vite-plugin/package.json b/packages/pigment-css-vite-plugin/package.json | ||
index bbbde65..f8b71f6 100644 | ||
--- a/packages/pigment-css-vite-plugin/package.json | ||
+++ b/packages/pigment-css-vite-plugin/package.json | ||
@@ -25,7 +25,7 @@ | ||
"watch": "tsup --watch", | ||
"copy-license": "node ../../scripts/pigment-license.mjs", | ||
"build": "tsup", | ||
- "typecheck": "tsc --noEmit -p ." | ||
+ "typescript": "tsc --noEmit -p ." | ||
}, | ||
"dependencies": { | ||
"@babel/core": "^7.26.0", | ||
diff --git a/packages/pigment-css-vite-plugin/tsconfig.json b/packages/pigment-css-vite-plugin/tsconfig.json | ||
index b787296..069cf63 100644 | ||
--- a/packages/pigment-css-vite-plugin/tsconfig.json | ||
+++ b/packages/pigment-css-vite-plugin/tsconfig.json | ||
@@ -1,11 +1,9 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
- "target": "ES2022", | ||
+ "skipLibCheck": true, | ||
"paths": { | ||
- "@babel/core": ["./node_modules/@babel/core"], | ||
- "@pigment-css/react": ["./packages/pigment-css-react/src"], | ||
- "@pigment-css/react/*": ["./packages/pigment-css-react/src/*"] | ||
+ "@babel/core": ["./node_modules/@babel/core"] | ||
} | ||
}, | ||
"include": ["src/**/*"], | ||
diff --git a/tsconfig.json b/tsconfig.json | ||
index 637610a..566486f 100644 | ||
--- a/tsconfig.json | ||
+++ b/tsconfig.json | ||
@@ -1,8 +1,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "esnext", | ||
- "target": "es5", | ||
- "lib": ["es2020", "dom"], | ||
+ // aligning with Node18 recommendation: https://www.npmjs.com/package/@tsconfig/node18 | ||
+ "target": "es2022", | ||
+ "lib": ["es2020", "dom", "ES2021.String"], | ||
"jsx": "preserve", | ||
"moduleResolution": "node", | ||
"forceConsistentCasingInFileNames": true, | ||
@@ -18,6 +19,7 @@ | ||
"@pigment-css/nextjs-plugin/*": ["./packages/pigment-css-nextjs-plugin/src/*"], | ||
"@pigment-css/react": ["./packages/pigment-css-react/src"], | ||
"@pigment-css/react/*": ["./packages/pigment-css-react/src/*"], | ||
+ "@pigment-css/unplugin": ["./packages/pigment-css-unplugin/src"], | ||
"@pigment-css/vite-plugin": ["./packages/pigment-css-vite-plugin/src"], | ||
"@pigment-css/vite-plugin/*": ["./packages/pigment-css-vite-plugin/src/*"], | ||
"@mui-internal/api-docs-builder": ["./node_modules/@mui/monorepo/packages/api-docs-builder"], | ||
@@ -30,7 +32,7 @@ | ||
"@pigment-css/utils/*": ["./packages/pigment-css-utils/src/*"] | ||
}, | ||
// Otherwise we get react-native typings which conflict with dom.lib. | ||
- "types": ["node", "react"] | ||
+ "types": ["node", "react", "mocha"] | ||
}, | ||
"exclude": ["**/.*/", "**/build", "**/node_modules", "docs/export"] | ||
} | ||
-- | ||
2.39.5 (Apple Git-154) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2023 Material-UI SAS | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Pigment CSS | ||
|
||
Pigment CSS is a zero-runtime CSS-in-JS library that extracts the colocated styles to their own CSS files at build time. | ||
|
||
## Getting started | ||
|
||
Pigment CSS supports Next.js and Vite with support for more bundlers in the future. | ||
|
||
### Why choose Pigment CSS | ||
|
||
Thanks to recent advancements in CSS (like CSS variables and `color-mix()`), "traditional" CSS-in-JS solutions that process styles at runtime are no longer required for unlocking features like color transformations and theme variables which are necessary for maintaining a sophisticated design system. | ||
|
||
Pigment CSS addresses the needs of the modern React developer by providing a zero-runtime CSS-in-JS styling solution as a successor to tools like Emotion and styled-components. | ||
|
||
Compared to its predecessors, Pigment CSS offers improved DX and runtime performance (though at the cost of increased build time) while also being compatible with React Server Components. | ||
Pigment CSS is built on top of [WyW-in-JS](https://wyw-in-js.dev/), enabling to provide the smoothest possible experience for Material UI users when migrating from Emotion in v5 to Pigment CSS in v6. | ||
|
||
### Installation | ||
|
||
<!-- #default-branch-switch --> | ||
|
||
```bash | ||
npm install @pigment-css/core | ||
npm install --save-dev @pigment-css/nextjs-plugin | ||
``` | ||
|
||
<!-- Replace this with the documentation link once it is available. --> | ||
|
||
For more information and getting started guide, check the [repository README.md](https://github.com/mui/pigment-css). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true, | ||
}); | ||
|
||
exports.default = require('../build/processors/css').CssProcessor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true, | ||
}); | ||
|
||
exports.default = require('../build/processors/keyframes').KeyframesProcessor; |
Oops, something went wrong.