unplugin-vue-components 29.2.0 → 31.0.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 (70) hide show
  1. package/README.md +4 -36
  2. package/dist/esbuild.d.mts +7 -0
  3. package/dist/esbuild.mjs +9 -0
  4. package/dist/{index.d.cts → index.d.mts} +4 -2
  5. package/dist/index.mjs +4 -0
  6. package/dist/nuxt.d.mts +7 -0
  7. package/dist/{nuxt.js → nuxt.mjs} +4 -4
  8. package/dist/{resolvers.d.ts → resolvers.d.mts} +189 -218
  9. package/dist/{resolvers.js → resolvers.mjs} +28 -83
  10. package/dist/rolldown.d.mts +7 -0
  11. package/dist/rolldown.mjs +9 -0
  12. package/dist/rollup.d.mts +7 -0
  13. package/dist/rollup.mjs +9 -0
  14. package/dist/rspack.d.mts +6 -0
  15. package/dist/rspack.mjs +9 -0
  16. package/dist/{src-bfjkatac.js → src-pYuu2TZ_.mjs} +53 -141
  17. package/dist/types-CWfK8m_y.d.mts +217 -0
  18. package/dist/types.d.mts +2 -0
  19. package/dist/types.mjs +1 -0
  20. package/dist/utils-DuuqqWXg.mjs +234 -0
  21. package/dist/vite.d.mts +9 -0
  22. package/dist/vite.mjs +9 -0
  23. package/dist/webpack.d.mts +7 -0
  24. package/dist/webpack.mjs +9 -0
  25. package/package.json +40 -78
  26. package/dist/esbuild.cjs +0 -9
  27. package/dist/esbuild.d.cts +0 -6
  28. package/dist/esbuild.d.ts +0 -7
  29. package/dist/esbuild.js +0 -9
  30. package/dist/index.cjs +0 -9
  31. package/dist/index.d.ts +0 -13
  32. package/dist/index.js +0 -5
  33. package/dist/nuxt.cjs +0 -14
  34. package/dist/nuxt.d.cts +0 -6
  35. package/dist/nuxt.d.ts +0 -7
  36. package/dist/resolvers.cjs +0 -2074
  37. package/dist/resolvers.d.cts +0 -574
  38. package/dist/rolldown.cjs +0 -9
  39. package/dist/rolldown.d.cts +0 -6
  40. package/dist/rolldown.d.ts +0 -7
  41. package/dist/rolldown.js +0 -9
  42. package/dist/rollup.cjs +0 -9
  43. package/dist/rollup.d.cts +0 -6
  44. package/dist/rollup.d.ts +0 -7
  45. package/dist/rollup.js +0 -9
  46. package/dist/rspack.cjs +0 -9
  47. package/dist/rspack.d.cts +0 -5
  48. package/dist/rspack.d.ts +0 -6
  49. package/dist/rspack.js +0 -9
  50. package/dist/src-BTwFq3T3.cjs +0 -188
  51. package/dist/src-D2-JfLYq.js +0 -187
  52. package/dist/src-DAvVDVLg.cjs +0 -769
  53. package/dist/types-CBTc19th.cjs +0 -0
  54. package/dist/types-DSJ5r-ta.d.cts +0 -225
  55. package/dist/types-rC3290ja.d.ts +0 -225
  56. package/dist/types.cjs +0 -1
  57. package/dist/types.d.cts +0 -2
  58. package/dist/types.d.ts +0 -2
  59. package/dist/types.js +0 -3
  60. package/dist/utils-8UQ22cuO.cjs +0 -1689
  61. package/dist/utils-BoXu-4gQ.js +0 -1523
  62. package/dist/vite.cjs +0 -9
  63. package/dist/vite.d.cts +0 -8
  64. package/dist/vite.d.ts +0 -9
  65. package/dist/vite.js +0 -9
  66. package/dist/webpack.cjs +0 -9
  67. package/dist/webpack.d.cts +0 -6
  68. package/dist/webpack.d.ts +0 -7
  69. package/dist/webpack.js +0 -9
  70. /package/dist/{types-DQoXDiso.js → types--fVOUYBq.mjs} +0 -0
