unplugin-vue-components 0.26.0 → 0.27.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/README.md CHANGED
@@ -65,7 +65,6 @@ export default {
65
65
 
66
66
  <br></details>
67
67
 
68
-
69
68
  <details>
70
69
  <summary>Webpack</summary><br>
71
70
 
@@ -117,6 +116,7 @@ module.exports = {
117
116
  ```
118
117
 
119
118
  You can also rename the Vue configuration file to `vue.config.mjs` and use static import syntax (you should use latest `@vue/cli-service ^5.0.8`):
119
+
120
120
  ```ts
121
121
  // vue.config.mjs
122
122
  import Components from 'unplugin-vue-components/webpack'
@@ -166,9 +166,9 @@ It will automatically turn this
166
166
  </template>
167
167
 
168
168
  <script>
169
- export default {
170
- name: 'App'
171
- }
169
+ export default {
170
+ name: 'App',
171
+ }
172
172
  </script>
173
173
  ```
174
174
 
@@ -182,16 +182,17 @@ into this
182
182
  </template>
183
183
 
184
184
  <script>
185
- import HelloWorld from './src/components/HelloWorld.vue'
185
+ import HelloWorld from './src/components/HelloWorld.vue'
186
186
 
187
- export default {
188
- name: 'App',
189
- components: {
190
- HelloWorld
187
+ export default {
188
+ name: 'App',
189
+ components: {
190
+ HelloWorld,
191
+ },
191
192
  }
192
- }
193
193
  </script>
194
194
  ```
195
+
195
196
  > **Note**
196
197
  > By default this plugin will import components in the `src/components` path. You can customize it using the `dirs` option.
197
198
 
@@ -122,17 +122,18 @@ function getNameFromFilePath(filePath, options) {
122
122
  for (const fileOrFolderName of namespaced) {
123
123
  let cumulativePrefix = "";
124
124
  let didCollapse = false;
125
+ const pascalCasedName = pascalCase(fileOrFolderName);
125
126
  for (const parentFolder of [...collapsed].reverse()) {
126
- cumulativePrefix = `${capitalize(parentFolder)}${cumulativePrefix}`;
127
- if (pascalCase(fileOrFolderName).startsWith(pascalCase(cumulativePrefix))) {
128
- const collapseSamePrefix = fileOrFolderName.slice(cumulativePrefix.length);
127
+ cumulativePrefix = `${parentFolder}${cumulativePrefix}`;
128
+ if (pascalCasedName.startsWith(cumulativePrefix)) {
129
+ const collapseSamePrefix = pascalCasedName.slice(cumulativePrefix.length);
129
130
  collapsed.push(collapseSamePrefix);
130
131
  didCollapse = true;
131
132
  break;
132
133
  }
133
134
  }
134
135
  if (!didCollapse)
135
- collapsed.push(fileOrFolderName);
136
+ collapsed.push(pascalCasedName);
136
137
  }
137
138
  namespaced = collapsed;
138
139
  }
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkUX65OJTHcjs = require('./chunk-UX65OJTH.cjs');
13
+ var _chunk5QHU6UOYcjs = require('./chunk-5QHU6UOY.cjs');
14
14
 
15
15
 
16
16
 
@@ -178,7 +178,7 @@ function parseDeclaration(code) {
178
178
  function stringifyComponentInfo(filepath, { from: path, as: name, name: importName }, importPathTransform) {
179
179
  if (!name)
180
180
  return void 0;
181
- path = _chunkUX65OJTHcjs.getTransformedPath.call(void 0, path, importPathTransform);
181
+ path = _chunk5QHU6UOYcjs.getTransformedPath.call(void 0, path, importPathTransform);
182
182
  const related = _path.isAbsolute.call(void 0, path) ? `./${_path.relative.call(void 0, _path.dirname.call(void 0, filepath), path)}` : path;
183
183
  const entry = `typeof import('${_utils.slash.call(void 0, related)}')['${importName || "default"}']`;
184
184
  return [name, entry];
@@ -217,17 +217,14 @@ function getDeclaration(ctx, filepath, originalImports) {
217
217
  component: stringifyDeclarationImports(_chunkWJIU4Q36cjs.__spreadValues.call(void 0, _chunkWJIU4Q36cjs.__spreadValues.call(void 0, {}, originalImports == null ? void 0 : originalImports.component), imports.component)),
218
218
  directive: stringifyDeclarationImports(_chunkWJIU4Q36cjs.__spreadValues.call(void 0, _chunkWJIU4Q36cjs.__spreadValues.call(void 0, {}, originalImports == null ? void 0 : originalImports.directive), imports.directive))
219
219
  };
220
- const head = ctx.options.version === 2.7 ? `export {}
221
-
222
- declare module 'vue' {` : `export {}
223
-
224
- declare module 'vue' {`;
225
220
  let code = `/* eslint-disable */
226
- /* prettier-ignore */
227
221
  // @ts-nocheck
228
222
  // Generated by unplugin-vue-components
229
223
  // Read more: https://github.com/vuejs/core/pull/3399
230
- ${head}`;
224
+ export {}
225
+
226
+ /* prettier-ignore */
227
+ declare module 'vue' {`;
231
228
  if (Object.keys(declarations.component).length > 0) {
232
229
  code += `
233
230
  export interface GlobalComponents {
@@ -299,12 +296,12 @@ async function transformComponent(code, transformer2, s, ctx, sfcPath) {
299
296
  const results = transformer2 === "vue2" ? resolveVue2(code, s) : resolveVue3(code, s);
300
297
  for (const { rawName, replace } of results) {
301
298
  debug2(`| ${rawName}`);
302
- const name = _chunkUX65OJTHcjs.pascalCase.call(void 0, rawName);
299
+ const name = _chunk5QHU6UOYcjs.pascalCase.call(void 0, rawName);
303
300
  ctx.updateUsageMap(sfcPath, [name]);
304
301
  const component = await ctx.findComponent(name, "component", [sfcPath]);
305
302
  if (component) {
306
303
  const varName = `__unplugin_components_${no}`;
307
- s.prepend(`${_chunkUX65OJTHcjs.stringifyComponentImport.call(void 0, _chunkWJIU4Q36cjs.__spreadProps.call(void 0, _chunkWJIU4Q36cjs.__spreadValues.call(void 0, {}, component), { as: varName }), ctx)};
304
+ s.prepend(`${_chunk5QHU6UOYcjs.stringifyComponentImport.call(void 0, _chunkWJIU4Q36cjs.__spreadProps.call(void 0, _chunkWJIU4Q36cjs.__spreadValues.call(void 0, {}, component), { as: varName }), ctx)};
308
305
  `);
309
306
  no += 1;
310
307
  replace(varName);
@@ -409,13 +406,13 @@ async function transformDirective(code, transformer2, s, ctx, sfcPath) {
409
406
  const results = await (transformer2 === "vue2" ? resolveVue22(code, s) : resolveVue32(code, s));
410
407
  for (const { rawName, replace } of results) {
411
408
  debug3(`| ${rawName}`);
412
- const name = `${_chunkUX65OJTHcjs.DIRECTIVE_IMPORT_PREFIX}${_chunkUX65OJTHcjs.pascalCase.call(void 0, rawName)}`;
409
+ const name = `${_chunk5QHU6UOYcjs.DIRECTIVE_IMPORT_PREFIX}${_chunk5QHU6UOYcjs.pascalCase.call(void 0, rawName)}`;
413
410
  ctx.updateUsageMap(sfcPath, [name]);
414
411
  const directive = await ctx.findComponent(name, "directive", [sfcPath]);
415
412
  if (!directive)
416
413
  continue;
417
414
  const varName = `__unplugin_directives_${no}`;
418
- s.prepend(`${_chunkUX65OJTHcjs.stringifyComponentImport.call(void 0, _chunkWJIU4Q36cjs.__spreadProps.call(void 0, _chunkWJIU4Q36cjs.__spreadValues.call(void 0, {}, directive), { as: varName }), ctx)};
415
+ s.prepend(`${_chunk5QHU6UOYcjs.stringifyComponentImport.call(void 0, _chunkWJIU4Q36cjs.__spreadProps.call(void 0, _chunkWJIU4Q36cjs.__spreadValues.call(void 0, {}, directive), { as: varName }), ctx)};
419
416
  `);
420
417
  no += 1;
421
418
  replace(varName);
@@ -434,7 +431,7 @@ function transformer(ctx, transformer2) {
434
431
  await transformComponent(code, transformer2, s, ctx, sfcPath);
435
432
  if (ctx.options.directives)
436
433
  await transformDirective(code, transformer2, s, ctx, sfcPath);
437
- s.prepend(_chunkUX65OJTHcjs.DISABLE_COMMENT);
434
+ s.prepend(_chunk5QHU6UOYcjs.DISABLE_COMMENT);
438
435
  const result = { code: s.toString() };
439
436
  if (ctx.sourcemap)
440
437
  result.map = s.generateMap({ source: id, includeContent: true, hires: "boundary" });
@@ -479,7 +476,7 @@ var Context = class {
479
476
  this.transformer = transformer(this, name || "vue3");
480
477
  }
481
478
  transform(code, id) {
482
- const { path, query } = _chunkUX65OJTHcjs.parseId.call(void 0, id);
479
+ const { path, query } = _chunk5QHU6UOYcjs.parseId.call(void 0, id);
483
480
  return this.transformer(code, id, path, query);
484
481
  }
485
482
  setupViteServer(server) {
@@ -491,14 +488,14 @@ var Context = class {
491
488
  setupWatcher(watcher) {
492
489
  const { globs } = this.options;
493
490
  watcher.on("unlink", (path) => {
494
- if (!_chunkUX65OJTHcjs.matchGlobs.call(void 0, path, globs))
491
+ if (!_chunk5QHU6UOYcjs.matchGlobs.call(void 0, path, globs))
495
492
  return;
496
493
  path = _utils.slash.call(void 0, path);
497
494
  this.removeComponents(path);
498
495
  this.onUpdate(path);
499
496
  });
500
497
  watcher.on("add", (path) => {
501
- if (!_chunkUX65OJTHcjs.matchGlobs.call(void 0, path, globs))
498
+ if (!_chunk5QHU6UOYcjs.matchGlobs.call(void 0, path, globs))
502
499
  return;
503
500
  path = _utils.slash.call(void 0, path);
504
501
  this.addComponents(path);
@@ -511,14 +508,14 @@ var Context = class {
511
508
  setupWatcherWebpack(watcher, emitUpdate) {
512
509
  const { globs } = this.options;
513
510
  watcher.on("unlink", (path) => {
514
- if (!_chunkUX65OJTHcjs.matchGlobs.call(void 0, path, globs))
511
+ if (!_chunk5QHU6UOYcjs.matchGlobs.call(void 0, path, globs))
515
512
  return;
516
513
  path = _utils.slash.call(void 0, path);
517
514
  this.removeComponents(path);
518
515
  emitUpdate(path, "unlink");
519
516
  });
520
517
  watcher.on("add", (path) => {
521
- if (!_chunkUX65OJTHcjs.matchGlobs.call(void 0, path, globs))
518
+ if (!_chunk5QHU6UOYcjs.matchGlobs.call(void 0, path, globs))
522
519
  return;
523
520
  path = _utils.slash.call(void 0, path);
524
521
  this.addComponents(path);
@@ -574,7 +571,7 @@ var Context = class {
574
571
  updates: []
575
572
  };
576
573
  const timestamp = +/* @__PURE__ */ new Date();
577
- const name = _chunkUX65OJTHcjs.pascalCase.call(void 0, _chunkUX65OJTHcjs.getNameFromFilePath.call(void 0, path, this.options));
574
+ const name = _chunk5QHU6UOYcjs.pascalCase.call(void 0, _chunk5QHU6UOYcjs.getNameFromFilePath.call(void 0, path, this.options));
578
575
  Object.entries(this._componentUsageMap).forEach(([key, values]) => {
579
576
  if (values.has(name)) {
580
577
  const r = `/${_utils.slash.call(void 0, _path.relative.call(void 0, this.root, key))}`;
@@ -592,7 +589,7 @@ var Context = class {
592
589
  updateComponentNameMap() {
593
590
  this._componentNameMap = {};
594
591
  Array.from(this._componentPaths).forEach((path) => {
595
- const name = _chunkUX65OJTHcjs.pascalCase.call(void 0, _chunkUX65OJTHcjs.getNameFromFilePath.call(void 0, path, this.options));
592
+ const name = _chunk5QHU6UOYcjs.pascalCase.call(void 0, _chunk5QHU6UOYcjs.getNameFromFilePath.call(void 0, path, this.options));
596
593
  if (this._componentNameMap[name] && !this.options.allowOverrides) {
597
594
  console.warn(`[unplugin-vue-components] component "${name}"(${path}) has naming conflicts with other components, ignored.`);
598
595
  return;
@@ -610,7 +607,7 @@ var Context = class {
610
607
  for (const resolver of this.options.resolvers) {
611
608
  if (resolver.type !== type)
612
609
  continue;
613
- const result = await resolver.resolve(type === "directive" ? name.slice(_chunkUX65OJTHcjs.DIRECTIVE_IMPORT_PREFIX.length) : name);
610
+ const result = await resolver.resolve(type === "directive" ? name.slice(_chunk5QHU6UOYcjs.DIRECTIVE_IMPORT_PREFIX.length) : name);
614
611
  if (!result)
615
612
  continue;
616
613
  if (typeof result === "string") {
@@ -621,7 +618,7 @@ var Context = class {
621
618
  } else {
622
619
  info = _chunkWJIU4Q36cjs.__spreadValues.call(void 0, {
623
620
  as: name
624
- }, _chunkUX65OJTHcjs.normalizeComponentInfo.call(void 0, result));
621
+ }, _chunk5QHU6UOYcjs.normalizeComponentInfo.call(void 0, result));
625
622
  }
626
623
  if (type === "component")
627
624
  this.addCustomComponents(info);
@@ -633,7 +630,7 @@ var Context = class {
633
630
  }
634
631
  normalizePath(path) {
635
632
  var _a, _b, _c;
636
- return _chunkUX65OJTHcjs.resolveAlias.call(void 0, path, ((_b = (_a = this.viteConfig) == null ? void 0 : _a.resolve) == null ? void 0 : _b.alias) || ((_c = this.viteConfig) == null ? void 0 : _c.alias) || []);
633
+ return _chunk5QHU6UOYcjs.resolveAlias.call(void 0, path, ((_b = (_a = this.viteConfig) == null ? void 0 : _a.resolve) == null ? void 0 : _b.alias) || ((_c = this.viteConfig) == null ? void 0 : _c.alias) || []);
637
634
  }
638
635
  relative(path) {
639
636
  if (path.startsWith("/") && !path.startsWith(this.root))
@@ -682,7 +679,7 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
682
679
  return await ctx.findComponent(name, "component", filename ? [filename] : []);
683
680
  },
684
681
  stringifyImport(info) {
685
- return _chunkUX65OJTHcjs.stringifyComponentImport.call(void 0, info, ctx);
682
+ return _chunk5QHU6UOYcjs.stringifyComponentImport.call(void 0, info, ctx);
686
683
  }
687
684
  };
688
685
  return {
@@ -693,7 +690,7 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
693
690
  return filter(id);
694
691
  },
695
692
  async transform(code, id) {
696
- if (!_chunkUX65OJTHcjs.shouldTransform.call(void 0, code))
693
+ if (!_chunk5QHU6UOYcjs.shouldTransform.call(void 0, code))
697
694
  return null;
698
695
  try {
699
696
  const result = await ctx.transform(code, id);
@@ -122,17 +122,18 @@ function getNameFromFilePath(filePath, options) {
122
122
  for (const fileOrFolderName of namespaced) {
123
123
  let cumulativePrefix = "";
124
124
  let didCollapse = false;
125
+ const pascalCasedName = pascalCase(fileOrFolderName);
125
126
  for (const parentFolder of [...collapsed].reverse()) {
126
- cumulativePrefix = `${capitalize(parentFolder)}${cumulativePrefix}`;
127
- if (pascalCase(fileOrFolderName).startsWith(pascalCase(cumulativePrefix))) {
128
- const collapseSamePrefix = fileOrFolderName.slice(cumulativePrefix.length);
127
+ cumulativePrefix = `${parentFolder}${cumulativePrefix}`;
128
+ if (pascalCasedName.startsWith(cumulativePrefix)) {
129
+ const collapseSamePrefix = pascalCasedName.slice(cumulativePrefix.length);
129
130
  collapsed.push(collapseSamePrefix);
130
131
  didCollapse = true;
131
132
  break;
132
133
  }
133
134
  }
134
135
  if (!didCollapse)
135
- collapsed.push(fileOrFolderName);
136
+ collapsed.push(pascalCasedName);
136
137
  }
137
138
  namespaced = collapsed;
138
139
  }
@@ -10,7 +10,7 @@ import {
10
10
  resolveAlias,
11
11
  shouldTransform,
12
12
  stringifyComponentImport
13
- } from "./chunk-WRE7G5OD.js";
13
+ } from "./chunk-SQHKCPM6.js";
14
14
  import {
15
15
  __spreadProps,
16
16
  __spreadValues
@@ -217,17 +217,14 @@ function getDeclaration(ctx, filepath, originalImports) {
217
217
  component: stringifyDeclarationImports(__spreadValues(__spreadValues({}, originalImports == null ? void 0 : originalImports.component), imports.component)),
218
218
  directive: stringifyDeclarationImports(__spreadValues(__spreadValues({}, originalImports == null ? void 0 : originalImports.directive), imports.directive))
219
219
  };
220
- const head = ctx.options.version === 2.7 ? `export {}
221
-
222
- declare module 'vue' {` : `export {}
223
-
224
- declare module 'vue' {`;
225
220
  let code = `/* eslint-disable */
226
- /* prettier-ignore */
227
221
  // @ts-nocheck
228
222
  // Generated by unplugin-vue-components
229
223
  // Read more: https://github.com/vuejs/core/pull/3399
230
- ${head}`;
224
+ export {}
225
+
226
+ /* prettier-ignore */
227
+ declare module 'vue' {`;
231
228
  if (Object.keys(declarations.component).length > 0) {
232
229
  code += `
233
230
  export interface GlobalComponents {
package/dist/esbuild.cjs CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkGNWVEWZXcjs = require('./chunk-GNWVEWZX.cjs');
4
- require('./chunk-UX65OJTH.cjs');
3
+ var _chunkJGIUAMWPcjs = require('./chunk-JGIUAMWP.cjs');
4
+ require('./chunk-5QHU6UOY.cjs');
5
5
  require('./chunk-WJIU4Q36.cjs');
6
6
  require('./chunk-ZBPRDZS4.cjs');
7
7
 
8
8
  // src/esbuild.ts
9
- var esbuild_default = _chunkGNWVEWZXcjs.unplugin_default.esbuild;
9
+ var esbuild_default = _chunkJGIUAMWPcjs.unplugin_default.esbuild;
10
10
 
11
11
 
12
12
  exports.default = esbuild_default;
package/dist/esbuild.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-LAHXDHMT.js";
4
- import "./chunk-WRE7G5OD.js";
3
+ } from "./chunk-TSU3OFN5.js";
4
+ import "./chunk-SQHKCPM6.js";
5
5
  import "./chunk-5JVO2UWC.js";
6
6
  import "./chunk-6F4PWJZI.js";
7
7
 
package/dist/index.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkGNWVEWZXcjs = require('./chunk-GNWVEWZX.cjs');
3
+ var _chunkJGIUAMWPcjs = require('./chunk-JGIUAMWP.cjs');
4
4
 
5
5
 
6
6
 
7
7
 
8
- var _chunkUX65OJTHcjs = require('./chunk-UX65OJTH.cjs');
8
+ var _chunk5QHU6UOYcjs = require('./chunk-5QHU6UOY.cjs');
9
9
  require('./chunk-WJIU4Q36.cjs');
10
10
  require('./chunk-ZBPRDZS4.cjs');
11
11
 
@@ -13,4 +13,4 @@ require('./chunk-ZBPRDZS4.cjs');
13
13
 
14
14
 
15
15
 
16
- exports.camelCase = _chunkUX65OJTHcjs.camelCase; exports.default = _chunkGNWVEWZXcjs.unplugin_default; exports.kebabCase = _chunkUX65OJTHcjs.kebabCase; exports.pascalCase = _chunkUX65OJTHcjs.pascalCase;
16
+ exports.camelCase = _chunk5QHU6UOYcjs.camelCase; exports.default = _chunkJGIUAMWPcjs.unplugin_default; exports.kebabCase = _chunk5QHU6UOYcjs.kebabCase; exports.pascalCase = _chunk5QHU6UOYcjs.pascalCase;
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-LAHXDHMT.js";
3
+ } from "./chunk-TSU3OFN5.js";
4
4
  import {
5
5
  camelCase,
6
6
  kebabCase,
7
7
  pascalCase
8
- } from "./chunk-WRE7G5OD.js";
8
+ } from "./chunk-SQHKCPM6.js";
9
9
  import "./chunk-5JVO2UWC.js";
10
10
  import "./chunk-6F4PWJZI.js";
11
11
  export {
package/dist/nuxt.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkGNWVEWZXcjs = require('./chunk-GNWVEWZX.cjs');
4
- require('./chunk-UX65OJTH.cjs');
3
+ var _chunkJGIUAMWPcjs = require('./chunk-JGIUAMWP.cjs');
4
+ require('./chunk-5QHU6UOY.cjs');
5
5
  require('./chunk-WJIU4Q36.cjs');
6
6
  require('./chunk-ZBPRDZS4.cjs');
7
7
 
@@ -9,8 +9,8 @@ require('./chunk-ZBPRDZS4.cjs');
9
9
  var _kit = require('@nuxt/kit');
10
10
  var nuxt_default = _kit.defineNuxtModule.call(void 0, {
11
11
  setup(options) {
12
- _kit.addWebpackPlugin.call(void 0, _chunkGNWVEWZXcjs.unplugin_default.webpack(options));
13
- _kit.addVitePlugin.call(void 0, _chunkGNWVEWZXcjs.unplugin_default.vite(options));
12
+ _kit.addWebpackPlugin.call(void 0, _chunkJGIUAMWPcjs.unplugin_default.webpack(options));
13
+ _kit.addVitePlugin.call(void 0, _chunkJGIUAMWPcjs.unplugin_default.vite(options));
14
14
  }
15
15
  });
16
16
 
package/dist/nuxt.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-LAHXDHMT.js";
4
- import "./chunk-WRE7G5OD.js";
3
+ } from "./chunk-TSU3OFN5.js";
4
+ import "./chunk-SQHKCPM6.js";
5
5
  import "./chunk-5JVO2UWC.js";
6
6
  import "./chunk-6F4PWJZI.js";
7
7