@tbox.cn/app-build 0.0.0-stage → 1.0.0-alpha.10

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.
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-build",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0-alpha.10",
4
+ "type": "module",
5
+ "description": "tbox-app 1.0 build-time leaf: scan apps/ modules/ and generate manifest, registries, documents; Vite plugin and checks.",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js"
10
+ },
11
+ "./package.json": "./package.json",
12
+ "./tailwind-sources": {
13
+ "types": "./tailwind-sources.d.mts",
14
+ "import": "./tailwind-sources.mjs"
15
+ },
16
+ "./compat": {
17
+ "types": "./compat.d.mts",
18
+ "import": "./compat.mjs"
19
+ }
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "dependencies": {
25
+ "typescript": "5.9.3"
26
+ },
27
+ "peerDependencies": {
28
+ "vite": "6.4.3"
29
+ },
30
+ "peerDependenciesMeta": {
31
+ "vite": {
32
+ "optional": true
33
+ }
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "24.13.3",
37
+ "tsup": "8.5.1",
38
+ "vite": "6.4.3",
39
+ "vitest": "4.1.10"
40
+ },
41
+ "engines": {
42
+ "node": ">=20.0.0"
43
+ },
44
+ "files": [
45
+ "dist",
46
+ "tailwind-sources.mjs",
47
+ "tailwind-sources.d.mts",
48
+ "README.md",
49
+ "LICENSE",
50
+ "compat.mjs",
51
+ "compat.d.mts"
52
+ ],
53
+ "license": "MIT",
54
+ "scripts": {
55
+ "build": "tsup",
56
+ "typecheck": "tsc --noEmit",
57
+ "test": "vitest run"
58
+ }
6
59
  }
@@ -0,0 +1,2 @@
1
+ export function collectModuleSourceDirs(appRoot: string): string[];
2
+ export function renderModuleSources(dirs: string[]): string;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Tailwind 模块源码发现:dev/build 的 Vite 插件与证据包 surface-css 共用。
3
+ *
4
+ * 只登记有 src/client/index.ts 的客户端模块,扫描其 src/client/;显式绝对路径——
5
+ * Tailwind 的 @source 不跟随通配符路径(对 pnpm 软链不生效)。
6
+ */
7
+ import { existsSync, readdirSync, realpathSync, statSync } from 'node:fs';
8
+ import path from 'node:path';
9
+
10
+ const MODULE_ROOTS = [
11
+ { dir: 'modules', prefixes: ['module-'] },
12
+ { dir: 'apps/client/node_modules/@tbox.cn', prefixes: ['app-module-', 'module-'] },
13
+ ];
14
+
15
+ /**
16
+ * @param {string} appRoot
17
+ * @returns {string[]} 模块源码目录(绝对路径,已排序/去重)
18
+ */
19
+ export function collectModuleSourceDirs(appRoot) {
20
+ const root = path.resolve(appRoot);
21
+ const seen = new Set();
22
+ const out = [];
23
+
24
+ for (const { dir, prefixes } of MODULE_ROOTS) {
25
+ const base = path.join(root, dir);
26
+ if (!existsSync(base)) continue;
27
+ for (const name of readdirSync(base).sort()) {
28
+ if (!prefixes.some((prefix) => name.startsWith(prefix))) continue;
29
+ const moduleDir = path.join(base, name);
30
+ const clientDir = path.join(moduleDir, 'src/client');
31
+ let real;
32
+ try {
33
+ if (!statSync(moduleDir).isDirectory()) continue;
34
+ if (!existsSync(path.join(clientDir, 'index.ts'))) continue;
35
+ real = realpathSync(clientDir);
36
+ } catch {
37
+ continue;
38
+ }
39
+ if (seen.has(real)) continue;
40
+ seen.add(real);
41
+ out.push(clientDir);
42
+ }
43
+ }
44
+ return out.sort();
45
+ }
46
+
47
+ /**
48
+ * @param {string[]} dirs
49
+ * @returns {string} 可拼进任意 Tailwind 入口 CSS 的 @source 行
50
+ */
51
+ export function renderModuleSources(dirs) {
52
+ return dirs
53
+ .map((dir) => `@source ${JSON.stringify(dir.split(path.sep).join('/'))};`)
54
+ .join('\n');
55
+ }