@@ -1,14 +1,14 @@
1
- import { DIRECTIVE_IMPORT_PREFIX, DISABLE_COMMENT, escapeSpecialChars, getNameFromFilePath, getTransformedPath, isExclude, matchGlobs, normalizeComponentInfo, notNullish, parseId, pascalCase, resolveAlias, shouldTransform, slash, stringifyComponentImport, throttle, toArray } from "./utils-BoXu-4gQ.js";
1
+ import { _ as DISABLE_COMMENT, a as getTransformedPath, b as throttle, d as parseId, f as pascalCase, g as DIRECTIVE_IMPORT_PREFIX, h as stringifyComponentImport, l as matchGlobs, m as shouldTransform, n as escapeSpecialChars, o as isExclude, p as resolveAlias, r as getNameFromFilePath, u as normalizeComponentInfo, v as notNullish, x as toArray, y as slash } from "./utils-DuuqqWXg.mjs";
2
2
  import { existsSync } from "node:fs";
3
3
  import process from "node:process";
4
4
  import chokidar from "chokidar";
5
+ import { glob, globSync } from "tinyglobby";
5
6
  import { createUnplugin } from "unplugin";
6
7
  import { createFilter } from "unplugin-utils";
7
8
  import { dirname, isAbsolute, join, relative, resolve } from "node:path";
8
- import Debug from "debug";
9
+ import { createDebug } from "obug";
9
10
  import { mkdir, readFile, writeFile } from "node:fs/promises";
10
- import { getPackageInfoSync, importModule, isPackageExists } from "local-pkg";
11
- import { globSync } from "tinyglobby";
11
+ import { isPackageExists } from "local-pkg";
12
12
  import MagicString from "magic-string";
13
13
 
14
14
  //#region src/core/type-imports/index.ts
@@ -41,16 +41,15 @@ function extractImports(code) {
41
41
  return Object.fromEntries(Array.from(code.matchAll(/['"]?([^\s'"]+)['"]?\s*:\s*(.+?)[,;\r\n]/g)).map((i) => [i[1], i[2]]));
42
42
  }
43
43
  function parseDeclaration(code) {
44
- var _exec, _exec2;
45
44
  if (!code) return;
46
45
  code = code.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, "");
47
46
  const imports = {
48
47
  component: {},
49
48
  directive: {}
50
49
  };
51
- const componentDeclaration = (_exec = /export\s+interface\s+GlobalComponents\s*\{.*?\}/s.exec(code)) === null || _exec === void 0 ? void 0 : _exec[0];
50
+ const componentDeclaration = /export\s+interface\s+GlobalComponents\s*\{.*?\}/s.exec(code)?.[0];
52
51
  if (componentDeclaration) imports.component = extractImports(componentDeclaration);
53
- const directiveDeclaration = (_exec2 = /export\s+interface\s+GlobalDirectives\s*\{.*?\}/s.exec(code)) === null || _exec2 === void 0 ? void 0 : _exec2[0];
52
+ const directiveDeclaration = /export\s+interface\s+GlobalDirectives\s*\{.*?\}/s.exec(code)?.[0];
54
53
  if (directiveDeclaration) imports.directive = extractImports(directiveDeclaration);
55
54
  return imports;
56
55
  }
