@vizejs/unplugin 0.32.0 → 0.34.0
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 +7 -0
- package/dist/esbuild.mjs +5 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +2 -0
- package/dist/rollup.d.mts +7 -0
- package/dist/rollup.mjs +5 -0
- package/dist/{types-K4_NiprT.d.ts → types-B9p6RbVJ.d.mts} +3 -3
- package/dist/{unplugin-uEvVDDGd.js → unplugin-DYS6RgJy.mjs} +25 -40
- package/dist/webpack.d.mts +6 -0
- package/dist/webpack.mjs +5 -0
- package/package.json +29 -30
- package/dist/esbuild.d.ts +0 -8
- package/dist/esbuild.js +0 -7
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -3
- package/dist/rollup.d.ts +0 -9
- package/dist/rollup.js +0 -7
- package/dist/webpack.d.ts +0 -8
- package/dist/webpack.js +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { t as VizeUnpluginOptions } from "./types-B9p6RbVJ.mjs";
|
|
2
|
+
import * as unplugin from "unplugin";
|
|
3
|
+
|
|
4
|
+
//#region src/esbuild.d.ts
|
|
5
|
+
declare const _default: (options?: VizeUnpluginOptions | undefined) => unplugin.EsbuildPlugin;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { _default as default };
|
package/dist/esbuild.mjs
ADDED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { t as VizeUnpluginOptions } from "./types-B9p6RbVJ.mjs";
|
|
2
|
+
import * as unplugin from "unplugin";
|
|
3
|
+
|
|
4
|
+
//#region src/unplugin.d.ts
|
|
5
|
+
declare const vizeUnplugin: unplugin.UnpluginInstance<VizeUnpluginOptions | undefined, boolean>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { type VizeUnpluginOptions, vizeUnplugin as default, vizeUnplugin };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { t as VizeUnpluginOptions } from "./types-B9p6RbVJ.mjs";
|
|
2
|
+
import * as unplugin from "unplugin";
|
|
3
|
+
|
|
4
|
+
//#region src/rollup.d.ts
|
|
5
|
+
declare const _default: (options?: VizeUnpluginOptions | undefined) => unplugin.RollupPlugin<any> | unplugin.RollupPlugin<any>[];
|
|
6
|
+
//#endregion
|
|
7
|
+
export { _default as default };
|
package/dist/rollup.mjs
ADDED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
|
-
|
|
3
2
|
interface VizeUnpluginOptions {
|
|
4
3
|
include?: string | RegExp | Array<string | RegExp>;
|
|
5
4
|
exclude?: string | RegExp | Array<string | RegExp>;
|
|
@@ -9,5 +8,6 @@ interface VizeUnpluginOptions {
|
|
|
9
8
|
vapor?: boolean;
|
|
10
9
|
root?: string;
|
|
11
10
|
debug?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { VizeUnpluginOptions as t };
|
|
@@ -4,7 +4,6 @@ import { createHash } from "node:crypto";
|
|
|
4
4
|
import * as native from "@vizejs/native";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { transform } from "oxc-transform";
|
|
7
|
-
|
|
8
7
|
//#region src/filter.ts
|
|
9
8
|
function createFilter(include, exclude) {
|
|
10
9
|
const includePatterns = include ? Array.isArray(include) ? include : [include] : [/\.vue$/];
|
|
@@ -15,7 +14,6 @@ function createFilter(include, exclude) {
|
|
|
15
14
|
return matchInclude && !matchExclude;
|
|
16
15
|
};
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
//#endregion
|
|
20
18
|
//#region src/style.ts
|
|
21
19
|
const PREPROCESSOR_LANGS = new Set([
|
|
@@ -85,8 +83,7 @@ function generateOutput(compiled, options) {
|
|
|
85
83
|
output += "\n_sfc_main.render = render;";
|
|
86
84
|
output += "\nexport default _sfc_main;";
|
|
87
85
|
}
|
|
88
|
-
|
|
89
|
-
if (useDelegatedStyles) {
|
|
86
|
+
if (hasDelegatedStyles(compiled) && filePath) {
|
|
90
87
|
const styleImports = [];
|
|
91
88
|
const cssModuleImports = [];
|
|
92
89
|
for (const block of compiled.styles) {
|
|
@@ -114,12 +111,9 @@ function generateOutput(compiled, options) {
|
|
|
114
111
|
}).join("\n");
|
|
115
112
|
output = output.replace(/^export default _sfc_main;/m, `${cssModuleSetup}\nexport default _sfc_main;`);
|
|
116
113
|
}
|
|
117
|
-
} else if (compiled.css && !(isProduction && extractCss))
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
output = `
|
|
121
|
-
export const __vize_css__ = ${cssCode};
|
|
122
|
-
const __vize_css_id__ = ${cssId};
|
|
114
|
+
} else if (compiled.css && !(isProduction && extractCss)) output = `
|
|
115
|
+
export const __vize_css__ = ${JSON.stringify(compiled.css)};
|
|
116
|
+
const __vize_css_id__ = ${JSON.stringify(`vize-style-${compiled.scopeId}`)};
|
|
123
117
|
(function() {
|
|
124
118
|
if (typeof document !== "undefined") {
|
|
125
119
|
let style = document.getElementById(__vize_css_id__);
|
|
@@ -134,7 +128,6 @@ const __vize_css_id__ = ${cssId};
|
|
|
134
128
|
}
|
|
135
129
|
})();
|
|
136
130
|
${output}`;
|
|
137
|
-
}
|
|
138
131
|
if (!isProduction && isDev && hasExportDefault && supportsTemplateOnlyHmr(output)) output += "";
|
|
139
132
|
return output;
|
|
140
133
|
}
|
|
@@ -151,10 +144,8 @@ function wrapScopedPreprocessorStyle(content, scoped, lang) {
|
|
|
151
144
|
}
|
|
152
145
|
body.push(line);
|
|
153
146
|
}
|
|
154
|
-
|
|
155
|
-
return `${hoistedContent}[${scoped}] {\n${body.join("\n")}\n}`;
|
|
147
|
+
return `${hoisted.length > 0 ? `${hoisted.join("\n")}\n\n` : ""}[${scoped}] {\n${body.join("\n")}\n}`;
|
|
156
148
|
}
|
|
157
|
-
|
|
158
149
|
//#endregion
|
|
159
150
|
//#region src/compiler.ts
|
|
160
151
|
const { compileSfc } = native;
|
|
@@ -208,7 +199,6 @@ function compileVueModule(filePath, source, options, cache) {
|
|
|
208
199
|
warnings: result.warnings
|
|
209
200
|
};
|
|
210
201
|
}
|
|
211
|
-
|
|
212
202
|
//#endregion
|
|
213
203
|
//#region src/request.ts
|
|
214
204
|
const STYLE_MARKER = ".__vize_style_";
|
|
@@ -223,24 +213,23 @@ function isVirtualStyleId(id) {
|
|
|
223
213
|
return id.includes(STYLE_MARKER);
|
|
224
214
|
}
|
|
225
215
|
function parseVueRequest(id) {
|
|
226
|
-
const [path
|
|
216
|
+
const [path, rawQuery = ""] = id.split("?", 2);
|
|
227
217
|
const params = new URLSearchParams(rawQuery);
|
|
228
|
-
const filename = params.get("vize-file") ?? path
|
|
218
|
+
const filename = params.get("vize-file") ?? path;
|
|
229
219
|
const moduleValue = params.has("module") ? params.get("module") || true : false;
|
|
230
220
|
const indexValue = params.get("index");
|
|
231
|
-
const query = {
|
|
232
|
-
vue: params.has("vue"),
|
|
233
|
-
type: params.get("type"),
|
|
234
|
-
index: indexValue === null ? null : Number.parseInt(indexValue, 10),
|
|
235
|
-
lang: params.get("lang"),
|
|
236
|
-
module: moduleValue,
|
|
237
|
-
scoped: params.get("scoped"),
|
|
238
|
-
vizeFile: params.get("vize-file")
|
|
239
|
-
};
|
|
240
221
|
return {
|
|
241
222
|
filename,
|
|
242
|
-
path
|
|
243
|
-
query
|
|
223
|
+
path,
|
|
224
|
+
query: {
|
|
225
|
+
vue: params.has("vue"),
|
|
226
|
+
type: params.get("type"),
|
|
227
|
+
index: indexValue === null ? null : Number.parseInt(indexValue, 10),
|
|
228
|
+
lang: params.get("lang"),
|
|
229
|
+
module: moduleValue,
|
|
230
|
+
scoped: params.get("scoped"),
|
|
231
|
+
vizeFile: params.get("vize-file")
|
|
232
|
+
}
|
|
244
233
|
};
|
|
245
234
|
}
|
|
246
235
|
function createVirtualStyleId(id) {
|
|
@@ -258,7 +247,6 @@ function createVirtualStyleId(id) {
|
|
|
258
247
|
if (query.module !== false) params.set("module", typeof query.module === "string" ? query.module : "");
|
|
259
248
|
return `${filename}${STYLE_MARKER}${index}${suffix}?${params.toString()}`;
|
|
260
249
|
}
|
|
261
|
-
|
|
262
250
|
//#endregion
|
|
263
251
|
//#region src/strip-types.ts
|
|
264
252
|
function formatErrorMessage(error) {
|
|
@@ -279,7 +267,6 @@ async function stripTypeScript(filePath, code, sourceMap) {
|
|
|
279
267
|
map: result.map ?? null
|
|
280
268
|
};
|
|
281
269
|
}
|
|
282
|
-
|
|
283
270
|
//#endregion
|
|
284
271
|
//#region src/unplugin.ts
|
|
285
272
|
function normalizeOptions(rawOptions = {}) {
|
|
@@ -304,11 +291,11 @@ function createVueDefineMap(isProduction) {
|
|
|
304
291
|
}
|
|
305
292
|
function injectWebpackVueDefines(compiler, isProduction) {
|
|
306
293
|
const { DefinePlugin } = compiler.webpack;
|
|
307
|
-
const existingDefines = new Set();
|
|
294
|
+
const existingDefines = /* @__PURE__ */ new Set();
|
|
308
295
|
for (const plugin of compiler.options.plugins ?? []) {
|
|
309
|
-
const definitions
|
|
310
|
-
if (!definitions
|
|
311
|
-
for (const key of Object.keys(definitions
|
|
296
|
+
const definitions = plugin.definitions;
|
|
297
|
+
if (!definitions) continue;
|
|
298
|
+
for (const key of Object.keys(definitions)) existingDefines.add(key);
|
|
312
299
|
}
|
|
313
300
|
const definitions = createVueDefineMap(isProduction);
|
|
314
301
|
const missingDefinitions = {};
|
|
@@ -331,7 +318,7 @@ async function loadStyleBlock(id, options, cache) {
|
|
|
331
318
|
const vizeUnplugin = createUnplugin((rawOptions = {}) => {
|
|
332
319
|
const options = normalizeOptions(rawOptions);
|
|
333
320
|
const filter = createFilter(options.include, options.exclude);
|
|
334
|
-
const cache = new Map();
|
|
321
|
+
const cache = /* @__PURE__ */ new Map();
|
|
335
322
|
return {
|
|
336
323
|
name: "unplugin-vize",
|
|
337
324
|
resolveId(id) {
|
|
@@ -356,12 +343,11 @@ const vizeUnplugin = createUnplugin((rawOptions = {}) => {
|
|
|
356
343
|
if (!isVueFile(id) || !filter(id)) return null;
|
|
357
344
|
const { compiled, warnings } = compileVueModule(id, code, options, cache);
|
|
358
345
|
for (const warning of warnings) this.warn(`[vize] ${warning}`);
|
|
359
|
-
const
|
|
346
|
+
const transformed = await stripTypeScript(id, generateOutput(compiled, {
|
|
360
347
|
isProduction: options.isProduction,
|
|
361
348
|
isDev: false,
|
|
362
349
|
filePath: id
|
|
363
|
-
});
|
|
364
|
-
const transformed = await stripTypeScript(id, generated, options.sourceMap);
|
|
350
|
+
}), options.sourceMap);
|
|
365
351
|
return {
|
|
366
352
|
code: transformed.code,
|
|
367
353
|
map: transformed.map
|
|
@@ -390,6 +376,5 @@ const vizeUnplugin = createUnplugin((rawOptions = {}) => {
|
|
|
390
376
|
}
|
|
391
377
|
};
|
|
392
378
|
});
|
|
393
|
-
|
|
394
379
|
//#endregion
|
|
395
|
-
export { vizeUnplugin };
|
|
380
|
+
export { vizeUnplugin as t };
|
package/dist/webpack.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/unplugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "Experimental unplugin-based Vue SFC integration for rollup, webpack, and esbuild powered by Vize",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"compiler",
|
|
7
|
+
"esbuild",
|
|
8
|
+
"fast",
|
|
9
|
+
"native",
|
|
10
|
+
"plugin",
|
|
11
|
+
"rollup",
|
|
12
|
+
"unplugin",
|
|
13
|
+
"vue",
|
|
14
|
+
"webpack"
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/ubugeeei/vize",
|
|
20
|
+
"directory": "npm/unplugin-vize"
|
|
7
21
|
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
8
25
|
"type": "module",
|
|
9
26
|
"main": "./dist/index.js",
|
|
10
27
|
"types": "./dist/index.d.ts",
|
|
@@ -30,48 +47,30 @@
|
|
|
30
47
|
"default": "./dist/webpack.js"
|
|
31
48
|
}
|
|
32
49
|
},
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
],
|
|
36
|
-
"keywords": [
|
|
37
|
-
"unplugin",
|
|
38
|
-
"rollup",
|
|
39
|
-
"webpack",
|
|
40
|
-
"esbuild",
|
|
41
|
-
"vue",
|
|
42
|
-
"plugin",
|
|
43
|
-
"compiler",
|
|
44
|
-
"native",
|
|
45
|
-
"fast"
|
|
46
|
-
],
|
|
47
|
-
"repository": {
|
|
48
|
-
"type": "git",
|
|
49
|
-
"url": "https://github.com/ubugeeei/vize",
|
|
50
|
-
"directory": "npm/unplugin-vize"
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
51
52
|
},
|
|
52
|
-
"license": "MIT",
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"oxc-transform": "^0.116.0",
|
|
55
55
|
"unplugin": "^3.0.0",
|
|
56
|
-
"@vizejs/native": "0.
|
|
56
|
+
"@vizejs/native": "0.34.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/node": "^22.0.0",
|
|
60
60
|
"esbuild": "^0.25.11",
|
|
61
61
|
"rollup": "^4.52.4",
|
|
62
|
-
"tsdown": "^0.9.0",
|
|
63
62
|
"tsx": "^4.21.0",
|
|
64
63
|
"typescript": "~5.6.0",
|
|
64
|
+
"vite-plus": "latest",
|
|
65
65
|
"vue": "3.6.0-beta.1",
|
|
66
66
|
"webpack": "^5.101.3"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
|
-
"build": "
|
|
70
|
-
"dev": "
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"fmt": "
|
|
74
|
-
"fmt:check": "oxfmt src tsdown.config.ts",
|
|
69
|
+
"build": "vp pack",
|
|
70
|
+
"dev": "vp pack --watch",
|
|
71
|
+
"check": "vp check src vite.config.ts",
|
|
72
|
+
"check:fix": "vp check --fix src vite.config.ts",
|
|
73
|
+
"fmt": "vp fmt --write src vite.config.ts",
|
|
75
74
|
"test": "node --import tsx --test src/*.test.ts src/**/*.test.ts",
|
|
76
75
|
"test:update": "node --import tsx --test --test-update-snapshots src/*.test.ts src/**/*.test.ts"
|
|
77
76
|
}
|
package/dist/esbuild.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { VizeUnpluginOptions } from "./types-K4_NiprT.js";
|
|
2
|
-
import * as esbuild1 from "esbuild";
|
|
3
|
-
|
|
4
|
-
//#region src/esbuild.d.ts
|
|
5
|
-
declare const _default: (options?: VizeUnpluginOptions | undefined) => esbuild1.Plugin;
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
export { _default as default };
|
package/dist/esbuild.js
DELETED
package/dist/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { VizeUnpluginOptions } from "./types-K4_NiprT.js";
|
|
2
|
-
import * as unplugin7 from "unplugin";
|
|
3
|
-
|
|
4
|
-
//#region src/unplugin.d.ts
|
|
5
|
-
declare const vizeUnplugin: unplugin7.UnpluginInstance<VizeUnpluginOptions | undefined, boolean>;
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
export { VizeUnpluginOptions, vizeUnplugin as default, vizeUnplugin };
|
package/dist/index.js
DELETED
package/dist/rollup.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { VizeUnpluginOptions } from "./types-K4_NiprT.js";
|
|
2
|
-
import * as rollup3 from "rollup";
|
|
3
|
-
import * as rollup4 from "rollup";
|
|
4
|
-
|
|
5
|
-
//#region src/rollup.d.ts
|
|
6
|
-
declare const _default: (options?: VizeUnpluginOptions | undefined) => rollup3.Plugin<any> | rollup4.Plugin<any>[];
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { _default as default };
|
package/dist/rollup.js
DELETED
package/dist/webpack.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { VizeUnpluginOptions } from "./types-K4_NiprT.js";
|
|
2
|
-
import * as webpack6 from "webpack";
|
|
3
|
-
|
|
4
|
-
//#region src/webpack.d.ts
|
|
5
|
-
declare const _default: (options?: VizeUnpluginOptions | undefined) => webpack6.WebpackPluginInstance;
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
export { _default as default };
|