From f4cfba6d25897432ff0e4b7aa673e0478e0251bd Mon Sep 17 00:00:00 2001 From: Max Holman Date: Sun, 23 Jun 2024 20:24:03 +0800 Subject: [PATCH 1/2] chore: rc oopsies --- Makefile | 24 ++++++++++++++++-------- bundlesize.config.cjs | 2 +- lib/defaults.ts | 1 - lib/generated/open-props-tokens.ts | 2 +- package.json | 12 ++++++------ tsconfig.json | 2 +- vite.config.ts | 15 ++++++++++++--- 7 files changed, 37 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index eebe386..c34813e 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -SRCS = $(wildcard lib/**) +SRCS = $(wildcard lib/**/*.ts) .DEFAULT_GOAL := all @@ -10,14 +10,13 @@ node_modules: package.json pnpm-lock.yaml pnpm install touch $@ -dist/bin/token.js: node_modules bin/token.ts build ${SRCS} - pnpm exec tsc -b +dist/bin/token.js: dist -dist/bin/open-props-tokens.js: node_modules bin/open-props-tokens.ts +dist/bin/open-props-tokens.js: lib/generated/open-props-tokens.ts pnpm exec tsc -b -lib/generated/open-props-tokens.ts: dist/bin/open-props-tokens.js - node $< > $@ +lib/generated/open-props-tokens.ts: + node dist/bin/open-props-tokens.js > $@ pnpm exec prettier --write $@ # SCSS @@ -39,7 +38,7 @@ build: $(SRCS) node_modules vite.config.ts vite-env.d.ts touch $@ .PHONY: build-watch -build-watch: $(SRCS) node_modules vite.config.ts vite-env.d.ts +build-watch: node_modules vite.config.ts vite-env.d.ts pnpm exec vite build --mode=development --clearScreen false touch -c build @@ -59,8 +58,9 @@ dev: debug: DEBUG_BUILD=1 $(MAKE) -dist: node_modules tsconfig.json +dist: $(SRCS) node_modules tsconfig.json pnpm exec tsc -b + touch $@ .PHONY: clean clean: node_modules tsconfig.json @@ -77,6 +77,7 @@ test: node_modules lint dist build DEBUG_BUILD=true pnpm vitest run DEBUG_BUILD=true pnpm vitest run pnpm exec bundlesize + $(MAKE) smoketest .PHONY: lint lint: node_modules @@ -87,3 +88,10 @@ lint: node_modules pretty: node_modules pnpm exec eslint --fix . pnpm exec prettier --write . + +.PHONY: smoketest +smoketest: all + node -e 'import("@block65/react-design-system")' + node -e 'import("@block65/react-design-system/vanilla-extract")' + node -e 'import("@block65/react-design-system/hooks")' + node -e 'import("@block65/react-design-system/open-props")' diff --git a/bundlesize.config.cjs b/bundlesize.config.cjs index ad6d195..34cdb49 100644 --- a/bundlesize.config.cjs +++ b/bundlesize.config.cjs @@ -5,7 +5,7 @@ module.exports = { files: [ { path: 'build/**/*.js', - maxSize: '40 kB', + maxSize: '45 kB', compression: 'brotli', }, { diff --git a/lib/defaults.ts b/lib/defaults.ts index 673c174..a25f066 100644 --- a/lib/defaults.ts +++ b/lib/defaults.ts @@ -9,7 +9,6 @@ import { textVariantVars, } from './vars.css.js'; -// this is just a partial definition for the borders export const globalTokens = { border: { radius: openPropsTokens.radius2, diff --git a/lib/generated/open-props-tokens.ts b/lib/generated/open-props-tokens.ts index 93b44a7..ed8dece 100644 --- a/lib/generated/open-props-tokens.ts +++ b/lib/generated/open-props-tokens.ts @@ -6,7 +6,7 @@ * * WARN: Do not edit directly. * - * Generated on 2024-06-23T11:37:36.401Z by "mholman" + * Generated on 2024-06-23T12:10:16.212Z by "mholman" * */ // Token Group: "other" diff --git a/package.json b/package.json index ee0c472..4beea79 100644 --- a/package.json +++ b/package.json @@ -33,17 +33,17 @@ "./vanilla-extract": { "types": "./dist/lib/vars.d.ts", "default": "./build/vars.js" + }, + "./open-props": { + "types": "./dist/lib/generated/open-props-tokens.d.ts", + "default": "./dist/lib/generated/open-props-tokens.js" } }, "files": [ "dist/lib/**/*.d.ts", + "dist/lib/generated/*", "lib/scss/**/*.scss", - "build/*/*.js", - "build/*/*.js.map", - "build/*.js", - "build/*.js.map", - "build/*.css", - "build/*.scss" + "build/**/*" ], "scripts": { "prepare": "husky", diff --git a/tsconfig.json b/tsconfig.json index 22a9f3c..cd2eeaa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,4 +1,4 @@ -// last updated: Sun Jun 23 07:41:22 PM +08 2024 +// last updated: Sun Jun 23 08:05:07 PM +08 2024 { "compilerOptions": { "target": "es2020", diff --git a/vite.config.ts b/vite.config.ts index ad0f5f9..b5ec42f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -14,6 +14,7 @@ export default defineConfig((config) => { react(), vanillaExtractPlugin(debugBuild ? { identifiers: 'debug' } : {}), ], + build: { outDir: 'build', target: 'esnext', @@ -28,7 +29,6 @@ export default defineConfig((config) => { }, rollupOptions: { external: [ - /^@floating-ui\/.*/, 'react', 'react-dom', 'react/jsx-runtime', @@ -43,7 +43,15 @@ export default defineConfig((config) => { }), ], output: { - preserveModules: true, // presume the consuming library is going to bundle it + manualChunks(id) { + if (id.includes('@floating-ui')) { + return 'floating-ui'; + } + if (id.includes('node_modules')) { + return 'vendor'; + } + return 'main'; + }, }, }, @@ -70,9 +78,10 @@ export default defineConfig((config) => { }, }, + // this is for better dx with the import paths and hmr optimizeDeps: { exclude: [ - new URL('./build/main.js', import.meta.url).pathname, + new URL('./build/defaults.js', import.meta.url).pathname, new URL('./build/vars.js', import.meta.url).pathname, new URL('./build/style.css', import.meta.url).pathname, ], From 53cd97632ad67db5f12bfb7799b318fe34625749 Mon Sep 17 00:00:00 2001 From: Max Holman Date: Sun, 23 Jun 2024 20:26:47 +0800 Subject: [PATCH 2/2] chore: lint --- bundlesize.config.cjs | 2 +- vite.config.ts | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/bundlesize.config.cjs b/bundlesize.config.cjs index 34cdb49..24d2094 100644 --- a/bundlesize.config.cjs +++ b/bundlesize.config.cjs @@ -5,7 +5,7 @@ module.exports = { files: [ { path: 'build/**/*.js', - maxSize: '45 kB', + maxSize: '49 kB', compression: 'brotli', }, { diff --git a/vite.config.ts b/vite.config.ts index b5ec42f..90a943b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -56,9 +56,6 @@ export default defineConfig((config) => { }, sourcemap: true, - - // we have these on even with modules, so that we can estimate the size of - // the library when bundled minify: !debugBuild, cssMinify: !debugBuild, },