fix(cli): 生成的临时 app 从 Tailwind 3 全套迁到 v4,dev 的编程式 postcss 改接 @tailwindcss/postcss (#3852) - #3889
Merged
Merged
Conversation
…dcss/postcss (#3852) 生成器写出的样式面此前是完整的 v3 三件套(`src/index.css` 的 `@tailwind base/components/utilities` 指令、`postcss.config.js` 的 `tailwindcss: {}` 插件键、 一份 v3 `tailwind.config.js`),而仓内与 `@object-ui/components` 都已在 v4 (components 的 peer 是 `tailwindcss ^4.2.1`)。#3827 把这三个键钉成显式 `TAILWIND_V3_DEFERRED` 记账指向本单,本单翻转那些钉子。 两个后果都实测过: - 仓内 `objectui dev` 不出样式。`commands/dev.ts` 的 monorepo 分支把 `require('tailwindcss')(configPath)` 当 PostCSS 插件调用,v4 下这条路径只会抛 "moved to @tailwindcss/postcss",异常被 try/catch 吞成一行黄字警告 —— `css.postcss` 没被设上,Vite 退回搜配置文件,`/src/index.css` 最终 500: `Failed to load PostCSS config … Cannot find module '@tailwindcss/postcss'`。 浏览器里 stylesheet 0 条规则,`h-16` 高 0px,`bg-background` 透明。 - 仓外一次干净安装 ERESOLVE:生成清单的 `tailwindcss ^3.4.19` 与它依赖的 `@object-ui/components` 的 v4 peer 冲突(#3827 让 `@object-ui/*` 变成真能解析 之后此冲突就上膛了)。 改动: - `src/index.css` 改为仓内惯用的 v4 CSS-first 写法(`@import 'tailwindcss'` + `@custom-variant dark` + `@source` + `@theme`),两个生成器共用一个 builder (此前两份 CSS 除 body 三个 utility 外逐字节相同)。`@theme` 的 token 集与 `packages/components/src/index.css` 逐条对齐 —— 含 v3 config 一直缺、而生成的 `src/Layout.tsx` 自己就在用的 8 个 `sidebar-*` token。 - `postcss.config.js` 写 `'@tailwindcss/postcss': {}`;不再生成 `tailwind.config.js`(v4 下无 `@config` 指向即死文件,仓内本身零个 `tailwind.config.*`),v3 的 `content` 四条扫描面等价迁为 `@source`,workspace 两条绝对 glob 语义不变;仓外补 `../node_modules/@object-ui/*/dist/**/*.js` (v4 不自动扫 gitignore 掉的 node_modules)。 - 清单 `tailwindcss` → `^4.3.3`、新增 `@tailwindcss/postcss ^4.3.3`,两者锚回仓内; `DEPENDENCY_ANCHORS` 去掉 `deferred-tailwind-v4` 这一类。 - `commands/dev.ts` 改接 `@tailwindcss/postcss`,由 `@object-ui/cli` 自己声明这两个 插件包(仓根只声明 tailwindcss,不声明 @tailwindcss/postcss,从 cwd 解析在本仓 必然失败);加载失败不再吞成警告,而是带修法响亮报错并拒绝起服务。 反向验证(方向先判后跑):还原两份 pre-fix 源码后,新增 8 个门禁转红并逐一点名 (`@tailwind base;`、v3 插件键、被写出的 `tailwind.config.js`、缺失的 `@source`、 35 个 token 全缺、`^3.4.19` 与 peer `^4.2.1` 不同 major);其中 "resolves every theme token" 一条在 pre-fix 输入上是"因为什么都没产出而绿", 已按 #3826 的教训补上非空断言。把插件包移开模拟坏安装:退出码 1、带修法报错、 不起服务(此前:警告 + exit 0 + 无样式)。 Co-authored-by: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
Collaborator
Author
|
✅ 验收(PM,session 实物核验:头 裁定要点:
转 ready 并挂 auto-merge。越界 #3890(alias 表死清单,与 Tailwind 无关的第二个「dev 空白」根因)/#3891(doctor 误报)/#3892(init 脚手架化石区间,可复用 platformPackageRange())归分诊席;#3893(finding)入维护者决策箱与 #3884 并案。 Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3852
packages/cli的两个生成器写出的样式面此前是完整的 Tailwind 3 三件套,而仓内与@object-ui/components都已在 v4(components 的peerDependencies.tailwindcss是^4.2.1)。#3827 / PR #3854 把这三个键钉成显式TAILWIND_V3_DEFERRED记账并指向本单 —— 本 PR 有意识地翻转那些钉子。实测到的两个后果
1. 仓内
objectui dev的 CSS 管线今天是死的,而且比 issue 描述的更彻底。commands/dev.ts的 monorepo 分支把require('tailwindcss')(configPath)当 PostCSS 插件调用,v4 下这条路径只会抛 "moved to@tailwindcss/postcss";异常被try/catch吞成一行黄字警告,于是css.postcss根本没被设上,Vite 退回去搜配置文件、往上找到仓根的postcss.config.mjs,而@tailwindcss/postcss从仓根解析不到 —— 浏览器拿到的是 HTTP 500:终端只有一行警告,进程退出码 0,服务照常起。
2. 仓外一次干净安装 ERESOLVE。 生成清单声明
tailwindcss ^3.4.19,与它依赖的@object-ui/components的 v4 peer 冲突;#3827 让@object-ui/*变成真能解析之后这条冲突就上膛了。改动
src/index.css改为仓内惯用的 v4 CSS-first 写法(@import 'tailwindcss'+@custom-variant dark+@source+@theme),参照packages/components/src/index.css与examples/console-starter/src/index.css。两个生成器合用一个 builder —— 此前两份 CSS 除body上三个 utility 外逐字节相同。@theme的 token 集与 components 的@theme逐条对齐,含 v3 config 一直缺、而生成的src/Layout.tsx自己就在用的 8 个sidebar-*token(bg-sidebar-primary、data-[state=open]:bg-sidebar-accent…)。postcss.config.js写'@tailwindcss/postcss': {}(同packages/components/postcss.config.js)。tailwind.config.js。 v4 下没有@config指向它时它就是死文件,仓内本身零个tailwind.config.*;v3content的四条扫描面等价迁为@source,workspace 两条绝对 glob(components /plugin-*)语义不变,仓外另补../node_modules/@object-ui/*/dist/**/*.js—— v4 不自动扫被 gitignore 的node_modules,这是 v3content同样缺、v4 才有办法补的一条。tailwindcss ^3.4.19→^4.3.3(锚仓根),新增@tailwindcss/postcss ^4.3.3(锚仓内 6 处一致声明);DEPENDENCY_ANCHORS去掉deferred-tailwind-v4这一整类。commands/dev.ts改接@tailwindcss/postcss,并由@object-ui/cli自己声明这两个插件包 —— 仓根只声明tailwindcss、不声明@tailwindcss/postcss,从 cwd 解析在本仓必然失败(实测MODULE_NOT_FOUND);从 components 的 node_modules 里捞正是 packages/cli 的 createTempAppWithRouting 生成的 app import 了未声明的 lucide-react,且其工具链区间落后仓内一到三个 major #3827 点名的"在消费端糊"的做法,所以在生产端声明。加载失败不再吞成警告,而是带修法响亮报错并拒绝起服务。serve.ts/build.ts同路径核查:两者没有 monorepo 分支,始终走生成的postcss.config.js,因此本 PR 换掉那份配置就同时修好了它们真实被用到的仓外路径;它们在仓内另有一个与 Tailwind 无关的更深缺陷(见文末越界发现),已另行立单而不在本 PR 处理。浏览器实证(dogfood)
同一份探针页(
h-16 bg-background border-b px-4/bg-sidebar-primary size-8 rounded-lg/ 只存在于packages/components/src的min-h-[150px]/ 只存在于packages/plugin-chatbot/src的sm:h-[360px]),由同一个正在跑的objectui dev服务出,Chromium 读 computed style:/src/index.cssdocument.styleSheets0 条规则/*! tailwindcss v4.3.3 */,89 条顶层规则h-16高度0px64pxbg-backgroundrgba(0, 0, 0, 0)rgb(2, 8, 23)px-40px16pxborder-b颜色rgb(0, 0, 0)rgb(30, 41, 59)bg-sidebar-primaryrgba(0, 0, 0, 0)rgb(29, 78, 216)(=hsl(224.3 76.3% 48%))size-8/rounded-lg1264px × 0px/0px32px × 32px/8pxmin-h-[150px](仅 components/src)0px150pxsm:h-[360px](仅 plugin-chatbot/src)0px360px0px/autorgb(2, 8, 23)/rgb(248, 250, 252)/900px/antialiased一处诚实的限定:这次 in-repo 运行里,
@tailwindcss/postcss的自动 source 检测(base = 调用时的 cwd = 仓根)也会扫到仓内其它包(探针外可见h-[260px]这类只属于packages/app-shell/src的类也被编出),所以上表最后两行不能单独证明我写的 workspace@sourceglob 生效。glob 形状是另外用离线编译 fixture 单独验的:绝对路径 glob、目录位plugin-*通配、以及node_modules/@object-ui/*/dist/**/*.js(自动检测永不扫 node_modules,因此这条只能由显式@source命中)三者都实测通过。显式@source仍然必要:自动检测的 base 取决于调用时的 cwd,不保证是 workspace 根。单元测试里没有"真编译一遍"的门禁,原因也是实测的:
@import 'tailwindcss'由插件按样式表自身所在目录解析,fixture 旁边没有node_modules就报Can't resolve 'tailwindcss' in …/app/src。这一端因此留给上面的浏览器实证,单测只钉形状与语义。反向验证(方向先判后跑)
预判先写下再跑,跑完逐条对上:
@tailwind base;在、v3 插件键在、tailwind.config.js被写出、@source全无、@themetoken 期望 35 个实得 0 个、^3.4.19与 peer^4.2.1不同 major、锚表少@tailwindcss/postcss。resolves every theme token through a variable it declares itself在 pre-fix 输入上是绿的 —— 因为那份 CSS 根本没有@theme,被引用集合为空,空集没有未声明成员。这正是 fix(create-plugin): 清掉脚手架的未用 lucide 声明,并让生成的 schema 接口真的可达 (#3755, #3759) #3826 说的"因为什么都没产出而绿",已就地补上referenced.length > 20的非空断言,并把这条原因写进注释。@tailwindcss/postcss从 CLI 的 node_modules 移开(模拟坏安装)→ 退出码 1、带修法的报错、127.0.0.1:5854无人监听;此前同类失败是"警告 + exit 0 + 无样式"。验证
pnpm exec vitest run packages/cli/src/__tests__/ --maxWorkers=2→ 3 files / 63 passedpnpm --filter @object-ui/cli type-check→ 干净;末次编辑后全仓pnpm exec turbo run type-check --concurrency=2→ 78/78 successfulpnpm --filter @object-ui/cli build后按 fix(cli): 生成的临时 app 补齐 lucide-react 与七个 plugin 声明,两处清单区间锚到仓内 #3854 先例核 dist 深度:dist/里"@tailwindcss/postcss": "^4.3.3"、tailwindcss: "^4.3.3"、'@tailwindcss/postcss': {}、@import 'tailwindcss'都在;@tailwind base、'tailwind.config.js'、3.4.19、require('tailwindcss')全部零命中(^4.1.18的那处命中属init.ts的脚手架,与本单无关且本来就是 v4)grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f]'零命中;起过的 dev server(5852/5853/5854/5855)全部按 PID 关净,临时 fixture 与.objectui-tmp已删Generated by Claude Code