feat: beta/stable 双渠道构建重构(monorepo + variants + 入口 barrel) - #3
Open
XiaoYangx666 wants to merge 8 commits into
Open
feat: beta/stable 双渠道构建重构(monorepo + variants + 入口 barrel)#3XiaoYangx666 wants to merge 8 commits into
XiaoYangx666 wants to merge 8 commits into
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
- 常用命令、架构总览 - 构建链路约束:rolldown 多入口、dts entry、版本注入双 config 同步、 @minecraft 钉版、legacy-peer-deps、typescript@7 无编译器 API、export type - 开发规则:以实际类型定义为准、文本符号/颜色约束、版本线一致 Co-Authored-By: Claude <noreply@anthropic.com>
共享实现与测试集中到 packages/core/src 与 packages/core/test(不发布), 根目录仅保留编排脚本与测试依赖,删除根 rolldown.config.ts。 Co-Authored-By: Claude <noreply@anthropic.com>
同一份 packages/core/src 用两个渠道的 rolldown 配置构建: - __BETA__ 构建期注入实现条件编译(beta=true / stable=false) - 各渠道用各自 package.json 版本注入 __SAPI_PRO_VERSION_* / 选举数字 - 每渠道独立 tsconfig,@minecraft/* 重定向到各自安装的类型版本 - stable 经 treeshake.moduleSideEffects + dts glob 排除模拟命令子系统 - 发布:beta --tag beta / stable --tag stable,均不挂 latest Co-Authored-By: Claude <noreply@anthropic.com>
移除 per-channel 源码(variants/*/chatBus.ts、commandWiring.ts)与 @sapi/* 别名: - chatBus 实例归入共享 Event/chatBus.ts,Event.ts 不再导出实例 - 每渠道入口 barrel(entry.<ch>.ts / Event.entry.<ch>.ts)决定是否暴露 chatBus - beta 的 d.ts 暴露 chatBus(免空检查),stable 的 d.ts 无 chatBus(导入报 TS2305) - 模拟命令聊天接线内联为 if (__BETA__) chatBus.subscribe(...) - stable 产物经 treeshake.moduleSideEffects + dts glob 剔除 chatBus 模块 - dist 结构回到干净路径(preserveModulesRoot = CORE) Co-Authored-By: Claude <noreply@anthropic.com>
GitHub Actions 的 secrets 上下文仅允许在 job 级 if 与 env 中使用, step 级 if 引用会报 Unrecognized named-value。改为先经 env 读出 NPM_TOKEN 是否配置并写入 step output,发布步骤用 steps.<id>.outputs 判断。 Co-Authored-By: Claude <noreply@anthropic.com>
根 pack 脚本此前只是 build 的别名(只产出 build/*.zip), CI 的 *.tgz 上传/Release 附件因此匹配不到文件。改为 build 后追加 pack:beta + pack:stable,产出两个 .tgz。 Co-Authored-By: Claude <noreply@anthropic.com>
根 devDependencies 不再安装 @minecraft/common/server/server-ui: - 构建链路本就各自用 tsconfig.beta/stable.json 的 paths 重定向到渠道 node_modules - vitest 测试用工厂 mock 不加载真实模块(98 用例通过) - 编辑器类型经根 tsconfig.json 新增的 @minecraft paths 指向 variants/beta 的 beta 类型 Co-Authored-By: Claude <noreply@anthropic.com>
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.
概述
不维护双分支,用单一共享源码同时构建并发布
sapi-pro的 beta / stable 双渠道。beta 与 stable 各有独立的package.json、Rolldown 配置与@minecraft/*依赖版本,同一份packages/core/src构建成不同的dist。改动内容
1. 迁移为 monorepo
packages/core/(src/+test/,不发布)package.json只做脚本编排与测试依赖2. 双渠道构建(
variants/beta+variants/stable)rolldown.config.ts,transform.define注入__BETA__(beta=true /stable=false)实现条件编译 + 死代码消除
__SAPI_PRO_VERSION__(显示字符串)与__SAPI_PRO_VERSION_NUM__(多包主机选举数字),从各自渠道的package.json读取@minecraft/server、@minecraft/server-ui重定向到各自安装的版本(beta 用最新 beta版、stable 用稳定版)
.js/.d.ts;stable只注册游戏原生命令
3. chatBus 改为渠道入口 barrel 隔离
Event/chatBus.ts,只由每渠道入口 barrel(entry.beta.ts/entry.stable.ts、Event.entry.*.ts)决定是否导出chatBus(免空检查);stable 的 d.ts 不导出(消费方import { chatBus }报 TS2305)4. 发布流程
npm publish --tag betanpm publish --tag stablelatest标签,安装用sapi-pro@beta/sapi-pro@stable显式指定build.yml(dev push / PR / 手动)+release.yml(v*标签 / 手动,发布 npm + GitHub Release)验证
npm run typecheck:beta/typecheck:stable双渠道类型检查通过npm test98 个用例全部通过import { chatBus },stable 报 TS2305Event/chatBus;stable 无 chatBus / parser / help,保留共享chatBusClass类型注意事项
npm install后需npm run install:variants(两个渠道各自安装@minecraft/*)NPM_TOKEN(未配置时发布步骤自动跳过)@minecraft/server@2.8.0),不支持成就无关的 beta-only 功能