@@ -95,11 +94,11 @@ function getDeclaration(ctx, filepath, originalImports) {
95
94
  if (!imports) return;
96
95
  const declarations = {
97
96
  component: stringifyDeclarationImports({
98
- ...originalImports === null || originalImports === void 0 ? void 0 : originalImports.component,
97
+ ...originalImports?.component,
99
98
  ...imports.component
100
99
  }),
101
100
  directive: stringifyDeclarationImports({
102
- ...originalImports === null || originalImports === void 0 ? void 0 : originalImports.directive,
101
+ ...originalImports?.directive,
103
102
  ...imports.directive
104
103
  })
105
104
  };
@@ -158,9 +157,8 @@ async function writeComponentsJson(ctx, _removeUnused = false) {
158
157
 
159
158
  //#endregion
160
159
  //#region src/core/fs/glob.ts
161
- const debug$4 = Debug("unplugin-vue-components:glob");
160
+ const debug$4 = createDebug("unplugin-vue-components:glob");
162
161
  function searchComponents(ctx) {
163
- var _ctx$options$resolver;
164
162
  debug$4(`started with: [${ctx.options.globs.join(", ")}]`);
165
163
  const root = ctx.root;
166
164
  const files = globSync(ctx.options.globs, {
@@ -170,7 +168,7 @@ function searchComponents(ctx) {
170
168
  absolute: true,
171
169
  expandDirectories: false
172
170
  });
173
- if (!files.length && !((_ctx$options$resolver = ctx.options.resolvers) === null || _ctx$options$resolver === void 0 ? void 0 : _ctx$options$resolver.length)) console.warn("[unplugin-vue-components] no components found");
171
+ if (!files.length && !ctx.options.resolvers?.length) console.warn("[unplugin-vue-components] no components found");
174
172
  debug$4(`${files.length} components found.`);
175
173
  ctx.addComponents(files);
176
174
  }
@@ -201,16 +199,16 @@ function normalizeResolvers(resolvers) {
201
199
  type: "component"
202
200
  } : r);
203
201
  }
204
- function resolveGlobsExclude(root, glob) {
202
+ function resolveGlobsExclude(root, glob$1) {
205
203
  const excludeReg = /^!/;
206
- return slash(`${excludeReg.test(glob) ? "!" : ""}${resolve(root, glob.replace(excludeReg, ""))}`);
204
+ return slash(`${excludeReg.test(glob$1) ? "!" : ""}${resolve(root, glob$1.replace(excludeReg, ""))}`);
207
205
  }
208
206
  function resolveOptions(options, root) {
209
207
  const resolved = Object.assign({}, defaultOptions, options);
210
208
  resolved.resolvers = normalizeResolvers(resolved.resolvers);
211
209
  resolved.extensions = toArray(resolved.extensions);
212
210
  if (resolved.globs) {
213
- resolved.globs = toArray(resolved.globs).map((glob) => resolveGlobsExclude(root, glob));
211
+ resolved.globs = toArray(resolved.globs).map((glob$1) => resolveGlobsExclude(root, glob$1));
214
212
  resolved.resolvedDirs = [];
215
213
  } else {
216
214
  const extsGlob = resolved.extensions.length === 1 ? resolved.extensions : `{${resolved.extensions.join(",")}}`;
@@ -237,38 +235,13 @@ function resolveOptions(options, root) {
237
235
  if (!resolved.types && resolved.dts) resolved.types = detectTypeImports();
238
236
  resolved.types = resolved.types || [];
239
237
  resolved.root = root;
240
- resolved.version = resolved.version ?? getVueVersion(root);
241
- if (resolved.version < 2 || resolved.version >= 4) throw new Error(`[unplugin-vue-components] unsupported version: ${resolved.version}`);
242
- resolved.transformer = options.transformer || `vue${Math.trunc(resolved.version)}`;
243
- resolved.directives = typeof options.directives === "boolean" ? options.directives : !resolved.resolvers.some((i) => i.type === "directive") ? false : resolved.version >= 3;
238
+ resolved.directives ??= resolved.resolvers.some((i) => i.type === "directive");
244
239
  return resolved;
245
240
  }
246
- function getVueVersion(root) {
247
- var _getPackageInfoSync;
248
- const version = +(((_getPackageInfoSync = getPackageInfoSync("vue", { paths: [join(root, "/")] })) === null || _getPackageInfoSync === void 0 ? void 0 : _getPackageInfoSync.version) || "3").split(".").slice(0, 2).join(".");
249
- if (version === 2.7) return 2.7;
250
- else if (version < 2.7) return 2;
251
- return 3;
252
- }
253
241
 
254
242
  //#endregion
255
243
  //#region src/core/transforms/component.ts
256
- const debug$3 = Debug("unplugin-vue-components:transform:component");
257
- function resolveVue2$1(code, s) {
258
- const results = [];
259
- for (const match of code.matchAll(/\b(_c|h)\(\s*['"](.+?)["']([,)])/g)) {
260
- const [full, renderFunctionName, matchedName, append] = match;
261
- if (match.index != null && matchedName && !matchedName.startsWith("_")) {
262
- const start = match.index;
263
- const end = start + full.length;
264
- results.push({
265
- rawName: matchedName,
266
- replace: (resolved) => s.overwrite(start, end, `${renderFunctionName}(${resolved}${append}`)
267
- });
268
- }
269
- }
270
- return results;
271
- }
244
+ const debug$3 = createDebug("unplugin-vue-components:transform:component");
272
245
  function resolveVue3$1(code, s, transformerUserResolveFunctions) {
273
246
  const results = [];
274
247
  /**
@@ -288,9 +261,9 @@ function resolveVue3$1(code, s, transformerUserResolveFunctions) {
288
261
  }
289
262
  return results;
290
263
  }
291
- async function transformComponent(code, transformer$1, s, ctx, sfcPath) {
264
+ async function transformComponent(code, s, ctx, sfcPath) {
292
265
  let no = 0;
293
- const results = transformer$1 === "vue2" ? resolveVue2$1(code, s) : resolveVue3$1(code, s, ctx.options.transformerUserResolveFunctions);
266
+ const results = resolveVue3$1(code, s, ctx.options.transformerUserResolveFunctions);
294
267
  for (const { rawName, replace } of results) {
295
268
  debug$3(`| ${rawName}`);
296
269
  const name = pascalCase(rawName);
@@ -310,59 +283,27 @@ async function transformComponent(code, transformer$1, s, ctx, sfcPath) {
310
283
  }
311
284
 
312
285
  //#endregion
313
- //#region src/core/transforms/directive/vue2.ts
314
- /**
315
- * Get Vue 2 render function position
316
- */
317
- function getRenderFnStart(program) {
318
- var _ref;
319
- const renderFn = program.body.find((node) => node.type === "VariableDeclaration" && node.declarations[0].id.type === "Identifier" && ["render", "_sfc_render"].includes(node.declarations[0].id.name));
320
- const start = renderFn === null || renderFn === void 0 || (_ref = renderFn.declarations[0].init) === null || _ref === void 0 || (_ref = _ref.body) === null || _ref === void 0 ? void 0 : _ref.start;
321
- if (start === null || start === void 0) throw new Error("[unplugin-vue-components:directive] Cannot find render function position.");
322
- return start + 1;
323
- }
324
- async function resolveVue2(code, s) {
325
- if (!isPackageExists("@babel/parser")) throw new Error("[unplugin-vue-components:directive] To use Vue 2 directive you will need to install Babel first: \"npm install -D @babel/parser\"");
326
- const { parse: parse$1 } = await importModule("@babel/parser");
327
- const { program } = parse$1(code, { sourceType: "module" });
328
- const nodes = [];
329
- const { walk } = await import("./src-D2-JfLYq.js");
330
- walk(program, { enter(node) {
331
- if (node.type === "CallExpression") nodes.push(node);
332
- } });
333
- if (nodes.length === 0) return [];
334
- let _renderStart;
335
- const getRenderStart = () => {
336
- if (_renderStart !== void 0) return _renderStart;
337
- return _renderStart = getRenderFnStart(program);
338
- };
339
- const results = [];
340
- for (const node of nodes) {
341
- var _args$, _args$1$properties$fi;
342
- const { callee, arguments: args } = node;
343
- if (callee.type !== "Identifier" || callee.name !== "_c" || ((_args$ = args[1]) === null || _args$ === void 0 ? void 0 : _args$.type) !== "ObjectExpression") continue;
344
- const directives = (_args$1$properties$fi = args[1].properties.find((property) => property.type === "ObjectProperty" && property.key.type === "Identifier" && property.key.name === "directives")) === null || _args$1$properties$fi === void 0 ? void 0 : _args$1$properties$fi.value;
345
- if (!directives || directives.type !== "ArrayExpression") continue;
346
- for (const directive of directives.elements) {
347
- var _directive$properties;
348
- if ((directive === null || directive === void 0 ? void 0 : directive.type) !== "ObjectExpression") continue;
349
- const nameNode = (_directive$properties = directive.properties.find((p) => p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "name")) === null || _directive$properties === void 0 ? void 0 : _directive$properties.value;
350
- if ((nameNode === null || nameNode === void 0 ? void 0 : nameNode.type) !== "StringLiteral") continue;
351
- const name = nameNode.value;
352
- if (!name || name.startsWith("_")) continue;
353
- results.push({
354
- rawName: name,
355
- replace: (resolved) => {
356
- s.prependLeft(getRenderStart(), `\nthis.$options.directives["${name}"] = ${resolved};`);
357
- }
358
- });
359
- }
286
+ //#region src/core/transforms/directive.ts
287
+ const debug$2 = createDebug("unplugin-vue-components:transform:directive");
288
+ async function transformDirective(code, s, ctx, sfcPath) {
289
+ let no = 0;
290
+ const results = resolveVue3(code, s, ctx.options.transformerUserResolveFunctions);
291
+ for (const { rawName, replace } of results) {
292
+ debug$2(`| ${rawName}`);
293
+ const name = `${DIRECTIVE_IMPORT_PREFIX}${pascalCase(rawName)}`;
294
+ ctx.updateUsageMap(sfcPath, [name]);
295
+ const directive = await ctx.findComponent(name, "directive", [sfcPath]);
296
+ if (!directive) continue;
297
+ const varName = `__unplugin_directives_${no}`;
298
+ s.prepend(`${stringifyComponentImport({
299
+ ...directive,
300
+ as: varName
301
+ }, ctx)};\n`);
302
+ no += 1;
303
+ replace(varName);
360
304
  }
361
- return results;
305
+ debug$2(`^ (${no})`);
362
306
  }
363
-
364
- //#endregion
365
- //#region src/core/transforms/directive/vue3.ts
366
307
  function resolveVue3(code, s, transformerUserResolveFunctions) {
367
308
  const results = [];
368
309
  for (const match of code.matchAll(/_?resolveDirective\("(.+?)"\)/g)) {
@@ -380,40 +321,17 @@ function resolveVue3(code, s, transformerUserResolveFunctions) {
380
321
  return results;
381
322
  }
382
323
 
383
- //#endregion
384
- //#region src/core/transforms/directive/index.ts
385
- const debug$2 = Debug("unplugin-vue-components:transform:directive");
386
- async function transformDirective(code, transformer$1, s, ctx, sfcPath) {
387
- let no = 0;
388
- const results = await (transformer$1 === "vue2" ? resolveVue2(code, s) : resolveVue3(code, s));
389
- for (const { rawName, replace } of results) {
390
- debug$2(`| ${rawName}`);
391
- const name = `${DIRECTIVE_IMPORT_PREFIX}${pascalCase(rawName)}`;
392
- ctx.updateUsageMap(sfcPath, [name]);
393
- const directive = await ctx.findComponent(name, "directive", [sfcPath]);
394
- if (!directive) continue;
395
- const varName = `__unplugin_directives_${no}`;
396
- s.prepend(`${stringifyComponentImport({
397
- ...directive,
398
- as: varName
399
- }, ctx)};\n`);
400
- no += 1;
401
- replace(varName);
402
- }
403
- debug$2(`^ (${no})`);
404
- }
405
-
406
324
  //#endregion
407
325
  //#region src/core/transformer.ts
408
- const debug$1 = Debug("unplugin-vue-components:transformer");
409
- function transformer(ctx, transformer$1) {
326
+ const debug$1 = createDebug("unplugin-vue-components:transformer");
327
+ function transformer(ctx) {
410
328
  return async (code, id, path) => {
411
329
  ctx.searchGlob();
412
330
  const sfcPath = ctx.normalizePath(path);
413
331
  debug$1(sfcPath);
414
332
  const s = new MagicString(code);
415
- await transformComponent(code, transformer$1, s, ctx, sfcPath);
416
- if (ctx.options.directives) await transformDirective(code, transformer$1, s, ctx, sfcPath);
333
+ await transformComponent(code, s, ctx, sfcPath);
334
+ if (ctx.options.directives) await transformDirective(code, s, ctx, sfcPath);
417
335
  s.prepend(DISABLE_COMMENT);
418
336
  const result = { code: s.toString() };
419
337
  if (ctx.sourcemap) result.map = s.generateMap({
@@ -428,15 +346,15 @@ function transformer(ctx, transformer$1) {
428
346
  //#endregion
429
347
  //#region src/core/context.ts
430
348
  const debug = {
431
- components: Debug("unplugin-vue-components:context:components"),
432
- search: Debug("unplugin-vue-components:context:search"),
433
- hmr: Debug("unplugin-vue-components:context:hmr"),
434
- declaration: Debug("unplugin-vue-components:declaration"),
435
- env: Debug("unplugin-vue-components:env")
349
+ components: createDebug("unplugin-vue-components:context:components"),
350
+ search: createDebug("unplugin-vue-components:context:search"),
351
+ hmr: createDebug("unplugin-vue-components:context:hmr"),
352
+ declaration: createDebug("unplugin-vue-components:declaration"),
353
+ env: createDebug("unplugin-vue-components:env")
436
354
  };
437
355
  var Context = class {
438
356
  options;
439
- transformer = void 0;
357
+ transformer;
440
358
  _componentPaths = /* @__PURE__ */ new Set();
441
359
  _componentNameMap = {};
442
360
  _componentUsageMap = {};
@@ -458,7 +376,7 @@ var Context = class {
458
376
  this.dumpComponentsInfoPath = this.options.dumpComponentsInfo === true ? "./.components-info.json" : this.options.dumpComponentsInfo ?? false;
459
377
  this.generateComponentsJson = throttle(500, this._generateComponentsJson.bind(this), { noLeading: false });
460
378
  }
461
- this.setTransformer(this.options.transformer);
379
+ this.transformer = transformer(this);
462
380
  }
463
381
  setRoot(root) {
464
382
  if (this.root === root) return;
@@ -466,10 +384,6 @@ var Context = class {
466
384
  this.root = root;
467
385
  this.options = resolveOptions(this.rawOptions, this.root);
468
386
  }
469
- setTransformer(name) {
470
- debug.env("transformer", name);
471
- this.transformer = transformer(this, name || "vue3");
472
- }
473
387
  transform(code, id) {
474
388
  const { path, query } = parseId(id);
475
389
  return this.transformer(code, id, path, query);
@@ -615,8 +529,7 @@ var Context = class {
615
529
  }
616
530
  }
617
531
  normalizePath(path) {
618
- var _this$viteConfig, _this$viteConfig2;
619
- return resolveAlias(path, ((_this$viteConfig = this.viteConfig) === null || _this$viteConfig === void 0 || (_this$viteConfig = _this$viteConfig.resolve) === null || _this$viteConfig === void 0 ? void 0 : _this$viteConfig.alias) || ((_this$viteConfig2 = this.viteConfig) === null || _this$viteConfig2 === void 0 ? void 0 : _this$viteConfig2.alias) || []);
532
+ return resolveAlias(path, this.viteConfig?.resolve?.alias || this.viteConfig?.alias || []);
620
533
  }
621
534
  relative(path) {
622
535
  if (path.startsWith("/") && !path.startsWith(this.root)) return slash(path.slice(1));
@@ -702,10 +615,9 @@ var unplugin_default = createUnplugin((options = {}) => {
702
615
  }
703
616
  },
704
617
  vite: {
705
- configResolved(config) {
618
+ async configResolved(config) {
706
619
  ctx.setRoot(config.root);
707
620
  ctx.sourcemap = true;
708
- if (config.plugins.find((i) => i.name === "vite-plugin-vue2")) ctx.setTransformer("vue2");
709
621
  if (ctx.options.dts) {
710
622
  ctx.searchGlob();
711
623
  if (!existsSync(ctx.options.dts)) ctx.generateDeclaration();
@@ -713,7 +625,7 @@ var unplugin_default = createUnplugin((options = {}) => {
713
625
  if (ctx.options.dumpComponentsInfo && ctx.dumpComponentsInfoPath) {
714
626
  if (!existsSync(ctx.dumpComponentsInfoPath)) ctx.generateComponentsJson();
715
627
  }
716
- if (config.build.watch && config.command === "build") ctx.setupWatcher(chokidar.watch(ctx.options.globs));
628
+ if (config.build.watch && config.command === "build") ctx.setupWatcher(chokidar.watch(await glob(ctx.options.globs)));
717
629
  },
718
630
  configureServer(server) {
719
631
  ctx.setupViteServer(server);
@@ -722,10 +634,10 @@ var unplugin_default = createUnplugin((options = {}) => {
722
634
  webpack(compiler) {
723
635
  let watcher;
724
636
  let fileDepQueue = [];
725
- compiler.hooks.watchRun.tap(PLUGIN_NAME, () => {
637
+ compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, async () => {
726
638
  if (!watcher && compiler.watching) {
727
639
  watcher = compiler.watching;
728
- ctx.setupWatcherWebpack(chokidar.watch(ctx.options.globs), (path, type) => {
640
+ ctx.setupWatcherWebpack(chokidar.watch(await glob(ctx.options.globs)), (path, type) => {
729
641
  fileDepQueue.push({
730
642
  path,
731
643
  type
@@ -750,4 +662,4 @@ var unplugin_default = createUnplugin((options = {}) => {
750
662
  });
751
663
 
752
664
  //#endregion
753
- export { unplugin_default };
665
+ export { unplugin_default as t };
@@ -0,0 +1,217 @@
1
+ import { TransformResult } from "unplugin";
2
+ import { FilterPattern } from "unplugin-utils";
3
+
4
+ //#region node_modules/.pnpm/@antfu+utils@9.3.0/node_modules/@antfu/utils/dist/index.d.mts
5
+ /**
6
+ * Promise, or maybe not
7
+ */
8
+ type Awaitable<T> = T | PromiseLike<T>;
9
+ /**
10
+ * Null or whatever
11
+ */
12
+ //#endregion
13
+ //#region src/types.d.ts
14
+ interface ImportInfoLegacy {
15
+ /**
16
+ * @deprecated renamed to `as`
17
+ */
18
+ name?: string;
19
+ /**
20
+ * @deprecated renamed to `name`
21
+ */
22
+ importName?: string;
23
+ /**
24
+ * @deprecated renamed to `from`
25
+ */
26
+ path: string;
27
+ sideEffects?: SideEffectsInfo;
28
+ }
29
+ interface ImportInfo {
30
+ as?: string;
31
+ name?: string;
32
+ from: string;
33
+ }
34
+ type SideEffectsInfo = (ImportInfo | string)[] | ImportInfo | string | undefined;
35
+ interface ComponentInfo extends ImportInfo {
36
+ sideEffects?: SideEffectsInfo;
37
+ }
38
+ type ComponentResolveResult = Awaitable<string | ComponentInfo | null | undefined | void>;
39
+ type ComponentResolverFunction = (name: string) => ComponentResolveResult;
40
+ interface ComponentResolverObject {
41
+ type: 'component' | 'directive';
42
+ resolve: ComponentResolverFunction;
43
+ }
44
+ type ComponentResolver = ComponentResolverFunction | ComponentResolverObject;
45
+ type Matcher = (id: string) => boolean | null | undefined;
46
+ type Transformer = (code: string, id: string, path: string, query: Record<string, string>) => Awaitable<TransformResult | null>;
47
+ interface PublicPluginAPI {
48
+ /**
49
+ * Resolves a component using the configured resolvers.
50
+ */
51
+ findComponent: (name: string, filename?: string) => Promise<ComponentInfo | undefined>;
52
+ /**
53
+ * Obtain an import statement for a resolved component.
54
+ */
55
+ stringifyImport: (info: ComponentInfo) => string;
56
+ }
57
+ /**
58
+ * Plugin options.
59
+ */
60
+ interface Options {
61
+ /**
62
+ * RegExp or glob to match files to be transformed
63
+ */
64
+ include?: FilterPattern;
65
+ /**
66
+ * RegExp or glob to match files to NOT be transformed
67
+ */
68
+ exclude?: FilterPattern;
69
+ /**
70
+ * RegExp or string to match component names that will NOT be imported
71
+ */
72
+ excludeNames?: FilterPattern;
73
+ /**
74
+ * Relative paths to the directory to search for components.
75
+ * @default 'src/components'
76
+ */
77
+ dirs?: string | string[];
78
+ /**
79
+ * Valid file extensions for components.
80
+ * @default ['vue']
81
+ */
82
+ extensions?: string | string[];
83
+ /**
84
+ * Glob patterns to match file names to be detected as components.
85
+ *
86
+ * When specified, the `dirs`, `extensions`, and `directoryAsNamespace` options will be ignored.
87
+ */
88
+ globs?: string | string[];
89
+ /**
90
+ * Negated glob patterns to exclude files from being detected as components.
91
+ *
92
+ * @default []
93
+ */
94
+ globsExclude?: string | string[];
95
+ /**
96
+ * Search for subdirectories
97
+ * @default true
98
+ */
99
+ deep?: boolean;
100
+ /**
101
+ * Allow subdirectories as namespace prefix for components
102
+ * @default false
103
+ */
104
+ directoryAsNamespace?: boolean;
105
+ /**
106
+ * Generate components with prefix.
107
+ */
108
+ prefix?: string;
109
+ /**
110
+ * Collapse same prefixes (camel-sensitive) of folders and components
111
+ * to prevent duplication inside namespaced component name.
112
+ *
113
+ * Works when `directoryAsNamespace: true`
114
+ * @default false
115
+ */
116
+ collapseSamePrefixes?: boolean;
117
+ /**
118
+ * Subdirectory paths for ignoring namespace prefixes
119
+ *
120
+ * Works when `directoryAsNamespace: true`
121
+ * @default "[]"
122
+ */
123
+ globalNamespaces?: string[];
124
+ /**
125
+ * Pass a custom function to resolve the component importing path from the component name.
126
+ *
127
+ * The component names are always in PascalCase
128
+ */
129
+ resolvers?: (ComponentResolver | ComponentResolver[])[];
130
+ /**
131
+ * Apply custom transform over the path for importing
132
+ */
133
+ importPathTransform?: (path: string) => string | undefined;
134
+ /**
135
+ * Tranform users' usage of resolveComponent/resolveDirective as well
136
+ *
137
+ * If disabled, only components inside templates (which compiles to `_resolveComponent` etc.)
138
+ * will be transformed.
139
+ *
140
+ * @default true
141
+ */
142
+ transformerUserResolveFunctions?: boolean;
143
+ /**
144
+ * Generate TypeScript declaration for global components
145
+ *
146
+ * Accept boolean or a path related to project root
147
+ *
148
+ * @see https://github.com/vuejs/core/pull/3399
149
+ * @see https://github.com/johnsoncodehk/volar#using
150
+ * @default true
151
+ */
152
+ dts?: boolean | string;
153
+ /**
154
+ * Generate TypeScript declaration for global components
155
+ * For TSX support
156
+ *
157
+ * @default true if `@vitejs/plugin-vue-jsx` is installed
158
+ */
159
+ dtsTsx?: boolean;
160
+ /**
161
+ * Do not emit warning on component overriding
162
+ *
163
+ * @default false
164
+ */
165
+ allowOverrides?: boolean;
166
+ /**
167
+ * auto import for directives.
168
+ * @default true
169
+ */
170
+ directives?: boolean;
171
+ /**
172
+ * Only provide types of components in library (registered globally)
173
+ */
174
+ types?: TypeImport[];
175
+ /**
176
+ * Generate sourcemap for the transformed code.
177
+ *
178
+ * @default true
179
+ */
180
+ sourcemap?: boolean;
181
+ /**
182
+ * Save component information into a JSON file for other tools to consume.
183
+ * Provide a filepath to save the JSON file.
184
+ *
185
+ * When set to `true`, it will save to `./.components-info.json`
186
+ *
187
+ * @default false
188
+ */
189
+ dumpComponentsInfo?: boolean | string;
190
+ /**
191
+ * The mode for syncing the components.d.ts and .components-info.json file.
192
+ * - `append`: only append the new components to the existing files.
193
+ * - `overwrite`: overwrite the whole existing files with the current components.
194
+ * - `default`: use `append` strategy when using dev server, `overwrite` strategy when using build.
195
+ *
196
+ * @default 'default'
197
+ */
198
+ syncMode?: 'default' | 'append' | 'overwrite';
199
+ }
200
+ type ResolvedOptions = Omit<Required<Options>, 'resolvers' | 'extensions' | 'dirs' | 'globalComponentsDeclaration'> & {
201
+ resolvers: ComponentResolverObject[];
202
+ extensions: string[];
203
+ dirs: string[];
204
+ resolvedDirs: string[];
205
+ globs: string[];
206
+ globsExclude: string[];
207
+ dts: string | false;
208
+ dtsTsx: boolean;
209
+ root: string;
210
+ };
211
+ type ComponentsImportMap = Record<string, string[] | undefined>;
212
+ interface TypeImport {
213
+ from: string;
214
+ names: string[];
215
+ }
216
+ //#endregion
217
+ export { ComponentResolverObject as a, ImportInfoLegacy as c, PublicPluginAPI as d, ResolvedOptions as f, TypeImport as h, ComponentResolverFunction as i, Matcher as l, Transformer as m, ComponentResolveResult as n, ComponentsImportMap as o, SideEffectsInfo as p, ComponentResolver as r, ImportInfo as s, ComponentInfo as t, Options as u };
@@ -0,0 +1,2 @@
1
+ import { a as ComponentResolverObject, c as ImportInfoLegacy, d as PublicPluginAPI, f as ResolvedOptions, h as TypeImport, i as ComponentResolverFunction, l as Matcher, m as Transformer, n as ComponentResolveResult, o as ComponentsImportMap, p as SideEffectsInfo, r as ComponentResolver, s as ImportInfo, t as ComponentInfo, u as Options } from "./types-CWfK8m_y.mjs";
2
+ export { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, Transformer, TypeImport };
package/dist/types.mjs ADDED
@@ -0,0 +1 @@
1
+ export { };