@pikacss/unplugin-pikacss 0.0.54 → 0.0.56
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/esbuild.d.mts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +22 -18
- package/dist/rolldown.d.mts +1 -1
- package/dist/rollup.d.mts +1 -1
- package/dist/rspack.d.mts +1 -1
- package/dist/{types-CooOKDFP.d.mts → types-ekE7tO8H.d.mts} +14 -23
- package/dist/vite.d.mts +1 -1
- package/dist/webpack.d.mts +1 -1
- package/package.json +2 -2
package/dist/esbuild.d.mts
CHANGED
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, t as PluginOptions } from "./types-ekE7tO8H.mjs";
|
|
2
2
|
import * as _$unplugin from "unplugin";
|
|
3
3
|
import { UnpluginFactory } from "unplugin";
|
|
4
4
|
export * from "@pikacss/integration";
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import {
|
|
3
|
+
import { createCtx, log } from "@pikacss/integration";
|
|
4
4
|
import { resolve } from "pathe";
|
|
5
5
|
import { debounce } from "perfect-debounce";
|
|
6
6
|
import { createUnplugin } from "unplugin";
|
|
@@ -32,26 +32,25 @@ const PLUGIN_NAME = "unplugin-pikacss";
|
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
34
|
const unpluginFactory = (options, meta) => {
|
|
35
|
-
const { cwd: userCwd, currentPackageName = "@pikacss/unplugin-pikacss", config: configOrPath, tsCodegen = true, cssCodegen = true, scan = {}, fnName = "pika",
|
|
35
|
+
const { cwd: userCwd, currentPackageName = "@pikacss/unplugin-pikacss", config: configOrPath, tsCodegen = true, cssCodegen = true, scan = {}, fnName = "pika", transformedFormat = "string", autoCreateConfig = false } = options ?? {};
|
|
36
36
|
log.debug("Creating unplugin factory with options:", options);
|
|
37
|
-
const defaultInclude = [`**/*.{${[
|
|
38
|
-
"js",
|
|
39
|
-
"ts",
|
|
40
|
-
"jsx",
|
|
41
|
-
"tsx",
|
|
42
|
-
...normalizeMarkupExtensions([...DEFAULT_MARKUP_EXTENSIONS, ...markupExtensions ?? []])
|
|
43
|
-
].join(",")}}`];
|
|
44
37
|
const resolvedOptions = {
|
|
45
38
|
currentPackageName,
|
|
46
39
|
configOrPath,
|
|
47
40
|
tsCodegen: tsCodegen === true ? "pika.gen.ts" : tsCodegen,
|
|
48
41
|
cssCodegen: cssCodegen === true ? "pika.gen.css" : cssCodegen,
|
|
49
42
|
scan: {
|
|
50
|
-
include: typeof scan?.include === "string" ? [scan.include] : scan?.include ||
|
|
51
|
-
exclude: typeof scan?.exclude === "string" ? [scan.exclude] : scan?.exclude || [
|
|
43
|
+
include: typeof scan?.include === "string" ? [scan.include] : scan?.include || ["**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,vue}"],
|
|
44
|
+
exclude: typeof scan?.exclude === "string" ? [scan.exclude] : scan?.exclude || [
|
|
45
|
+
"node_modules/**",
|
|
46
|
+
"dist/**",
|
|
47
|
+
".git/**",
|
|
48
|
+
".nuxt/**",
|
|
49
|
+
".output/**",
|
|
50
|
+
"coverage/**"
|
|
51
|
+
]
|
|
52
52
|
},
|
|
53
53
|
fnName,
|
|
54
|
-
markupExtensions,
|
|
55
54
|
transformedFormat,
|
|
56
55
|
autoCreateConfig
|
|
57
56
|
};
|
|
@@ -66,6 +65,7 @@ const unpluginFactory = (options, meta) => {
|
|
|
66
65
|
function applyRuntimeContext(nextCwd, nextMode) {
|
|
67
66
|
if (userCwd == null) ctx.cwd = resolve(nextCwd);
|
|
68
67
|
mode = nextMode;
|
|
68
|
+
ctx.configErrorBehavior = nextMode === "build" ? "throw" : "retain-last-good";
|
|
69
69
|
}
|
|
70
70
|
const debouncedWriteCssCodegenFile = debounce(async () => {
|
|
71
71
|
await ctx.writeCssCodegenFile();
|
|
@@ -166,6 +166,7 @@ const unpluginFactory = (options, meta) => {
|
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
}).catch((error) => {
|
|
169
|
+
if (mode === "build") throw error;
|
|
169
170
|
log.error(`Failed to setup integration context: ${error?.message ?? error}`, error);
|
|
170
171
|
});
|
|
171
172
|
return setupPromise;
|
|
@@ -207,6 +208,7 @@ const unpluginFactory = (options, meta) => {
|
|
|
207
208
|
async buildStart() {
|
|
208
209
|
log.debug("Plugin buildStart hook triggered");
|
|
209
210
|
log.debug(`Current mode: ${mode}, cwd: ${ctx.cwd}`);
|
|
211
|
+
ctx.configErrorBehavior = mode === "build" ? "throw" : "retain-last-good";
|
|
210
212
|
await ensureSetup();
|
|
211
213
|
if (mode === "build") {
|
|
212
214
|
log.debug("Running full CSS code generation in build mode");
|
|
@@ -248,13 +250,15 @@ const unpluginFactory = (options, meta) => {
|
|
|
248
250
|
}
|
|
249
251
|
}
|
|
250
252
|
},
|
|
253
|
+
async buildEnd() {
|
|
254
|
+
if (mode !== "build") return;
|
|
255
|
+
await ctx.waitForIdle();
|
|
256
|
+
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?`);
|
|
257
|
+
},
|
|
251
258
|
watchChange(id, change) {
|
|
252
|
-
if (change?.event === "delete"
|
|
253
|
-
log.debug(`Source file deleted, dropping its
|
|
254
|
-
ctx.
|
|
255
|
-
ctx.previewUsages.delete(id);
|
|
256
|
-
queueCssWrite();
|
|
257
|
-
queueTsWrite();
|
|
259
|
+
if (change?.event === "delete") {
|
|
260
|
+
log.debug(`Source file deleted, dropping its state: ${id}`);
|
|
261
|
+
ctx.dropModule(id);
|
|
258
262
|
}
|
|
259
263
|
if (id === ctx.resolvedConfigPath) {
|
|
260
264
|
let currentContent = null;
|
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, t as PluginOptions } from "./types-ekE7tO8H.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
|
package/dist/rollup.d.mts
CHANGED
package/dist/rspack.d.mts
CHANGED
|
@@ -37,20 +37,21 @@ interface PluginOptions {
|
|
|
37
37
|
/**
|
|
38
38
|
* Glob patterns controlling which source files are scanned for `pika()` calls.
|
|
39
39
|
*
|
|
40
|
-
* @default `{ include: ['**\/*.{js,
|
|
40
|
+
* @default `{ include: ['**\/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,vue}'], exclude: ['node_modules/**', 'dist/**', '.git/**', '.nuxt/**', '.output/**', 'coverage/**'] }`
|
|
41
41
|
*/
|
|
42
42
|
scan?: {
|
|
43
43
|
/**
|
|
44
44
|
* File glob patterns to scan. Supports a single string or array of strings.
|
|
45
|
-
* When omitted, the default covers
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @default ['**\/*.{js,ts,jsx,tsx,vue,svelte,astro,html,htm}']
|
|
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}']
|
|
49
48
|
*/
|
|
50
49
|
include?: string | string[];
|
|
51
50
|
/**
|
|
52
51
|
* File glob patterns to exclude. Supports a single string or array of strings.
|
|
53
|
-
*
|
|
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/**']
|
|
54
55
|
*/
|
|
55
56
|
exclude?: string | string[];
|
|
56
57
|
};
|
|
@@ -64,7 +65,12 @@ interface PluginOptions {
|
|
|
64
65
|
/**
|
|
65
66
|
* When `true`, automatically scaffolds a default `pika.config.js` file if no existing config is found.
|
|
66
67
|
*
|
|
67
|
-
* @
|
|
68
|
+
* @remarks
|
|
69
|
+
* Defaults to `false`: a build plugin should not silently write files into the
|
|
70
|
+
* user's repository (a footgun in read-only CI, containers, and installed
|
|
71
|
+
* packages). Scaffold a config explicitly (or opt back in with `true`).
|
|
72
|
+
*
|
|
73
|
+
* @default `false`
|
|
68
74
|
*/
|
|
69
75
|
autoCreateConfig?: boolean;
|
|
70
76
|
/**
|
|
@@ -74,19 +80,6 @@ interface PluginOptions {
|
|
|
74
80
|
* @default `'pika'`
|
|
75
81
|
*/
|
|
76
82
|
fnName?: string;
|
|
77
|
-
/**
|
|
78
|
-
* Additional file extensions (leading dots optional) whose sources are scanned in markup
|
|
79
|
-
* mode. Markup files' top-level syntax is not JavaScript — `pika()` calls live inside
|
|
80
|
-
* quoted template attributes (e.g., `:class="pika({...})"` in Vue SFCs) — so string and
|
|
81
|
-
* comment detection works differently there. Extensions listed here are merged with the
|
|
82
|
-
* built-in defaults `['vue', 'svelte', 'astro', 'html', 'htm']`; pass `['riot']` to also
|
|
83
|
-
* scan `.riot` files in markup mode. When `scan.include` is not set, the default include
|
|
84
|
-
* glob is extended with these extensions too, so the files are actually selected for
|
|
85
|
-
* scanning without further configuration.
|
|
86
|
-
*
|
|
87
|
-
* @default `undefined` (built-in defaults only)
|
|
88
|
-
*/
|
|
89
|
-
markupExtensions?: string[];
|
|
90
83
|
/**
|
|
91
84
|
* Default output format for normal `pika()` calls. `'string'` produces a space-joined class string;
|
|
92
85
|
* `'array'` produces a string array of class names.
|
|
@@ -110,7 +103,7 @@ interface PluginOptions {
|
|
|
110
103
|
cssCodegen?: true | string;
|
|
111
104
|
/**
|
|
112
105
|
* npm package name of the plugin consumer, embedded in generated file headers and import paths.
|
|
113
|
-
* Override when wrapping the unplugin in a framework-specific package (e.g., `@pikacss/nuxt`).
|
|
106
|
+
* Override when wrapping the unplugin in a framework-specific package (e.g., `@pikacss/nuxt-pikacss`).
|
|
114
107
|
*
|
|
115
108
|
* @default `'@pikacss/unplugin-pikacss'`
|
|
116
109
|
*/
|
|
@@ -137,8 +130,6 @@ interface ResolvedPluginOptions {
|
|
|
137
130
|
scan: IntegrationContextOptions['scan'];
|
|
138
131
|
/** Base function name to recognize in source transforms (e.g., `'pika'`). */
|
|
139
132
|
fnName: string;
|
|
140
|
-
/** Additional file extensions scanned in markup mode, merged with the integration defaults. */
|
|
141
|
-
markupExtensions?: string[];
|
|
142
133
|
/** Default output format for normal `pika()` calls: `'string'` or `'array'`. */
|
|
143
134
|
transformedFormat: 'string' | 'array';
|
|
144
135
|
/** Whether to scaffold a default config file when none is found. */
|
package/dist/vite.d.mts
CHANGED
package/dist/webpack.d.mts
CHANGED
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.56",
|
|
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.56"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"esbuild": "^0.28.1",
|