Skip to content

Commit 8df471a

Browse files
feat(release): compile ts to js using vite in library mode, make tailwind-merge a peer dependency
1 parent bb0e522 commit 8df471a

File tree

3 files changed

+86
-15
lines changed

3 files changed

+86
-15
lines changed

package.json

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
"version": "0.3.1",
44
"scripts": {
55
"dev": "bun run rsbuild:dev",
6-
"build": "rm -rf ./export ; tsc -p ./tsconfig.lib.json",
6+
"build": "bun run build:lib",
7+
"build:site": "bun run vite:build",
8+
"build:lib": "clear ; rm -rf ./dist ; vite build --config vite.config.lib.ts",
9+
"ts:build": "rm -rf ./export ; tsc -p ./tsconfig.lib.json",
710
"compile": "bun run tsc",
811
"vite:dev": "nice -5 vite dev --debug hmr",
912
"vite:build": "nice -15 vite build",
10-
"vite:deploy": "bun run vite:build && bun run solid:upload && bun run solid:tag",
13+
"vite:deploy": "bun run vite:build && bun run solid:upload && bun run tag:deployed",
1114
"rsbuild:dev": "nice -5 rsbuild dev",
1215
"rsbuild:build": "nice -15 rsbuild build",
13-
"rsbuild:deploy": "bun run rsbuild:build && bun run solid:upload && bun run solid:tag",
14-
"deploy": "bun run build && bun run upload && bun run tag",
15-
"upload": "bun run wrangler pages deploy ./dist --project-name=adaptive-solid-ui --commit-dirty",
16-
"tag": "git branch -f deployed",
16+
"rsbuild:deploy": "bun run rsbuild:build && bun run solid:upload && bun run tag:deployed",
17+
"deploy": "bun run build && bun run upload && bun run tag:deployed",
18+
"upload": "bun run wrangler pages deploy ./out --project-name=adaptive-solid-ui --commit-dirty",
19+
"tag:deployed": "git branch -f deployed",
1720
"release": "bash ./ops/release.sh",
1821
"generateDemoList": "bun run ./src/demos/generateDemoList.cli.ts",
1922
"update": "nice -15 bun x npm-check-updates -u && bun i",
@@ -31,6 +34,7 @@
3134
"clsx": "^2.1.1",
3235
"dayjs": "^1.11.18",
3336
"solid-js": "^1.9.9",
37+
"tailwind-merge": "^3.3.1",
3438
"valibot": "^1.1.0"
3539
},
3640
"devDependencies": {
@@ -40,22 +44,17 @@
4044
"@tailwindcss/postcss": "^4.1.13",
4145
"@tailwindcss/vite": "^4.1.13",
4246
"@types/bun": "latest",
47+
"glob": "^11.0.3",
4348
"image-size": "^2.0.2",
4449
"prettier": "^3.6.2",
4550
"rollup-plugin-visualizer": "^6.0.3",
46-
"tailwind-merge": "^3.3.1",
4751
"tailwindcss": "^4.1.13",
4852
"typescript": "^5.9.3",
4953
"vite": "^7.1.5",
54+
"vite-plugin-dts": "^4.5.4",
5055
"vite-plugin-solid": "^2.11.8",
5156
"wrangler": "^4.37.0"
5257
},
53-
"exports": {
54-
"./*": "./export/*"
55-
},
56-
"files": [
57-
"export"
58-
],
5958
"prettier": {
6059
"semi": false,
6160
"printWidth": 120,
@@ -79,5 +78,12 @@
7978
],
8079
"repository": {
8180
"url": "git+https://github.com/adaptive-shield-matrix/solid-ui.git"
82-
}
81+
},
82+
"exports": {
83+
"./*": {
84+
"import": "./dist/*.js",
85+
"types": "./dist/*.d.ts"
86+
}
87+
},
88+
"files": ["dist"]
8389
}

vite.config.lib.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { glob } from "glob"
2+
import { resolve } from "path"
3+
import { defineConfig } from "vite"
4+
import dts from "vite-plugin-dts"
5+
import solid from "vite-plugin-solid"
6+
7+
export default defineConfig({
8+
resolve: {
9+
alias: {
10+
"@": new URL("./src", import.meta.url).pathname,
11+
"~ui": new URL("./lib", import.meta.url).pathname,
12+
"~utils": new URL("././node_modules/@adaptive-sm/utils/dist", import.meta.url).pathname,
13+
},
14+
},
15+
plugins: [
16+
solid(),
17+
dts({
18+
include: ["lib/**/*"],
19+
outDir: "dist",
20+
// Use your tsconfig.lib.json for proper configuration
21+
tsconfigPath: "./tsconfig.lib.json",
22+
}),
23+
],
24+
build: {
25+
copyPublicDir: false,
26+
lib: {
27+
// Entry point(s) for your library
28+
// entry: resolve(__dirname, "lib/**/*.{ts,tsx}"),
29+
entry: glob.sync(resolve(__dirname, "lib/**/*.{ts,tsx}"), {
30+
ignore: ["**/*.test.ts", "**/*.test.tsx"],
31+
}),
32+
// Output formats - ESM is standard for modern libraries
33+
formats: ["es"],
34+
},
35+
outDir: "dist",
36+
// Don't minify library code - let consumers decide
37+
minify: false,
38+
sourcemap: true,
39+
rollupOptions: {
40+
// Externalize dependencies that shouldn't be bundled
41+
external: [
42+
"solid-js",
43+
"solid-js/web",
44+
"solid-js/store",
45+
"@adaptive-sm/utils",
46+
"@floating-ui/dom",
47+
"@mdi/js",
48+
"@solid-primitives/keyed",
49+
"@solid-primitives/scheduled",
50+
"@solidjs/router",
51+
"clsx",
52+
"dayjs",
53+
"tailwind-merge",
54+
"valibot",
55+
/^node:.*$/, // Externalize all node imports
56+
/^bun:.*$/, // Externalize all bun imports
57+
],
58+
output: {
59+
// Preserve module structure for better tree-shaking
60+
preserveModules: true,
61+
preserveModulesRoot: "lib",
62+
},
63+
},
64+
},
65+
})

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default defineConfig({
3333
plugins: [solid(), tailwindcss(), visualizer({ filename: "dist/bundle-size.html", gzipSize: true })],
3434
build: {
3535
chunkSizeWarningLimit: 1050,
36-
outDir: "dist",
36+
outDir: "out",
3737
assetsDir: "assets",
3838
},
3939
})

0 commit comments

Comments
 (0)