Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

SRCS = $(wildcard lib/**)
SRCS = $(wildcard lib/**/*.ts)

.DEFAULT_GOAL := all

Expand 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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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")'
2 changes: 1 addition & 1 deletion bundlesize.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
files: [
{
path: 'build/**/*.js',
maxSize: '40 kB',
maxSize: '49 kB',
compression: 'brotli',
},
{
Expand Down
1 change: 0 additions & 1 deletion lib/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/open-props-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 12 additions & 6 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default defineConfig((config) => {
react(),
vanillaExtractPlugin(debugBuild ? { identifiers: 'debug' } : {}),
],

build: {
outDir: 'build',
target: 'esnext',
Expand All @@ -28,7 +29,6 @@ export default defineConfig((config) => {
},
rollupOptions: {
external: [
/^@floating-ui\/.*/,
'react',
'react-dom',
'react/jsx-runtime',
Expand All @@ -43,14 +43,19 @@ 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';
},
},
},

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,
},
Expand All @@ -70,9 +75,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,
],
Expand Down