dsh-taiwind 0.3.0 → 0.3.1
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/README.md +7 -9
- package/dist/index.js +11 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ flowchart LR
|
|
|
43
43
|
### 1. 安装
|
|
44
44
|
|
|
45
45
|
```sh
|
|
46
|
-
pnpm add dsh-taiwind
|
|
46
|
+
pnpm add dsh-taiwind@latest
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
在业务插件的 `cordis.patch.yml` 里插入它(连同自身行):
|
|
@@ -90,8 +90,6 @@ pnpm add dsh-taiwind
|
|
|
90
90
|
|
|
91
91
|
🚀 客户端直接使用 taiwind 类名,例如 `bg-notes-accent w-notes-panel notes-compact` 即可。
|
|
92
92
|
|
|
93
|
-
没有声明 `dsh.taiwind` 的包不参与样式编译;声明了但路径不是相对 `.css`、文件不存在或指向包外都会明确报错,不会去猜别的 `main.css`。
|
|
94
|
-
|
|
95
93
|
### 3. 发布时携带样式文件
|
|
96
94
|
|
|
97
95
|
在 `package.json` 中添加 `files` 字段,发布时需要携带入口 CSS 及它引用的相对 CSS:
|
|
@@ -130,14 +128,14 @@ CSS 入口存在时**不会自动加载根目录 JS 配置**,需要时在 CSS
|
|
|
130
128
|
|
|
131
129
|
| 项目 | 说明 |
|
|
132
130
|
| --- | --- |
|
|
133
|
-
| 发布 | 原始 CSS 入口及其相对导入必须进 npm
|
|
134
|
-
| 不支持 | TypeScript
|
|
135
|
-
| 冲突检测 |
|
|
136
|
-
| 主题合并 |
|
|
131
|
+
| 发布 | 原始 CSS 入口及其相对导入必须进 npm 包; |
|
|
132
|
+
| 不支持 | TypeScript 配置、npm CSS 包导入、路径别名、远程 CSS、`@plugin`、文件路径形式的 `@source`、自定义 `source(...)` 扫描目录、跨包 CSS 导入 |
|
|
133
|
+
| 冲突检测 | CSS token、同名 `@utility` / `@custom-variant` 定义不一致时自动合并,并输出包含冲突项和双方包名的 warn 日志;同一冲突不会在每次轮询时重复刷屏 |
|
|
134
|
+
| 主题合并 | 按插件 ID、入口路径排序后交由 Tailwind 4 合并,CSS 定义优先于 JS 配置,同名 CSS 定义遵循后者覆盖;所有插件共享全局主题,不按插件隔离 |
|
|
137
135
|
| 自定义 CSS | 一起输出,但不自动限定作用域、去重或改写资源 URL;请用插件前缀选择器和可直接访问的资源地址 |
|
|
138
136
|
| 动态值 | 适合 CSS 变量或内联样式,不要拼接不完整类名 |
|
|
139
|
-
| 共享编译器成本 | 需安装 Tailwind、Oxide
|
|
140
|
-
| 共享不是隔离 |
|
|
137
|
+
| 共享编译器成本 | 需安装 Tailwind、Oxide 原生扫描器等宿主依赖;有磁盘占用(约 8mb~10mb)与宿主 CPU 开销 |
|
|
138
|
+
| 共享不是隔离 | 共用主题与全局选项;CSS 定义冲突只告警,非法配置与不兼容的 JS 全局选项仍会阻止更新;不适合要求完全独立 Tailwind 配置的插件 |
|
|
141
139
|
|
|
142
140
|
## 🛠️ 开发与贡献
|
|
143
141
|
|
package/dist/index.js
CHANGED
|
@@ -149,7 +149,7 @@ async function cssEntry(root, owner) {
|
|
|
149
149
|
if (!await stat(path).then((info) => info.isFile(), () => false)) throw new Error(`${owner}: dsh.taiwind entry not found: ${entry}`);
|
|
150
150
|
return path;
|
|
151
151
|
}
|
|
152
|
-
async function compilePlugins(entries) {
|
|
152
|
+
async function compilePlugins(entries, onWarning) {
|
|
153
153
|
const hash = createHash("sha256");
|
|
154
154
|
const bundleFiles = [];
|
|
155
155
|
const extend = Object.create(null);
|
|
@@ -160,6 +160,7 @@ async function compilePlugins(entries) {
|
|
|
160
160
|
const stylesheets = /* @__PURE__ */ new Map();
|
|
161
161
|
const cssImports = [];
|
|
162
162
|
const cssDefinitions = /* @__PURE__ */ new Map();
|
|
163
|
+
const warnings = /* @__PURE__ */ new Set();
|
|
163
164
|
const configsSeen = /* @__PURE__ */ new Set();
|
|
164
165
|
const setGlobal = (key, value, owner) => {
|
|
165
166
|
if (Object.hasOwn(merged, key) && canonical(merged[key]) !== canonical(value)) throw new Error(`Tailwind global configuration conflict at ${key}: ${owners.get(key)} and ${owner}`);
|
|
@@ -196,7 +197,7 @@ async function compilePlugins(entries) {
|
|
|
196
197
|
};
|
|
197
198
|
const checkDefinition = (key, value, owner) => {
|
|
198
199
|
const previous = cssDefinitions.get(key);
|
|
199
|
-
if (previous && previous.owner !== owner && previous.value !== value)
|
|
200
|
+
if (previous && previous.owner !== owner && previous.value !== value) warnings.add(`Tailwind CSS conflict at ${key}: ${previous.owner} and ${owner}; merging in plugin order`);
|
|
200
201
|
cssDefinitions.set(key, {
|
|
201
202
|
value,
|
|
202
203
|
owner
|
|
@@ -293,6 +294,7 @@ async function compilePlugins(entries) {
|
|
|
293
294
|
const utilities = await readFile(new URL(import.meta.resolve("tailwindcss/utilities.css")), "utf8");
|
|
294
295
|
hash.update(JSON.stringify([theme, utilities]));
|
|
295
296
|
const digest = hash.digest("hex");
|
|
297
|
+
for (const warning of warnings) onWarning?.(warning);
|
|
296
298
|
if (cached?.signature === digest) return cached.css;
|
|
297
299
|
const sources = [];
|
|
298
300
|
for (const file of bundleFiles) sources.push({
|
|
@@ -354,20 +356,24 @@ async function apply(ctx) {
|
|
|
354
356
|
pending = (async () => {
|
|
355
357
|
while (true) {
|
|
356
358
|
const current = generation;
|
|
357
|
-
const
|
|
359
|
+
const entries = ctx.clientModules.graph().entries.map(({ id }) => {
|
|
358
360
|
const path = ctx.clientModules.clientPath(id);
|
|
359
361
|
if (!path) throw new Error(`Missing client bundle: ${id}`);
|
|
360
362
|
return {
|
|
361
363
|
id,
|
|
362
364
|
path
|
|
363
365
|
};
|
|
364
|
-
})
|
|
366
|
+
});
|
|
367
|
+
const warnings = [];
|
|
368
|
+
const compiled = await compilePlugins(entries, (message) => warnings.push(message));
|
|
365
369
|
if (disposed) return;
|
|
366
370
|
if (generation !== current) continue;
|
|
367
371
|
css = compiled;
|
|
368
372
|
etag = `"${createHash("sha256").update(css).digest("hex")}"`;
|
|
369
373
|
failed = false;
|
|
370
|
-
|
|
374
|
+
const warning = warnings.join("\n");
|
|
375
|
+
if (warning && warning !== lastError) ctx.logger.warn(`${PLUGIN_ID}: ${warning}`);
|
|
376
|
+
lastError = warning;
|
|
371
377
|
break;
|
|
372
378
|
}
|
|
373
379
|
})().finally(() => {
|
package/package.json
CHANGED