@vizejs/unplugin 0.33.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.
@@ -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 };
@@ -0,0 +1,5 @@
1
+ import { t as vizeUnplugin } from "./unplugin-DYS6RgJy.mjs";
2
+ //#region src/esbuild.ts
3
+ var esbuild_default = vizeUnplugin.esbuild;
4
+ //#endregion
5
+ export { esbuild_default as default };
@@ -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,2 @@
1
+ import { t as vizeUnplugin } from "./unplugin-DYS6RgJy.mjs";
2
+ export { vizeUnplugin as default, vizeUnplugin };
@@ -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 };
@@ -0,0 +1,5 @@
1
+ import { t as vizeUnplugin } from "./unplugin-DYS6RgJy.mjs";
2
+ //#region src/rollup.ts
3
+ var rollup_default = vizeUnplugin.rollup;
4
+ //#endregion
5
+ export { rollup_default as default };
@@ -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
- } //#endregion
13
- export { VizeUnpluginOptions };
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
- const useDelegatedStyles = hasDelegatedStyles(compiled) && filePath;
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
- const cssCode = JSON.stringify(compiled.css);
119
- const cssId = JSON.stringify(`vize-style-${compiled.scopeId}`);
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
- const hoistedContent = hoisted.length > 0 ? `${hoisted.join("\n")}\n\n` : "";
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$1, rawQuery = ""] = id.split("?", 2);
216
+ const [path, rawQuery = ""] = id.split("?", 2);
227
217
  const params = new URLSearchParams(rawQuery);
228
- const filename = params.get("vize-file") ?? path$1;
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: path$1,
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$1 = plugin.definitions;
310
- if (!definitions$1) continue;
311
- for (const key of Object.keys(definitions$1)) existingDefines.add(key);
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 generated = generateOutput(compiled, {
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 };
@@ -0,0 +1,6 @@
1
+ import { t as VizeUnpluginOptions } from "./types-B9p6RbVJ.mjs";
2
+
3
+ //#region src/webpack.d.ts
4
+ declare const _default: (options?: VizeUnpluginOptions | undefined) => undefined;
5
+ //#endregion
6
+ export { _default as default };
@@ -0,0 +1,5 @@
1
+ import { t as vizeUnplugin } from "./unplugin-DYS6RgJy.mjs";
2
+ //#region src/webpack.ts
3
+ var webpack_default = vizeUnplugin.webpack;
4
+ //#endregion
5
+ export { webpack_default as default };
package/package.json CHANGED
@@ -1,10 +1,27 @@
1
1
  {
2
2
  "name": "@vizejs/unplugin",
3
- "version": "0.33.0",
3
+ "version": "0.34.0",
4
4
  "description": "Experimental unplugin-based Vue SFC integration for rollup, webpack, and esbuild powered by Vize",
5
- "publishConfig": {
6
- "access": "public"
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
- "files": [
34
- "dist"
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.33.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": "tsdown",
70
- "dev": "tsdown --watch",
71
- "lint": "oxlint --deny-warnings --type-aware --tsconfig tsconfig.json",
72
- "lint:fix": "oxlint --type-aware --tsconfig tsconfig.json --fix",
73
- "fmt": "oxfmt --write src tsdown.config.ts",
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 esbuild3 from "esbuild";
3
-
4
- //#region src/esbuild.d.ts
5
- declare const _default: (options?: VizeUnpluginOptions | undefined) => esbuild3.Plugin;
6
-
7
- //#endregion
8
- export { _default as default };
package/dist/esbuild.js DELETED
@@ -1,7 +0,0 @@
1
- import { vizeUnplugin } from "./unplugin-uEvVDDGd.js";
2
-
3
- //#region src/esbuild.ts
4
- var esbuild_default = vizeUnplugin.esbuild;
5
-
6
- //#endregion
7
- export { esbuild_default as default };
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
@@ -1,3 +0,0 @@
1
- import { vizeUnplugin } from "./unplugin-uEvVDDGd.js";
2
-
3
- export { vizeUnplugin as default, vizeUnplugin };
package/dist/rollup.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { VizeUnpluginOptions } from "./types-K4_NiprT.js";
2
- import * as rollup5 from "rollup";
3
- import * as rollup6 from "rollup";
4
-
5
- //#region src/rollup.d.ts
6
- declare const _default: (options?: VizeUnpluginOptions | undefined) => rollup5.Plugin<any> | rollup6.Plugin<any>[];
7
-
8
- //#endregion
9
- export { _default as default };
package/dist/rollup.js DELETED
@@ -1,7 +0,0 @@
1
- import { vizeUnplugin } from "./unplugin-uEvVDDGd.js";
2
-
3
- //#region src/rollup.ts
4
- var rollup_default = vizeUnplugin.rollup;
5
-
6
- //#endregion
7
- export { rollup_default as default };
package/dist/webpack.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { VizeUnpluginOptions } from "./types-K4_NiprT.js";
2
- import * as webpack1 from "webpack";
3
-
4
- //#region src/webpack.d.ts
5
- declare const _default: (options?: VizeUnpluginOptions | undefined) => webpack1.WebpackPluginInstance;
6
-
7
- //#endregion
8
- export { _default as default };
package/dist/webpack.js DELETED
@@ -1,7 +0,0 @@
1
- import { vizeUnplugin } from "./unplugin-uEvVDDGd.js";
2
-
3
- //#region src/webpack.ts
4
- var webpack_default = vizeUnplugin.webpack;
5
-
6
- //#endregion
7
- export { webpack_default as default };