Skip to content
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

[sparkle] internal: refactor packaging, compile tsc & tailwind - take2 #6090

Merged
merged 16 commits into from
Sep 3, 2024
1 change: 1 addition & 0 deletions sparkle/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
ignorePatterns: [
"rollup.config.js",
"eslint.js",
".eslintrc.js",
"dist/",
"node_modules/",
"svgr.config.js",
Expand Down
12 changes: 8 additions & 4 deletions sparkle/build_icons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ rm -rf src/icons/solid
rm -rf src/logo/platforms
rm -rf src/logo/dust

npx @svgr/cli --out-dir src/icons/stroke/ src/icons/src/stroke/
npx @svgr/cli --out-dir src/icons/solid/ src/icons/src/solid/
npx @svgr/cli --out-dir src/logo/platforms/ src/logo/src/platforms/
npx @svgr/cli --out-dir src/logo/dust/ src/logo/src/dust/
npx @svgr/cli --no-prettier --index-template svgr-stroke-template.js --out-dir src/icons/stroke/ src/icons/src/stroke/
npx @svgr/cli --no-prettier --index-template svgr-icon-template.js --out-dir src/icons/solid/ src/icons/src/solid/
npx @svgr/cli --no-prettier --index-template svgr-logo-template.js --out-dir src/logo/platforms/ src/logo/src/platforms/
npx @svgr/cli --no-prettier --index-template svgr-logo-template.js --out-dir src/logo/dust/ src/logo/src/dust/

npx prettier --write src/icons/stroke
npx eslint --fix src/icons/stroke
npx prettier --write src/icons/solid
npx eslint --fix src/icons/solid
npx prettier --write src/logo/platforms
npx eslint --fix src/logo/platforms
npx prettier --write src/logo/dust
npx eslint --fix src/logo/dust
152 changes: 152 additions & 0 deletions sparkle/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions sparkle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
"name": "@dust-tt/sparkle",
"version": "0.2.218",
"scripts": {
"build": "rm -rf dist && rollup -c",
"build:with-tw-base": "rollup -c --environment INCLUDE_TW_BASE:true",
"build": "rm -rf dist && npm run tailwind && npm run build:esm && npm run build:cjs",
"tailwind": "tailwindcss -i ./src/styles/tailwind.css -o dist/sparkle.css",
"build:esm": "npm run copy:esm && tsc && tsc-alias",
"copy:esm": "copyfiles -u 1 src/**/*.css src/**/*.svg src/**/*.png src/**/*.json dist/esm",
"build:cjs": "rollup -c",
"storybook": "storybook dev -p 6006 --debug-webpack",
"build-storybook": "storybook build",
"format:check": "prettier --check .",
"format": "prettier --write .",
"lint": "eslint ."
},
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"types": "dist/esm/index.d.ts",
"module": "dist/esm/index.js",
"files": [
"dist/",
Expand Down Expand Up @@ -45,6 +48,7 @@
"autoprefixer": "^10.4.14",
"babel-loader": "^9.1.3",
"babel-preset-react-app": "^10.0.1",
"copyfiles": "^2.4.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-simple-import-sort": "^12.1.0",
Expand All @@ -60,7 +64,9 @@
"sass-loader": "^13.3.2",
"storybook": "^7.4.6",
"tailwindcss": "^3.2.4",
"tsc-alias": "^1.8.10",
"typescript": "^5.4.5",
"typescript-transform-paths": "^3.4.7",
"uuid": "^9.0.1"
},
"peerDependencies": {
Expand Down
19 changes: 1 addition & 18 deletions sparkle/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import resolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import autoprefixer from "autoprefixer";
import fs from "fs";
import path from "path";
Expand All @@ -10,23 +9,13 @@ import postcss from "rollup-plugin-postcss";
import tailwindcss from "tailwindcss";
import { fileURLToPath } from "url";

let tsPluginOptions = {
tsconfig: "./tsconfig.json",
outputToFilesystem: true,
};

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const pkg = JSON.parse(
fs.readFileSync(path.resolve(__dirname, "package.json"), "utf-8")
);

let entryFile = "src/index.ts";
tsPluginOptions.exclude = "src/index_with_tw_base.ts";
if (process.env.INCLUDE_TW_BASE) {
entryFile = "src/index_with_tw_base.ts";
tsPluginOptions.exclude = "src/index.ts";
}
let entryFile = "dist/esm/index.js";

const config = {
input: entryFile,
Expand All @@ -37,17 +26,11 @@ const config = {
sourcemap: true,
name: "react-lib",
},
{
file: pkg.module,
format: "esm",
sourcemap: true,
},
],
plugins: [
external(),
resolve(),
commonjs(),
typescript(tsPluginOptions),
postcss({
plugins: [
tailwindcss({
Expand Down
Loading
Loading