@pikacss/unplugin-pikacss 0.0.57 → 0.0.59
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 +20 -3
- package/dist/esbuild.d.mts +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +42 -4
- package/dist/rolldown.d.mts +2 -2
- package/dist/rollup.d.mts +2 -2
- package/dist/rspack.d.mts +2 -2
- package/dist/{types-ekE7tO8H.d.mts → types-CBBDRP-6.d.mts} +43 -17
- package/dist/vite.d.mts +2 -2
- package/dist/webpack.d.mts +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Universal bundler plugin for PikaCSS. Supports Vite, Webpack, Rspack, Rollup, Rolldown, and esbuild.
|
|
4
4
|
|
|
5
|
-
The Vite entry supports Vite 7 and 8 only.
|
|
5
|
+
PikaCSS requires Node.js 22 or later (package engine range: `>=22`). The Vite entry supports Vite 7 and 8 only.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -28,12 +28,29 @@ export default defineConfig({
|
|
|
28
28
|
|
|
29
29
|
### Other bundlers
|
|
30
30
|
|
|
31
|
+
Use the entry point matching your bundler:
|
|
32
|
+
|
|
33
|
+
| Bundler | Entry point |
|
|
34
|
+
|---|---|
|
|
35
|
+
| Rollup | `@pikacss/unplugin-pikacss/rollup` |
|
|
36
|
+
| Rolldown | `@pikacss/unplugin-pikacss/rolldown` |
|
|
37
|
+
| Webpack | `@pikacss/unplugin-pikacss/webpack` |
|
|
38
|
+
| Rspack | `@pikacss/unplugin-pikacss/rspack` |
|
|
39
|
+
| esbuild | `@pikacss/unplugin-pikacss/esbuild` |
|
|
40
|
+
|
|
41
|
+
For example:
|
|
42
|
+
|
|
31
43
|
```ts
|
|
44
|
+
// rollup.config.ts
|
|
32
45
|
import pikacss from '@pikacss/unplugin-pikacss/rollup'
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
plugins: [pikacss()],
|
|
49
|
+
}
|
|
35
50
|
```
|
|
36
51
|
|
|
52
|
+
See the integration guide for bundler-specific configuration details.
|
|
53
|
+
|
|
37
54
|
## Documentation
|
|
38
55
|
|
|
39
56
|
See the [full documentation](https://pikacss.github.io/integrations/unplugin).
|
package/dist/esbuild.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-
|
|
1
|
+
import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
|
|
2
2
|
import * as _$unplugin from "unplugin";
|
|
3
3
|
export * from "@pikacss/integration";
|
|
4
4
|
|
|
@@ -21,4 +21,4 @@ export * from "@pikacss/integration";
|
|
|
21
21
|
*/
|
|
22
22
|
declare const _default: (options?: PluginOptions | undefined) => _$unplugin.EsbuildPlugin;
|
|
23
23
|
//#endregion
|
|
24
|
-
export { PluginOptions, ResolvedPluginOptions, _default as default };
|
|
24
|
+
export { PluginOptions, ResolvedPluginOptions, ScanOptions, _default as default };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-
|
|
1
|
+
import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
|
|
2
2
|
import * as _$unplugin from "unplugin";
|
|
3
3
|
import { UnpluginFactory } from "unplugin";
|
|
4
4
|
export * from "@pikacss/integration";
|
|
@@ -9,7 +9,7 @@ export * from "@pikacss/integration";
|
|
|
9
9
|
*
|
|
10
10
|
* @param options - User-supplied plugin configuration. When `undefined`, all defaults apply.
|
|
11
11
|
* @param meta - Unplugin metadata providing the target bundler framework name.
|
|
12
|
-
* @returns An unplugin hooks object consumed by
|
|
12
|
+
* @returns An unplugin hooks object consumed by the exported bundler adapters.
|
|
13
13
|
*
|
|
14
14
|
* @remarks
|
|
15
15
|
* This is the core entry-point called by `createUnplugin`. It resolves user options,
|
|
@@ -47,4 +47,4 @@ declare const unpluginFactory: UnpluginFactory<PluginOptions | undefined>;
|
|
|
47
47
|
*/
|
|
48
48
|
declare const unpluginPika: _$unplugin.UnpluginInstance<PluginOptions | undefined, boolean>;
|
|
49
49
|
//#endregion
|
|
50
|
-
export { PluginOptions, ResolvedPluginOptions, unpluginPika as default, unpluginPika, unpluginFactory };
|
|
50
|
+
export { PluginOptions, ResolvedPluginOptions, ScanOptions, unpluginPika as default, unpluginPika, unpluginFactory };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
+
import { writeFile } from "node:fs/promises";
|
|
2
3
|
import process from "node:process";
|
|
3
|
-
import { createCtx, log } from "@pikacss/integration";
|
|
4
|
+
import { consoleDiagnosticHandler, createCtx, log } from "@pikacss/integration";
|
|
4
5
|
import { resolve } from "pathe";
|
|
5
6
|
import { debounce } from "perfect-debounce";
|
|
6
7
|
import { createUnplugin } from "unplugin";
|
|
@@ -13,7 +14,7 @@ const PLUGIN_NAME = "unplugin-pikacss";
|
|
|
13
14
|
*
|
|
14
15
|
* @param options - User-supplied plugin configuration. When `undefined`, all defaults apply.
|
|
15
16
|
* @param meta - Unplugin metadata providing the target bundler framework name.
|
|
16
|
-
* @returns An unplugin hooks object consumed by
|
|
17
|
+
* @returns An unplugin hooks object consumed by the exported bundler adapters.
|
|
17
18
|
*
|
|
18
19
|
* @remarks
|
|
19
20
|
* This is the core entry-point called by `createUnplugin`. It resolves user options,
|
|
@@ -32,7 +33,9 @@ const PLUGIN_NAME = "unplugin-pikacss";
|
|
|
32
33
|
* ```
|
|
33
34
|
*/
|
|
34
35
|
const unpluginFactory = (options, meta) => {
|
|
35
|
-
const { cwd: userCwd, currentPackageName = "@pikacss/unplugin-pikacss", config: configOrPath, tsCodegen = true, cssCodegen = true, scan = {}, fnName = "pika", transformedFormat = "string", autoCreateConfig = false } = options ?? {};
|
|
36
|
+
const { cwd: userCwd, currentPackageName = "@pikacss/unplugin-pikacss", config: configOrPath, tsCodegen = true, cssCodegen = true, scan = {}, fnName = "pika", transformedFormat = "string", autoCreateConfig = false, report = false } = options ?? {};
|
|
37
|
+
const reportEnabled = report === true || typeof report === "object" && report != null;
|
|
38
|
+
const reportOutputPath = typeof report === "object" && report != null ? report.output : void 0;
|
|
36
39
|
log.debug("Creating unplugin factory with options:", options);
|
|
37
40
|
const resolvedOptions = {
|
|
38
41
|
currentPackageName,
|
|
@@ -58,10 +61,35 @@ const unpluginFactory = (options, meta) => {
|
|
|
58
61
|
let mode = "build";
|
|
59
62
|
const viteServers = [];
|
|
60
63
|
const rspackCompilers = [];
|
|
64
|
+
const collectedErrors = [];
|
|
65
|
+
let currentModuleId = null;
|
|
66
|
+
const onDiagnostic = (diagnostic) => {
|
|
67
|
+
consoleDiagnosticHandler(diagnostic);
|
|
68
|
+
if (diagnostic.level === "error") collectedErrors.push({
|
|
69
|
+
diagnostic,
|
|
70
|
+
moduleId: currentModuleId
|
|
71
|
+
});
|
|
72
|
+
};
|
|
61
73
|
const ctx = createCtx({
|
|
62
74
|
cwd: resolve(userCwd ?? process.cwd()),
|
|
63
|
-
...resolvedOptions
|
|
75
|
+
...resolvedOptions,
|
|
76
|
+
onDiagnostic
|
|
64
77
|
});
|
|
78
|
+
async function emitTokenReport() {
|
|
79
|
+
const reportFn = ctx.engine.designTokens?.report;
|
|
80
|
+
if (typeof reportFn !== "function") {
|
|
81
|
+
log.debug("Design-token report requested, but no design-tokens plugin surface is present.");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const result = reportFn();
|
|
85
|
+
log.info(`[design-tokens] ${result.totalTokens} tokens, ${result.used.length} used, ${result.unused.length} unused`);
|
|
86
|
+
log.info(`[design-tokens] ${result.deprecatedInUse.length} deprecated in use, ${result.strictViolations.error} strict error(s), ${result.strictViolations.warning} strict warning(s)`);
|
|
87
|
+
if (reportOutputPath != null) {
|
|
88
|
+
const outPath = resolve(ctx.cwd, reportOutputPath);
|
|
89
|
+
await writeFile(outPath, `${JSON.stringify(result, null, 2)}\n`, "utf-8");
|
|
90
|
+
log.info(`[design-tokens] report written to ${outPath}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
65
93
|
function applyRuntimeContext(nextCwd, nextMode) {
|
|
66
94
|
if (userCwd == null) ctx.cwd = resolve(nextCwd);
|
|
67
95
|
mode = nextMode;
|
|
@@ -243,9 +271,11 @@ const unpluginFactory = (options, meta) => {
|
|
|
243
271
|
this.addWatchFile(ctx.resolvedConfigPath);
|
|
244
272
|
log.debug(`Added watch file: ${ctx.resolvedConfigPath}`);
|
|
245
273
|
}
|
|
274
|
+
currentModuleId = id;
|
|
246
275
|
try {
|
|
247
276
|
return await ctx.transform(code, id);
|
|
248
277
|
} finally {
|
|
278
|
+
currentModuleId = null;
|
|
249
279
|
if (ctx.isIdle) await flushPendingGeneratedWrites();
|
|
250
280
|
}
|
|
251
281
|
}
|
|
@@ -254,6 +284,14 @@ const unpluginFactory = (options, meta) => {
|
|
|
254
284
|
if (mode !== "build") return;
|
|
255
285
|
await ctx.waitForIdle();
|
|
256
286
|
for (const file of ctx.getScannedButNotTransformedFiles()) log.warn(`Styles from ${file} were included in the generated CSS but the file was never reached by the bundler — dead file or missing import?`);
|
|
287
|
+
if (reportEnabled) await emitTokenReport();
|
|
288
|
+
if (collectedErrors.length > 0) {
|
|
289
|
+
const details = collectedErrors.map(({ diagnostic, moduleId }) => {
|
|
290
|
+
const where = moduleId != null ? ` (${moduleId})` : "";
|
|
291
|
+
return ` - ${diagnostic.plugin != null ? `[${diagnostic.plugin}] ` : ""}${diagnostic.code}${where}: ${diagnostic.message}`;
|
|
292
|
+
}).join("\n");
|
|
293
|
+
throw new Error(`PikaCSS reported ${collectedErrors.length} error diagnostic(s):\n${details}`);
|
|
294
|
+
}
|
|
257
295
|
},
|
|
258
296
|
watchChange(id, change) {
|
|
259
297
|
if (change?.event === "delete") {
|
package/dist/rolldown.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-
|
|
1
|
+
import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
|
|
2
2
|
export * from "@pikacss/integration";
|
|
3
3
|
|
|
4
4
|
//#region ../../node_modules/.pnpm/rolldown@1.0.0-rc.12_@emnapi+core@1.11.1_@emnapi+runtime@1.11.1/node_modules/rolldown/dist/shared/logging-C6h4g8dA.d.mts
|
|
@@ -5745,4 +5745,4 @@ interface InputOptions {
|
|
|
5745
5745
|
*/
|
|
5746
5746
|
declare const _default: (options?: PluginOptions | undefined) => Plugin<any> | Plugin<any>[];
|
|
5747
5747
|
//#endregion
|
|
5748
|
-
export { PluginOptions, ResolvedPluginOptions, _default as default };
|
|
5748
|
+
export { PluginOptions, ResolvedPluginOptions, ScanOptions, _default as default };
|
package/dist/rollup.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-
|
|
1
|
+
import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
|
|
2
2
|
import * as _$unplugin from "unplugin";
|
|
3
3
|
export * from "@pikacss/integration";
|
|
4
4
|
|
|
@@ -21,4 +21,4 @@ export * from "@pikacss/integration";
|
|
|
21
21
|
*/
|
|
22
22
|
declare const _default: (options?: PluginOptions | undefined) => _$unplugin.RollupPlugin<any> | _$unplugin.RollupPlugin<any>[];
|
|
23
23
|
//#endregion
|
|
24
|
-
export { PluginOptions, ResolvedPluginOptions, _default as default };
|
|
24
|
+
export { PluginOptions, ResolvedPluginOptions, ScanOptions, _default as default };
|
package/dist/rspack.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-
|
|
1
|
+
import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
|
|
2
2
|
export * from "@pikacss/integration";
|
|
3
3
|
|
|
4
4
|
//#region src/rspack.d.ts
|
|
@@ -20,4 +20,4 @@ export * from "@pikacss/integration";
|
|
|
20
20
|
*/
|
|
21
21
|
declare const _default: (options?: PluginOptions | undefined) => RspackPluginInstance;
|
|
22
22
|
//#endregion
|
|
23
|
-
export { PluginOptions, ResolvedPluginOptions, _default as default };
|
|
23
|
+
export { PluginOptions, ResolvedPluginOptions, ScanOptions, _default as default };
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import { EngineConfig, IntegrationContextOptions, Nullish } from "@pikacss/integration";
|
|
2
2
|
|
|
3
3
|
//#region src/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Glob patterns controlling which source files are scanned for `pika()` calls.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Explicit `include` or `exclude` values replace the corresponding defaults verbatim;
|
|
9
|
+
* they are not merged with the default patterns.
|
|
10
|
+
*/
|
|
11
|
+
interface ScanOptions {
|
|
12
|
+
/**
|
|
13
|
+
* File glob patterns to scan. Supports a single string or array of strings.
|
|
14
|
+
* When omitted, the default covers every extension the AST compiler
|
|
15
|
+
* supports: the full JS family plus Vue SFCs.
|
|
16
|
+
*
|
|
17
|
+
* @default ['**\/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,vue}']
|
|
18
|
+
*/
|
|
19
|
+
include?: string | string[];
|
|
20
|
+
/**
|
|
21
|
+
* File glob patterns to exclude. Supports a single string or array of strings.
|
|
22
|
+
* The default skips dependencies, build outputs, coverage, VCS metadata, and
|
|
23
|
+
* framework build dirs (`.nuxt`/`.output`).
|
|
24
|
+
*
|
|
25
|
+
* @default ['node_modules/**', 'dist/**', '.git/**', '.nuxt/**', '.output/**', 'coverage/**']
|
|
26
|
+
*/
|
|
27
|
+
exclude?: string | string[];
|
|
28
|
+
}
|
|
4
29
|
/**
|
|
5
30
|
* User-facing configuration options for the PikaCSS bundler plugin.
|
|
6
31
|
*
|
|
@@ -39,22 +64,7 @@ interface PluginOptions {
|
|
|
39
64
|
*
|
|
40
65
|
* @default `{ include: ['**\/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,vue}'], exclude: ['node_modules/**', 'dist/**', '.git/**', '.nuxt/**', '.output/**', 'coverage/**'] }`
|
|
41
66
|
*/
|
|
42
|
-
scan?:
|
|
43
|
-
/**
|
|
44
|
-
* File glob patterns to scan. Supports a single string or array of strings.
|
|
45
|
-
* When omitted, the default covers every extension the AST compiler
|
|
46
|
-
* supports: the full JS family plus Vue SFCs. An explicit value wins verbatim.
|
|
47
|
-
* @default ['**\/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,vue}']
|
|
48
|
-
*/
|
|
49
|
-
include?: string | string[];
|
|
50
|
-
/**
|
|
51
|
-
* File glob patterns to exclude. Supports a single string or array of strings.
|
|
52
|
-
* The default skips dependencies, build outputs, coverage, VCS metadata, and
|
|
53
|
-
* framework build dirs (`.nuxt`/`.output`). An explicit value wins verbatim.
|
|
54
|
-
* @default ['node_modules/**', 'dist/**', '.git/**', '.nuxt/**', '.output/**', 'coverage/**']
|
|
55
|
-
*/
|
|
56
|
-
exclude?: string | string[];
|
|
57
|
-
};
|
|
67
|
+
scan?: ScanOptions;
|
|
58
68
|
/**
|
|
59
69
|
* Engine configuration object or a path to a `pika.config.*` file. When omitted, the plugin
|
|
60
70
|
* auto-discovers a config file in the project root.
|
|
@@ -108,6 +118,22 @@ interface PluginOptions {
|
|
|
108
118
|
* @default `'@pikacss/unplugin-pikacss'`
|
|
109
119
|
*/
|
|
110
120
|
currentPackageName?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Emit a design-token usage report at the end of a production build. Requires
|
|
123
|
+
* `@pikacss/plugin-design-tokens` to be registered; a no-op otherwise.
|
|
124
|
+
*
|
|
125
|
+
* @remarks
|
|
126
|
+
* `true` logs a concise summary (total tokens, used/unused counts, deprecated
|
|
127
|
+
* tokens in use, and strict-violation counts) once per build. Passing
|
|
128
|
+
* `{ output }` additionally writes the full report as JSON to that path,
|
|
129
|
+
* resolved against the project root. The report is emitted only in build mode,
|
|
130
|
+
* so a dev server never spams it per HMR update.
|
|
131
|
+
*
|
|
132
|
+
* @default `false` (no report)
|
|
133
|
+
*/
|
|
134
|
+
report?: boolean | {
|
|
135
|
+
/** File path (resolved against the project root) to write the full report JSON to. */output?: string;
|
|
136
|
+
};
|
|
111
137
|
}
|
|
112
138
|
/**
|
|
113
139
|
* Normalized plugin configuration with all defaults applied and boolean shorthands expanded.
|
|
@@ -136,4 +162,4 @@ interface ResolvedPluginOptions {
|
|
|
136
162
|
autoCreateConfig: boolean;
|
|
137
163
|
}
|
|
138
164
|
//#endregion
|
|
139
|
-
export { ResolvedPluginOptions as n, PluginOptions as t };
|
|
165
|
+
export { ResolvedPluginOptions as n, ScanOptions as r, PluginOptions as t };
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-
|
|
1
|
+
import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
export * from "@pikacss/integration";
|
|
4
4
|
|
|
@@ -23,4 +23,4 @@ export * from "@pikacss/integration";
|
|
|
23
23
|
*/
|
|
24
24
|
declare const _default: (options?: PluginOptions) => Plugin;
|
|
25
25
|
//#endregion
|
|
26
|
-
export { PluginOptions, ResolvedPluginOptions, _default as default };
|
|
26
|
+
export { PluginOptions, ResolvedPluginOptions, ScanOptions, _default as default };
|
package/dist/webpack.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-
|
|
1
|
+
import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
|
|
2
2
|
export * from "@pikacss/integration";
|
|
3
3
|
|
|
4
4
|
//#region src/webpack.d.ts
|
|
@@ -20,4 +20,4 @@ export * from "@pikacss/integration";
|
|
|
20
20
|
*/
|
|
21
21
|
declare const _default: (options?: PluginOptions | undefined) => WebpackPluginInstance;
|
|
22
22
|
//#endregion
|
|
23
|
-
export { PluginOptions, ResolvedPluginOptions, _default as default };
|
|
23
|
+
export { PluginOptions, ResolvedPluginOptions, ScanOptions, _default as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikacss/unplugin-pikacss",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.59",
|
|
5
5
|
"author": "DevilTea <ch19980814@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://pikacss.github.io",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"pathe": "^2.0.3",
|
|
95
95
|
"perfect-debounce": "^2.1.0",
|
|
96
96
|
"unplugin": "^3.3.0",
|
|
97
|
-
"@pikacss/integration": "0.0.
|
|
97
|
+
"@pikacss/integration": "0.0.59"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"esbuild": "^0.28.1",
|