An open source design system that's fully customizable and agent ready
TypeScript
fix(build): add build step for vite plugin + fix stale example (#2205)
Cindy Zhang53f34a431d56
diff --git a/apps/example-nextjs-source/src/app/page.tsx b/apps/example-nextjs-source/src/app/page.tsxindex c64c517a09..4a6f29894c 100644--- a/apps/example-nextjs-source/src/app/page.tsx+++ b/apps/example-nextjs-source/src/app/page.tsx@@ -186,8 +186,8 @@ export default function Home() {/><XDSSwitchlabel="Enable notifications"- isSelected={toggle}- onChange={setToggle}+ value={toggle}+ onChange={(checked) => setToggle(checked)}/></XDSVStack>diff --git a/package.json b/package.jsonindex a25cda31fa..927ab9e2b8 100644--- a/package.json+++ b/package.json@@ -10,7 +10,7 @@"internal/*"],"scripts": {- "build": "yarn workspace @xds/core build && yarn workspace @xds/vega build && yarn workspace @xds/theme-default build && yarn workspace @xds/theme-neutral build && yarn workspace @xds/theme-brutalist build && yarn workspace @xds/theme-daily build && yarn workspace @xds/theme-matcha build && yarn workspace @xds/theme-stone build && yarn workspace @xds/theme-gothic build && yarn workspace @xds/theme-chocolate build && yarn workspace @xds/theme-y2k build && yarn workspace @xds/theme-butter build",+ "build": "yarn workspace @xds/build build && yarn workspace @xds/core build && yarn workspace @xds/vega build && yarn workspace @xds/theme-default build && yarn workspace @xds/theme-neutral build && yarn workspace @xds/theme-brutalist build && yarn workspace @xds/theme-daily build && yarn workspace @xds/theme-matcha build && yarn workspace @xds/theme-stone build && yarn workspace @xds/theme-gothic build && yarn workspace @xds/theme-chocolate build && yarn workspace @xds/theme-y2k build && yarn workspace @xds/theme-butter build","dev": "yarn workspace @xds/storybook dev","test": "vitest run","test:watch": "vitest",diff --git a/packages/build/.gitignore b/packages/build/.gitignorenew file mode 100644index 0000000000..849ddff3b7--- /dev/null+++ b/packages/build/.gitignore@@ -0,0 +1 @@+dist/diff --git a/packages/build/build.mjs b/packages/build/build.mjsnew file mode 100644index 0000000000..fa232d9e20--- /dev/null+++ b/packages/build/build.mjs@@ -0,0 +1,39 @@+#!/usr/bin/env node+/**+ * Compiles src/vite.ts → dist/vite.mjs for npm distribution.+ *+ * The vite plugin is the only TypeScript source in @xds/build.+ * Node does not support type-stripping for files inside node_modules,+ * so we must ship compiled JS.+ */+import {buildSync} from 'esbuild';+import {readFileSync, writeFileSync} from 'fs';++buildSync({+ entryPoints: ['src/vite.ts'],+ bundle: true,+ platform: 'node',+ format: 'esm',+ outfile: 'dist/vite.mjs',+ external: [+ 'vite',+ '@stylexjs/babel-plugin',+ '@stylexjs/unplugin',+ 'path',+ 'url',+ 'node:path',+ 'node:url',+ ],+ banner: {js: '// Built from src/vite.ts — do not edit directly'},+});++// Fix babel.js path: dist/vite.mjs resolves __dirname to dist/,+// but babel.js lives in src/+let content = readFileSync('dist/vite.mjs', 'utf8');+content = content.replace(+ 'resolve(__dirname, "babel.js")',+ 'resolve(__dirname, "../src/babel.js")',+);+writeFileSync('dist/vite.mjs', content);++console.log('Built dist/vite.mjs');diff --git a/packages/build/package.json b/packages/build/package.jsonindex 79830781c8..b763c76db2 100644--- a/packages/build/package.json+++ b/packages/build/package.json@@ -26,12 +26,17 @@".": "./src/config.js","./babel": "./src/babel.js","./postcss": "./src/index.js",- "./vite": "./src/vite.ts",+ "./vite": "./dist/vite.mjs","./next": "./src/next.js"},"files": [- "src"+ "src",+ "dist"],+ "scripts": {+ "build": "node build.mjs",+ "prepack": "npm run build"+ },"peerDependencies": {"@stylexjs/babel-plugin": ">=0.18.0","@babel/core": ">=7.0.0",@@ -43,6 +48,9 @@"glob-parent": "^6.0.0","is-glob": "^4.0.0"},+ "devDependencies": {+ "esbuild": "^0.25.0"+ },"peerDependenciesMeta": {"@stylexjs/unplugin": {"optional": true