unplugin-vue-components 28.8.0 → 29.1.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.
Files changed (51) hide show
  1. package/README.md +62 -1
  2. package/dist/esbuild.cjs +2 -2
  3. package/dist/esbuild.d.cts +4 -5
  4. package/dist/esbuild.d.ts +3 -3
  5. package/dist/esbuild.js +3 -3
  6. package/dist/index.cjs +2 -2
  7. package/dist/index.d.cts +3 -3
  8. package/dist/index.d.ts +3 -3
  9. package/dist/index.js +3 -3
  10. package/dist/nuxt.cjs +4 -3
  11. package/dist/nuxt.d.cts +4 -5
  12. package/dist/nuxt.d.ts +3 -3
  13. package/dist/nuxt.js +3 -3
  14. package/dist/resolvers.cjs +31 -27
  15. package/dist/resolvers.d.cts +1 -1
  16. package/dist/resolvers.d.ts +1 -1
  17. package/dist/resolvers.js +19 -21
  18. package/dist/rolldown.cjs +9 -0
  19. package/dist/rolldown.d.cts +6 -0
  20. package/dist/rolldown.d.ts +7 -0
  21. package/dist/rolldown.js +9 -0
  22. package/dist/rollup.cjs +2 -2
  23. package/dist/rollup.d.cts +4 -5
  24. package/dist/rollup.d.ts +3 -3
  25. package/dist/rollup.js +3 -3
  26. package/dist/rspack.cjs +2 -2
  27. package/dist/rspack.d.cts +2 -3
  28. package/dist/rspack.d.ts +1 -1
  29. package/dist/rspack.js +3 -3
  30. package/dist/{src-a29vieKX.js → src-BTwFq3T3.cjs} +3 -3
  31. package/dist/{src-B9aLSEVj.js → src-CbJqJu6O.js} +30 -38
  32. package/dist/{src-C_roJwTj.cjs → src-Ctx_G96r.cjs} +52 -51
  33. package/dist/{src-BslXt6ey.cjs → src-D2-JfLYq.js} +2 -4
  34. package/dist/{types-BED632qH.d.cts → types-BgF15syy.d.ts} +10 -1
  35. package/dist/types-DQoXDiso.js +1 -0
  36. package/dist/{types-CFwIfA2K.d.ts → types-dp3LCoF8.d.cts} +10 -1
  37. package/dist/types.d.cts +1 -1
  38. package/dist/types.d.ts +1 -1
  39. package/dist/types.js +3 -1
  40. package/dist/{utils-DuLwPrUJ.js → utils-BPB1pAS0.js} +33 -36
  41. package/dist/{utils-BIvt10am.cjs → utils-c-ZB7b5u.cjs} +44 -38
  42. package/dist/vite.cjs +2 -2
  43. package/dist/vite.d.cts +2 -3
  44. package/dist/vite.d.ts +1 -1
  45. package/dist/vite.js +3 -3
  46. package/dist/webpack.cjs +2 -2
  47. package/dist/webpack.d.cts +4 -5
  48. package/dist/webpack.d.ts +3 -3
  49. package/dist/webpack.js +3 -3
  50. package/package.json +42 -39
  51. package/dist/types-Cv8NMtbo.js +0 -0
@@ -1,4 +1,4 @@
1
- import { DIRECTIVE_IMPORT_PREFIX, DISABLE_COMMENT, getNameFromFilePath, getTransformedPath, isExclude, matchGlobs, normalizeComponentInfo, notNullish, parseId, pascalCase, resolveAlias, shouldTransform, slash, stringifyComponentImport, throttle, toArray } from "./utils-DuLwPrUJ.js";
1
+ import { DIRECTIVE_IMPORT_PREFIX, DISABLE_COMMENT, escapeSpecialChars, getNameFromFilePath, getTransformedPath, isExclude, matchGlobs, normalizeComponentInfo, notNullish, parseId, pascalCase, resolveAlias, shouldTransform, slash, stringifyComponentImport, throttle, toArray } from "./utils-BPB1pAS0.js";
2
2
  import { existsSync } from "node:fs";
