cornet-ui 0.1.0-beta.4 → 0.1.0-beta.6
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/dist/plugin-vite.d.ts +1 -1
- package/dist/plugin-vite.js +21 -20
- package/index.css +7 -0
- package/package.json +2 -18
- package/plugin-vite.ts +17 -2
package/dist/plugin-vite.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface CornetPluginOptions {
|
|
|
27
27
|
* `@source not` directives to that file during `vite build`, then restores
|
|
28
28
|
* this exact content so the file never changes from git's point of view.
|
|
29
29
|
*/
|
|
30
|
-
export declare const CSS_BASE_CONTENT = "/* Cornet CSS entry.\n During `vite build`, the Cornet Vite plugin temporarily appends\n `@source not` directives here to exclude unused components from\n Tailwind's scanning, then restores this file. Without the plugin,\n Tailwind simply scans every component: everything still works. */\n";
|
|
30
|
+
export declare const CSS_BASE_CONTENT = "/* Cornet CSS entry.\n The @source below registers the component sources with Tailwind: class\n literals live in the .vue templates and .types.ts constants, and Tailwind\n ignores node_modules unless a source is declared explicitly. Do not\n remove it, or variant classes (btn-primary, alert-success, ...) will be\n missing from the generated CSS when Cornet is installed from npm.\n\n During `vite build`, the Cornet Vite plugin temporarily appends\n `@source not` directives here to exclude unused components from\n Tailwind's scanning, then restores this file. Without the plugin,\n Tailwind simply scans every component: everything still works. */\n@source \"./components\";\n";
|
|
31
31
|
/** Parse `export { default as X } from './components/...'` lines of index.ts. */
|
|
32
32
|
export declare function parseLibraryExports(indexContent: string): Map<string, string>;
|
|
33
33
|
export interface UsageScanResult {
|
package/dist/plugin-vite.js
CHANGED
|
@@ -8,7 +8,7 @@ var u = [
|
|
|
8
8
|
".ts",
|
|
9
9
|
".tsx",
|
|
10
10
|
".jsx"
|
|
11
|
-
], d = "/* Cornet CSS entry.\n During `vite build`, the Cornet Vite plugin temporarily appends\n `@source not` directives here to exclude unused components from\n Tailwind's scanning, then restores this file. Without the plugin,\n Tailwind simply scans every component: everything still works. */\n";
|
|
11
|
+
], d = "/* Cornet CSS entry.\n The @source below registers the component sources with Tailwind: class\n literals live in the .vue templates and .types.ts constants, and Tailwind\n ignores node_modules unless a source is declared explicitly. Do not\n remove it, or variant classes (btn-primary, alert-success, ...) will be\n missing from the generated CSS when Cornet is installed from npm.\n\n During `vite build`, the Cornet Vite plugin temporarily appends\n `@source not` directives here to exclude unused components from\n Tailwind's scanning, then restores this file. Without the plugin,\n Tailwind simply scans every component: everything still works. */\n@source \"./components\";\n";
|
|
12
12
|
function f(e) {
|
|
13
13
|
let t = /* @__PURE__ */ new Map(), n = /export\s*{\s*default\s+as\s+(\w+)\s*}\s+from\s+['"](.+?)['"]/g, r;
|
|
14
14
|
for (; (r = n.exec(e)) !== null;) t.set(r[1], r[2]);
|
|
@@ -83,13 +83,13 @@ function _(t) {
|
|
|
83
83
|
return i;
|
|
84
84
|
}
|
|
85
85
|
function v(n = {}) {
|
|
86
|
-
let { showOutput: r = !0, failOnError: o = !1 } = n, u, v, y, b = (e) => {
|
|
86
|
+
let { showOutput: r = !0, failOnError: o = !1 } = n, u, v, y, b = !1, x = (e) => {
|
|
87
87
|
if (console.error("[vite-plugin-cornet] component detection failed:", e), o) throw e;
|
|
88
|
-
},
|
|
88
|
+
}, S = () => {
|
|
89
89
|
try {
|
|
90
|
-
y && e(y) && t(y, "utf-8") !== d && i(y, d);
|
|
90
|
+
b && y && e(y) && t(y, "utf-8") !== d && i(y, d);
|
|
91
91
|
} catch (e) {
|
|
92
|
-
|
|
92
|
+
x(e);
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
return {
|
|
@@ -103,32 +103,33 @@ function v(n = {}) {
|
|
|
103
103
|
v = n.libPath ? c(n.libPath) : g(a(l(import.meta.url))), y = s(v, "index.css");
|
|
104
104
|
let o = s(v, "index.ts");
|
|
105
105
|
if (!e(o)) {
|
|
106
|
-
console.
|
|
106
|
+
r && console.log("[vite-plugin-cornet] sources not present (dist install), CSS exclusions skipped");
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
b = !0;
|
|
110
|
+
let x = f(t(o, "utf-8")), C = n.packageNames;
|
|
111
|
+
if (!C) {
|
|
111
112
|
let n = s(v, "package.json"), r = e(n) ? JSON.parse(t(n, "utf-8")).name : void 0;
|
|
112
|
-
|
|
113
|
+
C = r ? [r] : [];
|
|
113
114
|
}
|
|
114
|
-
let
|
|
115
|
-
for (let e of
|
|
116
|
-
let e = p(t(n, "utf-8"),
|
|
117
|
-
e.used.forEach((e) =>
|
|
115
|
+
let w = u?.root ?? process.cwd(), T = n.srcDirs ?? ["src"], E = /* @__PURE__ */ new Set(), D = !1;
|
|
116
|
+
for (let e of T) for (let n of _(c(w, e))) {
|
|
117
|
+
let e = p(t(n, "utf-8"), C);
|
|
118
|
+
e.used.forEach((e) => E.add(e)), D ||= e.namespaceImport;
|
|
118
119
|
}
|
|
119
|
-
if (
|
|
120
|
-
r && console.log("[vite-plugin-cornet] namespace import detected, keeping all components"),
|
|
120
|
+
if (D) {
|
|
121
|
+
r && console.log("[vite-plugin-cornet] namespace import detected, keeping all components"), S();
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
|
-
let
|
|
124
|
-
i(y, d +
|
|
124
|
+
let O = m(E, x, v), { css: k, excludedCount: A } = h(x, O);
|
|
125
|
+
i(y, d + k), r && console.log(`[vite-plugin-cornet] ${O.size}/${x.size} components used, ${A} excluded from CSS`);
|
|
125
126
|
} catch (e) {
|
|
126
|
-
|
|
127
|
+
x(e);
|
|
127
128
|
}
|
|
128
129
|
},
|
|
129
|
-
closeBundle:
|
|
130
|
+
closeBundle: S,
|
|
130
131
|
buildEnd(e) {
|
|
131
|
-
e &&
|
|
132
|
+
e && S();
|
|
132
133
|
}
|
|
133
134
|
};
|
|
134
135
|
}
|
package/index.css
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
/* Cornet CSS entry.
|
|
2
|
+
The @source below registers the component sources with Tailwind: class
|
|
3
|
+
literals live in the .vue templates and .types.ts constants, and Tailwind
|
|
4
|
+
ignores node_modules unless a source is declared explicitly. Do not
|
|
5
|
+
remove it, or variant classes (btn-primary, alert-success, ...) will be
|
|
6
|
+
missing from the generated CSS when Cornet is installed from npm.
|
|
7
|
+
|
|
2
8
|
During `vite build`, the Cornet Vite plugin temporarily appends
|
|
3
9
|
`@source not` directives here to exclude unused components from
|
|
4
10
|
Tailwind's scanning, then restores this file. Without the plugin,
|
|
5
11
|
Tailwind simply scans every component: everything still works. */
|
|
12
|
+
@source "./components";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cornet-ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.0-beta.
|
|
4
|
+
"version": "0.1.0-beta.6",
|
|
5
5
|
"description": "Cornet — Vue 3 component library built on DaisyUI 5 and Tailwind CSS 4. Usable as an npm package or embedded directly as source in your project.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"homepage": "https://cornet-ui.com",
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|
|
35
|
-
"url": "
|
|
35
|
+
"url": "https://gitlab.limos.fr/hub-isima/daisyui-vue-kit.git"
|
|
36
36
|
},
|
|
37
37
|
"bugs": {
|
|
38
38
|
"url": "https://github.com/t-lecoublet/Cornet/issues"
|
|
@@ -60,22 +60,6 @@
|
|
|
60
60
|
"optional": true
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
-
"devDependencies": {
|
|
64
|
-
"@types/node": "^25.6.0",
|
|
65
|
-
"@vitejs/plugin-vue": "^6.0.6",
|
|
66
|
-
"@vue/eslint-config-typescript": "^14.0.0",
|
|
67
|
-
"@vue/test-utils": "^2.4.6",
|
|
68
|
-
"@vue/tsconfig": "^0.9.1",
|
|
69
|
-
"eslint": "^9.0.0",
|
|
70
|
-
"eslint-plugin-vue": "^10.0.0",
|
|
71
|
-
"happy-dom": "^20.0.0",
|
|
72
|
-
"typescript": "^6.0.2",
|
|
73
|
-
"vite": "^8.0.8",
|
|
74
|
-
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
75
|
-
"vitest": "^4.0.0",
|
|
76
|
-
"vue": "^3.5.32",
|
|
77
|
-
"vue-tsc": "^3.2.6"
|
|
78
|
-
},
|
|
79
63
|
"exports": {
|
|
80
64
|
".": {
|
|
81
65
|
"types": "./dist/index.d.ts",
|
package/plugin-vite.ts
CHANGED
|
@@ -35,10 +35,17 @@ const SOURCE_EXTENSIONS = ['.vue', '.js', '.ts', '.tsx', '.jsx']
|
|
|
35
35
|
* this exact content so the file never changes from git's point of view.
|
|
36
36
|
*/
|
|
37
37
|
export const CSS_BASE_CONTENT = `/* Cornet CSS entry.
|
|
38
|
+
The @source below registers the component sources with Tailwind: class
|
|
39
|
+
literals live in the .vue templates and .types.ts constants, and Tailwind
|
|
40
|
+
ignores node_modules unless a source is declared explicitly. Do not
|
|
41
|
+
remove it, or variant classes (btn-primary, alert-success, ...) will be
|
|
42
|
+
missing from the generated CSS when Cornet is installed from npm.
|
|
43
|
+
|
|
38
44
|
During \`vite build\`, the Cornet Vite plugin temporarily appends
|
|
39
45
|
\`@source not\` directives here to exclude unused components from
|
|
40
46
|
Tailwind's scanning, then restores this file. Without the plugin,
|
|
41
47
|
Tailwind simply scans every component: everything still works. */
|
|
48
|
+
@source "./components";
|
|
42
49
|
`
|
|
43
50
|
|
|
44
51
|
/** Parse `export { default as X } from './components/...'` lines of index.ts. */
|
|
@@ -190,6 +197,9 @@ export default function cornetPlugin(options: CornetPluginOptions = {}): Plugin
|
|
|
190
197
|
let config: ResolvedConfig | undefined
|
|
191
198
|
let libRoot: string | undefined
|
|
192
199
|
let cssFilePath: string | undefined
|
|
200
|
+
// Only touch index.css when detection actually ran: a dist-only install
|
|
201
|
+
// has no sources and its CSS file must never be rewritten.
|
|
202
|
+
let detectionActive = false
|
|
193
203
|
|
|
194
204
|
const fail = (error: unknown) => {
|
|
195
205
|
console.error('[vite-plugin-cornet] component detection failed:', error)
|
|
@@ -198,7 +208,7 @@ export default function cornetPlugin(options: CornetPluginOptions = {}): Plugin
|
|
|
198
208
|
|
|
199
209
|
const restoreCss = () => {
|
|
200
210
|
try {
|
|
201
|
-
if (cssFilePath && existsSync(cssFilePath) && readFileSync(cssFilePath, 'utf-8') !== CSS_BASE_CONTENT) {
|
|
211
|
+
if (detectionActive && cssFilePath && existsSync(cssFilePath) && readFileSync(cssFilePath, 'utf-8') !== CSS_BASE_CONTENT) {
|
|
202
212
|
writeFileSync(cssFilePath, CSS_BASE_CONTENT)
|
|
203
213
|
}
|
|
204
214
|
} catch (error) {
|
|
@@ -223,9 +233,14 @@ export default function cornetPlugin(options: CornetPluginOptions = {}): Plugin
|
|
|
223
233
|
|
|
224
234
|
const indexPath = join(libRoot, 'index.ts')
|
|
225
235
|
if (!existsSync(indexPath)) {
|
|
226
|
-
|
|
236
|
+
// Expected with the dist-only npm package: Tailwind only scans the
|
|
237
|
+
// modules the app actually imports, so exclusions are unnecessary.
|
|
238
|
+
if (showOutput) {
|
|
239
|
+
console.log('[vite-plugin-cornet] sources not present (dist install), CSS exclusions skipped')
|
|
240
|
+
}
|
|
227
241
|
return
|
|
228
242
|
}
|
|
243
|
+
detectionActive = true
|
|
229
244
|
const componentPaths = parseLibraryExports(readFileSync(indexPath, 'utf-8'))
|
|
230
245
|
|
|
231
246
|
let packageNames = options.packageNames
|