@dsh-workbench/module-tools 0.2.15 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/build.mjs +13 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-workbench/module-tools",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "模块包的构建与门禁工具:build(单文件 ESM 宿主侧 + 套 loader 壳的浏览器侧)、check(契约/产物边界/源码边界/卡片渲染)。模块包不再各带一份构建脚本。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "esbuild": "^0.28.2",
24
- "@dsh-workbench/shared": "0.2.15"
24
+ "@dsh-workbench/shared": "0.2.16"
25
25
  },
26
26
  "scripts": {
27
27
  "selfcheck": "node scripts/selfcheck.mjs"
package/src/build.mjs CHANGED
@@ -71,6 +71,19 @@ function cssInjector({ root }) {
71
71
  namespace: 'dsh-wb-css',
72
72
  }));
73
73
  context.onLoad({ filter: /.*/, namespace: 'dsh-wb-css' }, (args) => {
74
+ // 来自被 external 的那份 kit(@dsh-workbench/shared)的样式一律不收:外壳运行时自己会注入
75
+ // 那一份,产物里再带一份就变成"两份 kit 样式按选择器混合"(2026-10-18 实测:模块内联了 145
76
+ // 条外壳规则、冻结构建时的版本,与运行的外壳混用 ⇒ 折行 / 塌列 / 标签压值)。见 ADR-0028 §5.1。
77
+ // 两条路径都要认:
78
+ // · 装了依赖的模块仓 —— `node_modules/@dsh-workbench/{shared,core}/…`(pnpm 的 store 里也含这段);
79
+ // · 本仓自己开发时 —— `packages/{shared,workbench}/dist/…`。**是 dist 不是 src**:esbuild 默认
80
+ // 跟随软链(`preserveSymlinks:false`),workspace 的 `node_modules/@dsh-workbench/shared`
81
+ // 软链会被解成真实源码包路径,而 `exports."."` 指的是编译产物 `dist/index.js`,组件样式
82
+ // 与它同住 `dist/components/**`(只写 `src` 会在本仓场景漏收:实测 148 条规则照进产物)。
83
+ const outsourcedKitCss =
84
+ /node_modules\/@dsh-workbench\/(shared|core)\//.test(args.path) ||
85
+ /\/packages\/(shared|workbench)\/(src|dist)\//.test(args.path);
86
+ if (outsourcedKitCss) return { contents: 'export default {};', loader: 'js' };
74
87
  const raw = readFileSync(args.path, 'utf8');
75
88
  const key = relative(root, args.path).split('/').reverse()[0] + ':' + args.path;
76
89
  const scoped = /\.module\.css$/.test(args.path);