3
3
  import process from "node:process";
4
4
  import chokidar from "chokidar";
@@ -54,13 +54,6 @@ function parseDeclaration(code) {
54
54
  if (directiveDeclaration) imports.directive = extractImports(directiveDeclaration);
55
55
  return imports;
56
56
  }
57
- function addComponentPrefix(component, prefix) {
58
- if (!component.as || !prefix) return component;
59
- return {
60
- ...component,
61
- as: `${prefix}${component.as}`
62
- };
63
- }
64
57
  /**
65
58
  * Converts `ComponentInfo` to an array
66
59
  *
@@ -82,12 +75,10 @@ function stringifyComponentsInfo(filepath, components, importPathTransform) {
82
75
  return Object.fromEntries(components.map((info) => stringifyComponentInfo(filepath, info, importPathTransform)).filter(notNullish));
83
76
  }
84
77
  function getDeclarationImports(ctx, filepath) {
85
- const prefixComponentNameMap = Object.values(ctx.componentNameMap).map((info) => addComponentPrefix(info, ctx.options.prefix));
86
- const component = stringifyComponentsInfo(filepath, [
87
- ...Object.values(ctx.componentCustomMap),
88
- ...prefixComponentNameMap,
89
- ...resolveTypeImports(ctx.options.types)
90
- ], ctx.options.importPathTransform);
78
+ const component = stringifyComponentsInfo(filepath, [...Object.values({
79
+ ...ctx.componentNameMap,
80
+ ...ctx.componentCustomMap
81
+ }), ...resolveTypeImports(ctx.options.types)], ctx.options.importPathTransform);
91
82
  const directive = stringifyComponentsInfo(filepath, Object.values(ctx.directiveCustomMap), ctx.options.importPathTransform);
92
83
  if (Object.keys(component).length + Object.keys(directive).length === 0) return;
93
84
  return {
@@ -193,6 +184,7 @@ const defaultOptions = {
193
184
  allowOverrides: false,
194
185
  sourcemap: true,
195
186
  dumpComponentsInfo: false,
187
+ syncMode: "default",
196
188
  prefix: ""
197
189
  };
198
190
  function normalizeResolvers(resolvers) {
@@ -223,7 +215,7 @@ function resolveOptions(options, root) {
223
215
  prefix = "!";
224
216
  i = i.slice(1);
225
217
  }
226
- return resolved.deep ? prefix + slash(join(i, `**/*.${extsGlob}`)) : prefix + slash(join(i, `*.${extsGlob}`));
218
+ return resolved.deep ? prefix + escapeSpecialChars(slash(join(i, `**/*.${extsGlob}`))) : prefix + escapeSpecialChars(slash(join(i, `*.${extsGlob}`)));
227
219
  });
228
220
  if (!resolved.extensions.length) throw new Error("[unplugin-vue-components] `extensions` option is required to search for components");
229
221
  }
@@ -245,8 +237,7 @@ function resolveOptions(options, root) {
245
237
  }
246
238
  function getVueVersion(root) {
247
239
  var _getPackageInfoSync;
248
- const raw = ((_getPackageInfoSync = getPackageInfoSync("vue", { paths: [join(root, "/")] })) === null || _getPackageInfoSync === void 0 ? void 0 : _getPackageInfoSync.version) || "3";
249
- const version = +raw.split(".").slice(0, 2).join(".");
240
+ const version = +(((_getPackageInfoSync = getPackageInfoSync("vue", { paths: [join(root, "/")] })) === null || _getPackageInfoSync === void 0 ? void 0 : _getPackageInfoSync.version) || "3").split(".").slice(0, 2).join(".");
250
241
  if (version === 2.7) return 2.7;
251
242
  else if (version < 2.7) return 2;
252
243
  return 3;
@@ -327,7 +318,7 @@ async function resolveVue2(code, s) {
327
318
  const { parse: parse$1 } = await importModule("@babel/parser");
328
319
  const { program } = parse$1(code, { sourceType: "module" });
329
320
  const nodes = [];
330
- const { walk } = await import("./src-a29vieKX.js");
321
+ const { walk } = await import("./src-D2-JfLYq.js");
331
322
  walk(program, { enter(node) {
332
323
  if (node.type === "CallExpression") nodes.push(node);
333
324
  } });
@@ -438,11 +429,12 @@ const debug = {
438
429
  var Context = class {
439
430
  options;
440
431
  transformer = void 0;
441
- _componentPaths = new Set();
432
+ _componentPaths = /* @__PURE__ */ new Set();
442
433
  _componentNameMap = {};
443
434
  _componentUsageMap = {};
444
435
  _componentCustomMap = {};
445
436
  _directiveCustomMap = {};
437
+ _removeUnused = false;
446
438
  _server;
447
439
  root = process.cwd();
448
440
  sourcemap = true;
@@ -453,9 +445,9 @@ var Context = class {
453
445
  this.options = resolveOptions(rawOptions, this.root);
454
446
  this.sourcemap = rawOptions.sourcemap ?? true;
455
447
  this.generateDeclaration = throttle(500, this._generateDeclaration.bind(this), { noLeading: false });
448
+ this._removeUnused = this.options.syncMode === "overwrite";
456
449
  if (this.options.dumpComponentsInfo) {
457
- const dumpComponentsInfo = this.options.dumpComponentsInfo === true ? "./.components-info.json" : this.options.dumpComponentsInfo ?? false;
458
- this.dumpComponentsInfoPath = dumpComponentsInfo;
450
+ this.dumpComponentsInfoPath = this.options.dumpComponentsInfo === true ? "./.components-info.json" : this.options.dumpComponentsInfo ?? false;
459
451
  this.generateComponentsJson = throttle(500, this._generateComponentsJson.bind(this), { noLeading: false });
460
452
  }
461
453
  this.setTransformer(this.options.transformer);
@@ -477,6 +469,7 @@ var Context = class {
477
469
  setupViteServer(server) {
478
470
  if (this._server === server) return;
479
471
  this._server = server;
472
+ this._removeUnused = this.options.syncMode !== "append";
480
473
  this.setupWatcher(server.watcher);
481
474
  }
482
475
  setupWatcher(watcher) {
@@ -518,7 +511,7 @@ var Context = class {
518
511
  * @param paths paths of used components
519
512
  */
520
513
  updateUsageMap(path, paths) {
521
- if (!this._componentUsageMap[path]) this._componentUsageMap[path] = new Set();
514
+ if (!this._componentUsageMap[path]) this._componentUsageMap[path] = /* @__PURE__ */ new Set();
522
515
  paths.forEach((p) => {
523
516
  this._componentUsageMap[path].add(p);
524
517
  });
@@ -557,7 +550,7 @@ var Context = class {
557
550
  type: "update",
558
551
  updates: []
559
552
  };
560
- const timestamp = +new Date();
553
+ const timestamp = +/* @__PURE__ */ new Date();
561
554
  const name = pascalCase(getNameFromFilePath(path, this.options));
562
555
  Object.entries(this._componentUsageMap).forEach(([key, values]) => {
563
556
  if (values.has(name)) {
@@ -575,7 +568,8 @@ var Context = class {
575
568
  updateComponentNameMap() {
576
569
  this._componentNameMap = {};
577
570
  Array.from(this._componentPaths).forEach((path) => {
578
- const name = pascalCase(getNameFromFilePath(path, this.options));
571
+ const fileName = getNameFromFilePath(path, this.options);
572
+ const name = this.options.prefix ? `${pascalCase(this.options.prefix)}${pascalCase(fileName)}` : pascalCase(fileName);
579
573
  if (isExclude(name, this.options.excludeNames)) {
580
574
  debug.components("exclude", name);
581
575
  return;
@@ -609,7 +603,6 @@ var Context = class {
609
603
  else if (type === "directive") this.addCustomDirectives(info);
610
604
  return info;
611
605
  }
612
- return void 0;
613
606
  }
614
607
  normalizePath(path) {
615
608
  var _this$viteConfig, _this$viteConfig2;
@@ -631,20 +624,20 @@ var Context = class {
631
624
  debug.search(this._componentNameMap);
632
625
  this._searched = true;
633
626
  }
634
- _generateDeclaration(removeUnused = !this._server) {
627
+ _generateDeclaration(removeUnused = this._removeUnused) {
635
628
  if (!this.options.dts) return;
636
629
  debug.declaration("generating dts");
637
630
  return writeDeclaration(this, this.options.dts, removeUnused);
638
631
  }
639
- generateDeclaration(removeUnused = !this._server) {
632
+ generateDeclaration(removeUnused = this._removeUnused) {
640
633
  this._generateDeclaration(removeUnused);
641
634
  }
642
- _generateComponentsJson(removeUnused = !this._server) {
635
+ _generateComponentsJson(removeUnused = this._removeUnused) {
643
636
  if (!Object.keys(this._componentNameMap).length) return;
644
637
  debug.components("generating components-info");
645
638
  return writeComponentsJson(this, removeUnused);
646
639
  }
647
- generateComponentsJson(removeUnused = !this._server) {
640
+ generateComponentsJson(removeUnused = this._removeUnused) {
648
641
  this._generateComponentsJson(removeUnused);
649
642
  }
650
643
  get componentNameMap() {
@@ -673,18 +666,17 @@ var unplugin_default = createUnplugin((options = {}) => {
673
666
  /[\\/]\.nuxt[\\/]/
674
667
  ]);
675
668
  const ctx = new Context(options);
676
- const api = {
677
- async findComponent(name, filename) {
678
- return await ctx.findComponent(name, "component", filename ? [filename] : []);
679
- },
680
- stringifyImport(info) {
681
- return stringifyComponentImport(info, ctx);
682
- }
683
- };
684
669
  return {
685
670
  name: "unplugin-vue-components",
686
671
  enforce: "post",
687
- api,
672
+ api: {
673
+ async findComponent(name, filename) {
674
+ return await ctx.findComponent(name, "component", filename ? [filename] : []);
675
+ },
676
+ stringifyImport(info) {
677
+ return stringifyComponentImport(info, ctx);
678
+ }
679
+ },
688
680
  transformInclude(id) {
689
681
  return filter(id);
690
682
  },
@@ -1,15 +1,26 @@
1
- const require_utils = require('./utils-BIvt10am.cjs');
2
- const node_fs = require_utils.__toESM(require("node:fs"));
3
- const node_process = require_utils.__toESM(require("node:process"));
4
- const chokidar = require_utils.__toESM(require("chokidar"));
5
- const unplugin = require_utils.__toESM(require("unplugin"));
6
- const unplugin_utils = require_utils.__toESM(require("unplugin-utils"));
7
- const node_path = require_utils.__toESM(require("node:path"));
8
- const debug = require_utils.__toESM(require("debug"));
9
- const node_fs_promises = require_utils.__toESM(require("node:fs/promises"));
10
- const local_pkg = require_utils.__toESM(require("local-pkg"));
11
- const tinyglobby = require_utils.__toESM(require("tinyglobby"));
12
- const magic_string = require_utils.__toESM(require("magic-string"));
1
+ const require_utils = require('./utils-c-ZB7b5u.cjs');
2
+ let node_fs = require("node:fs");
3
+ node_fs = require_utils.__toESM(node_fs);
4
+ let node_process = require("node:process");
5
+ node_process = require_utils.__toESM(node_process);
6
+ let chokidar = require("chokidar");
7
+ chokidar = require_utils.__toESM(chokidar);
8
+ let unplugin = require("unplugin");
9
+ unplugin = require_utils.__toESM(unplugin);
10
+ let unplugin_utils = require("unplugin-utils");
11
+ unplugin_utils = require_utils.__toESM(unplugin_utils);
12
+ let node_path = require("node:path");
13
+ node_path = require_utils.__toESM(node_path);
14
+ let debug = require("debug");
15
+ debug = require_utils.__toESM(debug);
16
+ let node_fs_promises = require("node:fs/promises");
17
+ node_fs_promises = require_utils.__toESM(node_fs_promises);
18
+ let local_pkg = require("local-pkg");
19
+ local_pkg = require_utils.__toESM(local_pkg);
20
+ let tinyglobby = require("tinyglobby");
21
+ tinyglobby = require_utils.__toESM(tinyglobby);
22
+ let magic_string = require("magic-string");
23
+ magic_string = require_utils.__toESM(magic_string);
13
24
 
14
25
  //#region src/core/type-imports/index.ts
15
26
  const TypeImportPresets = [{
@@ -54,13 +65,6 @@ function parseDeclaration(code) {
54
65
  if (directiveDeclaration) imports.directive = extractImports(directiveDeclaration);
55
66
  return imports;
56
67
  }
57
- function addComponentPrefix(component, prefix) {
58
- if (!component.as || !prefix) return component;
59
- return {
60
- ...component,
61
- as: `${prefix}${component.as}`
62
- };
63
- }
64
68
  /**
65
69
  * Converts `ComponentInfo` to an array
66
70
  *
@@ -82,12 +86,10 @@ function stringifyComponentsInfo(filepath, components, importPathTransform) {
82
86
  return Object.fromEntries(components.map((info) => stringifyComponentInfo(filepath, info, importPathTransform)).filter(require_utils.notNullish));
83
87
  }
84
88
  function getDeclarationImports(ctx, filepath) {
85
- const prefixComponentNameMap = Object.values(ctx.componentNameMap).map((info) => addComponentPrefix(info, ctx.options.prefix));
86
- const component = stringifyComponentsInfo(filepath, [
87
- ...Object.values(ctx.componentCustomMap),
88
- ...prefixComponentNameMap,
89
- ...resolveTypeImports(ctx.options.types)
90
- ], ctx.options.importPathTransform);
89
+ const component = stringifyComponentsInfo(filepath, [...Object.values({
90
+ ...ctx.componentNameMap,
91
+ ...ctx.componentCustomMap
92
+ }), ...resolveTypeImports(ctx.options.types)], ctx.options.importPathTransform);
91
93
  const directive = stringifyComponentsInfo(filepath, Object.values(ctx.directiveCustomMap), ctx.options.importPathTransform);
92
94
  if (Object.keys(component).length + Object.keys(directive).length === 0) return;
93
95
  return {
@@ -193,6 +195,7 @@ const defaultOptions = {
193
195
  allowOverrides: false,
194
196
  sourcemap: true,
195
197
  dumpComponentsInfo: false,
198
+ syncMode: "default",
196
199
  prefix: ""
197
200
  };
198
201
  function normalizeResolvers(resolvers) {
@@ -223,7 +226,7 @@ function resolveOptions(options, root) {
223
226
  prefix = "!";
224
227
  i = i.slice(1);
225
228
  }
226
- return resolved.deep ? prefix + require_utils.slash((0, node_path.join)(i, `**/*.${extsGlob}`)) : prefix + require_utils.slash((0, node_path.join)(i, `*.${extsGlob}`));
229
+ return resolved.deep ? prefix + require_utils.escapeSpecialChars(require_utils.slash((0, node_path.join)(i, `**/*.${extsGlob}`))) : prefix + require_utils.escapeSpecialChars(require_utils.slash((0, node_path.join)(i, `*.${extsGlob}`)));
227
230
  });
228
231
  if (!resolved.extensions.length) throw new Error("[unplugin-vue-components] `extensions` option is required to search for components");
229
232
  }
@@ -245,8 +248,7 @@ function resolveOptions(options, root) {
245
248
  }
246
249
  function getVueVersion(root) {
247
250
  var _getPackageInfoSync;
248
- const raw = ((_getPackageInfoSync = (0, local_pkg.getPackageInfoSync)("vue", { paths: [(0, node_path.join)(root, "/")] })) === null || _getPackageInfoSync === void 0 ? void 0 : _getPackageInfoSync.version) || "3";
249
- const version = +raw.split(".").slice(0, 2).join(".");
251
+ const version = +(((_getPackageInfoSync = (0, local_pkg.getPackageInfoSync)("vue", { paths: [(0, node_path.join)(root, "/")] })) === null || _getPackageInfoSync === void 0 ? void 0 : _getPackageInfoSync.version) || "3").split(".").slice(0, 2).join(".");
250
252
  if (version === 2.7) return 2.7;
251
253
  else if (version < 2.7) return 2;
252
254
  return 3;
@@ -327,9 +329,7 @@ async function resolveVue2(code, s) {
327
329
  const { parse } = await (0, local_pkg.importModule)("@babel/parser");
328
330
  const { program } = parse(code, { sourceType: "module" });
329
331
  const nodes = [];
330
- const { walk } = await Promise.resolve().then(function() {
331
- return require("./src-BslXt6ey.cjs");
332
- });
332
+ const { walk } = await Promise.resolve().then(() => require("./src-BTwFq3T3.cjs"));
333
333
  walk(program, { enter(node) {
334
334
  if (node.type === "CallExpression") nodes.push(node);
335
335
  } });
@@ -440,11 +440,12 @@ const debug$1 = {
440
440
  var Context = class {
441
441
  options;
442
442
  transformer = void 0;
443
- _componentPaths = new Set();
443
+ _componentPaths = /* @__PURE__ */ new Set();
444
444
  _componentNameMap = {};
445
445
  _componentUsageMap = {};
446
446
  _componentCustomMap = {};
447
447
  _directiveCustomMap = {};
448
+ _removeUnused = false;
448
449
  _server;
449
450
  root = node_process.default.cwd();
450
451
  sourcemap = true;
@@ -455,9 +456,9 @@ var Context = class {
455
456
  this.options = resolveOptions(rawOptions, this.root);
456
457
  this.sourcemap = rawOptions.sourcemap ?? true;
457
458
  this.generateDeclaration = require_utils.throttle(500, this._generateDeclaration.bind(this), { noLeading: false });
459
+ this._removeUnused = this.options.syncMode === "overwrite";
458
460
  if (this.options.dumpComponentsInfo) {
459
- const dumpComponentsInfo = this.options.dumpComponentsInfo === true ? "./.components-info.json" : this.options.dumpComponentsInfo ?? false;
460
- this.dumpComponentsInfoPath = dumpComponentsInfo;
461
+ this.dumpComponentsInfoPath = this.options.dumpComponentsInfo === true ? "./.components-info.json" : this.options.dumpComponentsInfo ?? false;
461
462
  this.generateComponentsJson = require_utils.throttle(500, this._generateComponentsJson.bind(this), { noLeading: false });
462
463
  }
463
464
  this.setTransformer(this.options.transformer);
@@ -479,6 +480,7 @@ var Context = class {
479
480
  setupViteServer(server) {
480
481
  if (this._server === server) return;
481
482
  this._server = server;
483
+ this._removeUnused = this.options.syncMode !== "append";
482
484
  this.setupWatcher(server.watcher);
483
485
  }
484
486
  setupWatcher(watcher) {
@@ -520,7 +522,7 @@ var Context = class {
520
522
  * @param paths paths of used components
521
523
  */
522
524
  updateUsageMap(path, paths) {
523
- if (!this._componentUsageMap[path]) this._componentUsageMap[path] = new Set();
525
+ if (!this._componentUsageMap[path]) this._componentUsageMap[path] = /* @__PURE__ */ new Set();
524
526
  paths.forEach((p) => {
525
527
  this._componentUsageMap[path].add(p);
526
528
  });
@@ -559,7 +561,7 @@ var Context = class {
559
561
  type: "update",
560
562
  updates: []
561
563
  };
562
- const timestamp = +new Date();
564
+ const timestamp = +/* @__PURE__ */ new Date();
563
565
  const name = require_utils.pascalCase(require_utils.getNameFromFilePath(path, this.options));
564
566
  Object.entries(this._componentUsageMap).forEach(([key, values]) => {
565
567
  if (values.has(name)) {
@@ -577,7 +579,8 @@ var Context = class {
577
579
  updateComponentNameMap() {
578
580
  this._componentNameMap = {};
579
581
  Array.from(this._componentPaths).forEach((path) => {
580
- const name = require_utils.pascalCase(require_utils.getNameFromFilePath(path, this.options));
582
+ const fileName = require_utils.getNameFromFilePath(path, this.options);
583
+ const name = this.options.prefix ? `${require_utils.pascalCase(this.options.prefix)}${require_utils.pascalCase(fileName)}` : require_utils.pascalCase(fileName);
581
584
  if (require_utils.isExclude(name, this.options.excludeNames)) {
582
585
  debug$1.components("exclude", name);
583
586
  return;
@@ -611,7 +614,6 @@ var Context = class {
611
614
  else if (type === "directive") this.addCustomDirectives(info);
612
615
  return info;
613
616
  }
614
- return void 0;
615
617
  }
616
618
  normalizePath(path) {
617
619
  var _this$viteConfig, _this$viteConfig2;
@@ -633,20 +635,20 @@ var Context = class {
633
635
  debug$1.search(this._componentNameMap);
634
636
  this._searched = true;
635
637
  }
636
- _generateDeclaration(removeUnused = !this._server) {
638
+ _generateDeclaration(removeUnused = this._removeUnused) {
637
639
  if (!this.options.dts) return;
638
640
  debug$1.declaration("generating dts");
639
641
  return writeDeclaration(this, this.options.dts, removeUnused);
640
642
  }
641
- generateDeclaration(removeUnused = !this._server) {
643
+ generateDeclaration(removeUnused = this._removeUnused) {
642
644
  this._generateDeclaration(removeUnused);
643
645
  }
644
- _generateComponentsJson(removeUnused = !this._server) {
646
+ _generateComponentsJson(removeUnused = this._removeUnused) {
645
647
  if (!Object.keys(this._componentNameMap).length) return;
646
648
  debug$1.components("generating components-info");
647
649
  return writeComponentsJson(this, removeUnused);
648
650
  }
649
- generateComponentsJson(removeUnused = !this._server) {
651
+ generateComponentsJson(removeUnused = this._removeUnused) {
650
652
  this._generateComponentsJson(removeUnused);
651
653
  }
652
654
  get componentNameMap() {
@@ -675,18 +677,17 @@ var unplugin_default = (0, unplugin.createUnplugin)((options = {}) => {
675
677
  /[\\/]\.nuxt[\\/]/
676
678
  ]);
677
679
  const ctx = new Context(options);
678
- const api = {
679
- async findComponent(name, filename) {
680
- return await ctx.findComponent(name, "component", filename ? [filename] : []);
681
- },
682
- stringifyImport(info) {
683
- return require_utils.stringifyComponentImport(info, ctx);
684
- }
685
- };
686
680
  return {
687
681
  name: "unplugin-vue-components",
688
682
  enforce: "post",
689
- api,
683
+ api: {
684
+ async findComponent(name, filename) {
685
+ return await ctx.findComponent(name, "component", filename ? [filename] : []);
686
+ },
687
+ stringifyImport(info) {
688
+ return require_utils.stringifyComponentImport(info, ctx);
689
+ }
690
+ },
690
691
  transformInclude(id) {
691
692
  return filter(id);
692
693
  },
@@ -1,4 +1,3 @@
1
-
2
1
  //#region node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/walker.js
3
2
  /**
4
3
  * @typedef { import('estree').Node} Node
@@ -181,9 +180,8 @@ function isNode(value) {
181
180
  * @returns {Node | null}
182
181
  */
183
182
  function walk(ast, { enter, leave }) {
184
- const instance = new SyncWalker(enter, leave);
185
- return instance.visit(ast, null);
183
+ return new SyncWalker(enter, leave).visit(ast, null);
186
184
  }
187
185
 
188
186
  //#endregion
189
- exports.walk = walk;
187
+ export { walk };
@@ -1,6 +1,6 @@
1
- import { Awaitable } from "@antfu/utils";
2
1
  import { TransformResult } from "unplugin";
3
2
  import { FilterPattern } from "unplugin-utils";
3
+ import { Awaitable } from "@antfu/utils";
4
4
 
5
5
  //#region src/types.d.ts
6
6
  interface ImportInfoLegacy {
@@ -188,6 +188,15 @@ interface Options {
188
188
  * @default false
189
189
  */
190
190
  dumpComponentsInfo?: boolean | string;
191
+ /**
192
+ * The mode for syncing the components.d.ts and .components-info.json file.
193
+ * - `append`: only append the new components to the existing files.
194
+ * - `overwrite`: overwrite the whole existing files with the current components.
195
+ * - `default`: use `append` strategy when using dev server, `overwrite` strategy when using build.
196
+ *
197
+ * @default 'default'
198
+ */
199
+ syncMode?: 'default' | 'append' | 'overwrite';
191
200
  }
192
201
  type ResolvedOptions = Omit<Required<Options>, 'resolvers' | 'extensions' | 'dirs' | 'globalComponentsDeclaration'> & {
193
202
  resolvers: ComponentResolverObject[];
@@ -0,0 +1 @@
1
+ export { };
@@ -1,6 +1,6 @@
1
+ import { Awaitable } from "@antfu/utils";
1
2
  import { TransformResult } from "unplugin";
2
3
  import { FilterPattern } from "unplugin-utils";
3
- import { Awaitable } from "@antfu/utils";
4
4
 
5
5
  //#region src/types.d.ts
6
6
  interface ImportInfoLegacy {
@@ -188,6 +188,15 @@ interface Options {
188
188
  * @default false
189
189
  */
190
190
  dumpComponentsInfo?: boolean | string;
191
+ /**
192
+ * The mode for syncing the components.d.ts and .components-info.json file.
193
+ * - `append`: only append the new components to the existing files.
194
+ * - `overwrite`: overwrite the whole existing files with the current components.
195
+ * - `default`: use `append` strategy when using dev server, `overwrite` strategy when using build.
196
+ *
197
+ * @default 'default'
198
+ */
199
+ syncMode?: 'default' | 'append' | 'overwrite';
191
200
  }
192
201
  type ResolvedOptions = Omit<Required<Options>, 'resolvers' | 'extensions' | 'dirs' | 'globalComponentsDeclaration'> & {
193
202
  resolvers: ComponentResolverObject[];
package/dist/types.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport } from "./types-BED632qH.cjs";
1
+ import { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport } from "./types-dp3LCoF8.cjs";
2
2
  export { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport };
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport } from "./types-CFwIfA2K.js";
1
+ import { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport } from "./types-BgF15syy.js";
2
2
  export { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport };
package/dist/types.js CHANGED
@@ -1 +1,3 @@
1
- import "./types-Cv8NMtbo.js";
1
+ import "./types-DQoXDiso.js";
2
+
3
+ export { };