unplugin-vue-components 0.19.3 → 0.19.9
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 +10 -4
- package/dist/{chunk-TMX2H7L5.js → chunk-EUNTLVSW.js} +18 -5
- package/dist/{chunk-OUA4VSFE.js → chunk-MF6CXARB.js} +60 -21
- package/dist/{chunk-JIADFQ53.mjs → chunk-W7GE2GWI.mjs} +17 -4
- package/dist/{chunk-3RUG44IF.mjs → chunk-ZE7BF7UU.mjs} +41 -2
- package/dist/esbuild.js +3 -3
- package/dist/esbuild.mjs +2 -2
- package/dist/index.js +3 -3
- package/dist/index.mjs +2 -2
- package/dist/nuxt.js +4 -4
- package/dist/nuxt.mjs +2 -2
- package/dist/resolvers.d.ts +43 -2
- package/dist/resolvers.js +200 -44
- package/dist/resolvers.mjs +177 -21
- package/dist/rollup.js +3 -3
- package/dist/rollup.mjs +2 -2
- package/dist/types.d.ts +11 -2
- package/dist/vite.js +3 -3
- package/dist/vite.mjs +2 -2
- package/dist/webpack.js +3 -3
- package/dist/webpack.mjs +2 -2
- package/package.json +38 -39
package/README.md
CHANGED
|
@@ -166,7 +166,7 @@ export default {
|
|
|
166
166
|
|
|
167
167
|
## TypeScript
|
|
168
168
|
|
|
169
|
-
To get TypeScript support for auto-imported components, there is [a PR](https://github.com/vuejs/
|
|
169
|
+
To get TypeScript support for auto-imported components, there is [a PR](https://github.com/vuejs/core/pull/3399) to Vue 3 extending the interface of global components. Currently, [Volar](https://github.com/johnsoncodehk/volar) has supported this usage already. If you are using Volar, you can change the config as following to get the support.
|
|
170
170
|
|
|
171
171
|
```ts
|
|
172
172
|
Components({
|
|
@@ -176,7 +176,7 @@ Components({
|
|
|
176
176
|
|
|
177
177
|
Once the setup is done, a `components.d.ts` will be generated and updates automatically with the type definitions. Feel free to commit it into git or not as you want.
|
|
178
178
|
|
|
179
|
-
**Make sure you also add `components.d.ts` to your `tsconfig.json` under `includes`.**
|
|
179
|
+
> **Make sure you also add `components.d.ts` to your `tsconfig.json` under `includes`.**
|
|
180
180
|
|
|
181
181
|
## Importing from UI Libraries
|
|
182
182
|
|
|
@@ -256,7 +256,7 @@ Components({
|
|
|
256
256
|
|
|
257
257
|
So the `RouterLink` and `RouterView` will be presented in `components.d.ts`.
|
|
258
258
|
|
|
259
|
-
By default, `unplugin-vue-components` detects supported libraries automatically (e.g. `vue-router`) when
|
|
259
|
+
By default, `unplugin-vue-components` detects supported libraries automatically (e.g. `vue-router`) when they are installed in the workspace. If you want to disable it completely, you can pass an empty array to it:
|
|
260
260
|
|
|
261
261
|
```ts
|
|
262
262
|
Components({
|
|
@@ -342,6 +342,12 @@ Components({
|
|
|
342
342
|
// To install Babel, run: `npm install -D @babel/parser @babel/traverse`
|
|
343
343
|
directives: true,
|
|
344
344
|
|
|
345
|
+
// Transform path before resolving
|
|
346
|
+
importPathTransform: v => v,
|
|
347
|
+
|
|
348
|
+
// Allow for components to override other components with the same name
|
|
349
|
+
allowOverrides: false,
|
|
350
|
+
|
|
345
351
|
// filters for transforming targets
|
|
346
352
|
include: [/\.vue$/, /\.vue\?vue/],
|
|
347
353
|
exclude: [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/],
|
|
@@ -350,7 +356,7 @@ Components({
|
|
|
350
356
|
|
|
351
357
|
## Example
|
|
352
358
|
|
|
353
|
-
|
|
359
|
+
[Vitesse](https://github.com/antfu/vitesse) starter template.
|
|
354
360
|
|
|
355
361
|
## Thanks
|
|
356
362
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -117,7 +117,7 @@ function stringifyComponentImport({ as: name, from: path, name: importName, side
|
|
|
117
117
|
return imports.join(";");
|
|
118
118
|
}
|
|
119
119
|
function getNameFromFilePath(filePath, options) {
|
|
120
|
-
const { resolvedDirs, directoryAsNamespace, globalNamespaces } = options;
|
|
120
|
+
const { resolvedDirs, directoryAsNamespace, globalNamespaces, collapseSamePrefixes } = options;
|
|
121
121
|
const parsedFilePath = _path.parse.call(void 0, _utils.slash.call(void 0, filePath));
|
|
122
122
|
let strippedPath = "";
|
|
123
123
|
for (const dir of resolvedDirs) {
|
|
@@ -138,7 +138,21 @@ function getNameFromFilePath(filePath, options) {
|
|
|
138
138
|
if (filename.toLowerCase() === "index")
|
|
139
139
|
filename = "";
|
|
140
140
|
if (!isEmpty(folders)) {
|
|
141
|
-
|
|
141
|
+
let namespaced = [...folders, filename];
|
|
142
|
+
if (collapseSamePrefixes) {
|
|
143
|
+
const collapsed = [];
|
|
144
|
+
for (const fileOrFolderName of namespaced) {
|
|
145
|
+
const collapsedFilename = collapsed.join("");
|
|
146
|
+
if (collapsedFilename && fileOrFolderName.toLowerCase().startsWith(collapsedFilename.toLowerCase())) {
|
|
147
|
+
const collapseSamePrefix = fileOrFolderName.slice(collapsedFilename.length);
|
|
148
|
+
collapsed.push(collapseSamePrefix);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
collapsed.push(fileOrFolderName);
|
|
152
|
+
}
|
|
153
|
+
namespaced = collapsed;
|
|
154
|
+
}
|
|
155
|
+
filename = namespaced.filter(Boolean).join("-");
|
|
142
156
|
}
|
|
143
157
|
return filename;
|
|
144
158
|
}
|
|
@@ -153,12 +167,11 @@ function resolveAlias(filepath, alias) {
|
|
|
153
167
|
return result;
|
|
154
168
|
}
|
|
155
169
|
async function getPkgVersion(pkgName, defaultVersion) {
|
|
156
|
-
var _a;
|
|
157
170
|
try {
|
|
158
171
|
const isExist = _localpkg.isPackageExists.call(void 0, pkgName);
|
|
159
172
|
if (isExist) {
|
|
160
173
|
const pkg = await _localpkg.getPackageInfo.call(void 0, pkgName);
|
|
161
|
-
return (
|
|
174
|
+
return _nullishCoalesce((pkg == null ? void 0 : pkg.version), () => ( defaultVersion));
|
|
162
175
|
} else {
|
|
163
176
|
return defaultVersion;
|
|
164
177
|
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkEUNTLVSWjs = require('./chunk-EUNTLVSW.js');
|
|
16
16
|
|
|
17
17
|
// src/core/unplugin.ts
|
|
18
18
|
var _unplugin = require('unplugin');
|
|
@@ -101,7 +101,7 @@ function resolveOptions(options, root) {
|
|
|
101
101
|
function getVueVersion() {
|
|
102
102
|
var _a;
|
|
103
103
|
try {
|
|
104
|
-
const vue =
|
|
104
|
+
const vue = _chunkEUNTLVSWjs.__require.call(void 0, "vue");
|
|
105
105
|
const version = ((_a = vue == null ? void 0 : vue.default) == null ? void 0 : _a.version) || (vue == null ? void 0 : vue.version) || "3";
|
|
106
106
|
return version.startsWith("2.") ? "vue2" : "vue3";
|
|
107
107
|
} catch (e2) {
|
|
@@ -140,13 +140,13 @@ function parseDeclaration(code) {
|
|
|
140
140
|
}
|
|
141
141
|
async function generateDeclaration(ctx, root, filepath, removeUnused = false) {
|
|
142
142
|
const items = [
|
|
143
|
-
...Object.values(
|
|
143
|
+
...Object.values(_chunkEUNTLVSWjs.__spreadValues.call(void 0, _chunkEUNTLVSWjs.__spreadValues.call(void 0, {}, ctx.componentNameMap), ctx.componentCustomMap)),
|
|
144
144
|
...resolveTypeImports(ctx.options.types)
|
|
145
145
|
];
|
|
146
146
|
const imports = Object.fromEntries(items.map(({ from: path, as: name, name: importName }) => {
|
|
147
147
|
if (!name)
|
|
148
148
|
return void 0;
|
|
149
|
-
path =
|
|
149
|
+
path = _chunkEUNTLVSWjs.getTransformedPath.call(void 0, path, ctx);
|
|
150
150
|
const related = _path.isAbsolute.call(void 0, path) ? `./${_path.relative.call(void 0, _path.dirname.call(void 0, filepath), path)}` : path;
|
|
151
151
|
let entry = `typeof import('${_utils.slash.call(void 0, related)}')`;
|
|
152
152
|
if (importName)
|
|
@@ -159,14 +159,14 @@ async function generateDeclaration(ctx, root, filepath, removeUnused = false) {
|
|
|
159
159
|
return;
|
|
160
160
|
const originalContent = _fs.existsSync.call(void 0, filepath) ? await _fs.promises.readFile(filepath, "utf-8") : "";
|
|
161
161
|
const originalImports = parseDeclaration(originalContent);
|
|
162
|
-
const lines = Object.entries(
|
|
162
|
+
const lines = Object.entries(_chunkEUNTLVSWjs.__spreadValues.call(void 0, _chunkEUNTLVSWjs.__spreadValues.call(void 0, {}, originalImports), imports)).sort((a, b) => a[0].localeCompare(b[0])).filter(([name]) => removeUnused ? items.find((i) => i.as === name) : true).map(([name, v]) => {
|
|
163
163
|
if (!/^\w+$/.test(name))
|
|
164
164
|
name = `'${name}'`;
|
|
165
165
|
return `${name}: ${v}`;
|
|
166
166
|
});
|
|
167
167
|
const code = `// generated by unplugin-vue-components
|
|
168
168
|
// We suggest you to commit this file into source control
|
|
169
|
-
// Read more: https://github.com/vuejs/
|
|
169
|
+
// Read more: https://github.com/vuejs/core/pull/3399
|
|
170
170
|
import '@vue/runtime-core'
|
|
171
171
|
|
|
172
172
|
declare module '@vue/runtime-core' {
|
|
@@ -223,12 +223,12 @@ async function transformComponent(code, transformer2, s, ctx, sfcPath) {
|
|
|
223
223
|
const results = transformer2 === "vue2" ? resolveVue2(code, s) : resolveVue3(code, s);
|
|
224
224
|
for (const { rawName, replace } of results) {
|
|
225
225
|
debug2(`| ${rawName}`);
|
|
226
|
-
const name =
|
|
226
|
+
const name = _chunkEUNTLVSWjs.pascalCase.call(void 0, rawName);
|
|
227
227
|
ctx.updateUsageMap(sfcPath, [name]);
|
|
228
228
|
const component = await ctx.findComponent(name, "component", [sfcPath]);
|
|
229
229
|
if (component) {
|
|
230
230
|
const varName = `__unplugin_components_${no}`;
|
|
231
|
-
s.prepend(`${
|
|
231
|
+
s.prepend(`${_chunkEUNTLVSWjs.stringifyComponentImport.call(void 0, _chunkEUNTLVSWjs.__spreadProps.call(void 0, _chunkEUNTLVSWjs.__spreadValues.call(void 0, {}, component), { as: varName }), ctx)};
|
|
232
232
|
`);
|
|
233
233
|
no += 1;
|
|
234
234
|
replace(varName);
|
|
@@ -318,13 +318,13 @@ async function transformDirective(code, transformer2, s, ctx, sfcPath) {
|
|
|
318
318
|
const results = await (transformer2 === "vue2" ? resolveVue22(code, s) : resolveVue32(code, s));
|
|
319
319
|
for (const { rawName, replace } of results) {
|
|
320
320
|
debug3(`| ${rawName}`);
|
|
321
|
-
const name =
|
|
321
|
+
const name = _chunkEUNTLVSWjs.pascalCase.call(void 0, rawName);
|
|
322
322
|
ctx.updateUsageMap(sfcPath, [name]);
|
|
323
323
|
const directive = await ctx.findComponent(name, "directive", [sfcPath]);
|
|
324
324
|
if (!directive)
|
|
325
325
|
continue;
|
|
326
326
|
const varName = `__unplugin_directives_${no}`;
|
|
327
|
-
s.prepend(`${
|
|
327
|
+
s.prepend(`${_chunkEUNTLVSWjs.stringifyComponentImport.call(void 0, _chunkEUNTLVSWjs.__spreadProps.call(void 0, _chunkEUNTLVSWjs.__spreadValues.call(void 0, {}, directive), { as: varName }), ctx)};
|
|
328
328
|
`);
|
|
329
329
|
no += 1;
|
|
330
330
|
replace(varName);
|
|
@@ -343,7 +343,7 @@ function transformer(ctx, transformer2) {
|
|
|
343
343
|
await transformComponent(code, transformer2, s, ctx, sfcPath);
|
|
344
344
|
if (ctx.options.directives)
|
|
345
345
|
await transformDirective(code, transformer2, s, ctx, sfcPath);
|
|
346
|
-
s.prepend(
|
|
346
|
+
s.prepend(_chunkEUNTLVSWjs.DISABLE_COMMENT);
|
|
347
347
|
const result = { code: s.toString() };
|
|
348
348
|
if (ctx.sourcemap)
|
|
349
349
|
result.map = s.generateMap({ source: id, includeContent: true });
|
|
@@ -387,7 +387,7 @@ var Context = class {
|
|
|
387
387
|
this.transformer = transformer(this, name || "vue3");
|
|
388
388
|
}
|
|
389
389
|
transform(code, id) {
|
|
390
|
-
const { path, query } =
|
|
390
|
+
const { path, query } = _chunkEUNTLVSWjs.parseId.call(void 0, id);
|
|
391
391
|
return this.transformer(code, id, path, query);
|
|
392
392
|
}
|
|
393
393
|
setupViteServer(server) {
|
|
@@ -399,20 +399,37 @@ var Context = class {
|
|
|
399
399
|
setupWatcher(watcher) {
|
|
400
400
|
const { globs } = this.options;
|
|
401
401
|
watcher.on("unlink", (path) => {
|
|
402
|
-
if (!
|
|
402
|
+
if (!_chunkEUNTLVSWjs.matchGlobs.call(void 0, path, globs))
|
|
403
403
|
return;
|
|
404
404
|
path = _utils.slash.call(void 0, path);
|
|
405
405
|
this.removeComponents(path);
|
|
406
406
|
this.onUpdate(path);
|
|
407
407
|
});
|
|
408
408
|
watcher.on("add", (path) => {
|
|
409
|
-
if (!
|
|
409
|
+
if (!_chunkEUNTLVSWjs.matchGlobs.call(void 0, path, globs))
|
|
410
410
|
return;
|
|
411
411
|
path = _utils.slash.call(void 0, path);
|
|
412
412
|
this.addComponents(path);
|
|
413
413
|
this.onUpdate(path);
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
|
+
setupWatcherWebpack(watcher, emitUpdate) {
|
|
417
|
+
const { globs } = this.options;
|
|
418
|
+
watcher.on("unlink", (path) => {
|
|
419
|
+
if (!_chunkEUNTLVSWjs.matchGlobs.call(void 0, path, globs))
|
|
420
|
+
return;
|
|
421
|
+
path = _utils.slash.call(void 0, path);
|
|
422
|
+
this.removeComponents(path);
|
|
423
|
+
emitUpdate(path, "unlink");
|
|
424
|
+
});
|
|
425
|
+
watcher.on("add", (path) => {
|
|
426
|
+
if (!_chunkEUNTLVSWjs.matchGlobs.call(void 0, path, globs))
|
|
427
|
+
return;
|
|
428
|
+
path = _utils.slash.call(void 0, path);
|
|
429
|
+
this.addComponents(path);
|
|
430
|
+
emitUpdate(path, "add");
|
|
431
|
+
});
|
|
432
|
+
}
|
|
416
433
|
updateUsageMap(path, paths) {
|
|
417
434
|
if (!this._componentUsageMap[path])
|
|
418
435
|
this._componentUsageMap[path] = /* @__PURE__ */ new Set();
|
|
@@ -453,7 +470,7 @@ var Context = class {
|
|
|
453
470
|
updates: []
|
|
454
471
|
};
|
|
455
472
|
const timestamp = +new Date();
|
|
456
|
-
const name =
|
|
473
|
+
const name = _chunkEUNTLVSWjs.pascalCase.call(void 0, _chunkEUNTLVSWjs.getNameFromFilePath.call(void 0, path, this.options));
|
|
457
474
|
Object.entries(this._componentUsageMap).forEach(([key, values]) => {
|
|
458
475
|
if (values.has(name)) {
|
|
459
476
|
const r = `/${_utils.slash.call(void 0, _path.relative.call(void 0, this.root, key))}`;
|
|
@@ -471,7 +488,7 @@ var Context = class {
|
|
|
471
488
|
updateComponentNameMap() {
|
|
472
489
|
this._componentNameMap = {};
|
|
473
490
|
Array.from(this._componentPaths).forEach((path) => {
|
|
474
|
-
const name =
|
|
491
|
+
const name = _chunkEUNTLVSWjs.pascalCase.call(void 0, _chunkEUNTLVSWjs.getNameFromFilePath.call(void 0, path, this.options));
|
|
475
492
|
if (this._componentNameMap[name] && !this.options.allowOverrides) {
|
|
476
493
|
console.warn(`[unplugin-vue-components] component "${name}"(${path}) has naming conflicts with other components, ignored.`);
|
|
477
494
|
return;
|
|
@@ -499,9 +516,9 @@ var Context = class {
|
|
|
499
516
|
this.addCustomComponents(info);
|
|
500
517
|
return info;
|
|
501
518
|
} else {
|
|
502
|
-
info =
|
|
519
|
+
info = _chunkEUNTLVSWjs.__spreadValues.call(void 0, {
|
|
503
520
|
as: name
|
|
504
|
-
},
|
|
521
|
+
}, _chunkEUNTLVSWjs.normalizeComponetInfo.call(void 0, result));
|
|
505
522
|
this.addCustomComponents(info);
|
|
506
523
|
return info;
|
|
507
524
|
}
|
|
@@ -511,7 +528,7 @@ var Context = class {
|
|
|
511
528
|
}
|
|
512
529
|
normalizePath(path) {
|
|
513
530
|
var _a, _b, _c;
|
|
514
|
-
return
|
|
531
|
+
return _chunkEUNTLVSWjs.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) || []);
|
|
515
532
|
}
|
|
516
533
|
relative(path) {
|
|
517
534
|
if (path.startsWith("/") && !path.startsWith(this.root))
|
|
@@ -548,7 +565,7 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
|
|
|
548
565
|
return await ctx.findComponent(name, "component", filename ? [filename] : []);
|
|
549
566
|
},
|
|
550
567
|
stringifyImport(info) {
|
|
551
|
-
return
|
|
568
|
+
return _chunkEUNTLVSWjs.stringifyComponentImport.call(void 0, info, ctx);
|
|
552
569
|
}
|
|
553
570
|
};
|
|
554
571
|
return {
|
|
@@ -559,7 +576,7 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
|
|
|
559
576
|
return filter(id);
|
|
560
577
|
},
|
|
561
578
|
async transform(code, id) {
|
|
562
|
-
if (!
|
|
579
|
+
if (!_chunkEUNTLVSWjs.shouldTransform.call(void 0, code))
|
|
563
580
|
return null;
|
|
564
581
|
try {
|
|
565
582
|
const result = await ctx.transform(code, id);
|
|
@@ -585,6 +602,28 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
|
|
|
585
602
|
configureServer(server) {
|
|
586
603
|
ctx.setupViteServer(server);
|
|
587
604
|
}
|
|
605
|
+
},
|
|
606
|
+
webpack(compiler) {
|
|
607
|
+
if (compiler.options.mode !== "development")
|
|
608
|
+
return;
|
|
609
|
+
let fileDepQueue = [];
|
|
610
|
+
ctx.setupWatcherWebpack(_chokidar2.default.watch(ctx.options.globs), (path, type) => {
|
|
611
|
+
fileDepQueue.push({ path, type });
|
|
612
|
+
process.nextTick(() => {
|
|
613
|
+
compiler.watching.invalidate();
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
compiler.hooks.compilation.tap("unplugin-vue-components", (compilation) => {
|
|
617
|
+
if (fileDepQueue.length) {
|
|
618
|
+
fileDepQueue.forEach(({ path, type }) => {
|
|
619
|
+
if (type === "unlink")
|
|
620
|
+
compilation.fileDependencies.delete(path);
|
|
621
|
+
else
|
|
622
|
+
compilation.fileDependencies.add(path);
|
|
623
|
+
});
|
|
624
|
+
fileDepQueue = [];
|
|
625
|
+
}
|
|
626
|
+
});
|
|
588
627
|
}
|
|
589
628
|
};
|
|
590
629
|
});
|
|
@@ -117,7 +117,7 @@ function stringifyComponentImport({ as: name, from: path, name: importName, side
|
|
|
117
117
|
return imports.join(";");
|
|
118
118
|
}
|
|
119
119
|
function getNameFromFilePath(filePath, options) {
|
|
120
|
-
const { resolvedDirs, directoryAsNamespace, globalNamespaces } = options;
|
|
120
|
+
const { resolvedDirs, directoryAsNamespace, globalNamespaces, collapseSamePrefixes } = options;
|
|
121
121
|
const parsedFilePath = parse(slash(filePath));
|
|
122
122
|
let strippedPath = "";
|
|
123
123
|
for (const dir of resolvedDirs) {
|
|
@@ -138,7 +138,21 @@ function getNameFromFilePath(filePath, options) {
|
|
|
138
138
|
if (filename.toLowerCase() === "index")
|
|
139
139
|
filename = "";
|
|
140
140
|
if (!isEmpty(folders)) {
|
|
141
|
-
|
|
141
|
+
let namespaced = [...folders, filename];
|
|
142
|
+
if (collapseSamePrefixes) {
|
|
143
|
+
const collapsed = [];
|
|
144
|
+
for (const fileOrFolderName of namespaced) {
|
|
145
|
+
const collapsedFilename = collapsed.join("");
|
|
146
|
+
if (collapsedFilename && fileOrFolderName.toLowerCase().startsWith(collapsedFilename.toLowerCase())) {
|
|
147
|
+
const collapseSamePrefix = fileOrFolderName.slice(collapsedFilename.length);
|
|
148
|
+
collapsed.push(collapseSamePrefix);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
collapsed.push(fileOrFolderName);
|
|
152
|
+
}
|
|
153
|
+
namespaced = collapsed;
|
|
154
|
+
}
|
|
155
|
+
filename = namespaced.filter(Boolean).join("-");
|
|
142
156
|
}
|
|
143
157
|
return filename;
|
|
144
158
|
}
|
|
@@ -153,12 +167,11 @@ function resolveAlias(filepath, alias) {
|
|
|
153
167
|
return result;
|
|
154
168
|
}
|
|
155
169
|
async function getPkgVersion(pkgName, defaultVersion) {
|
|
156
|
-
var _a;
|
|
157
170
|
try {
|
|
158
171
|
const isExist = isPackageExists(pkgName);
|
|
159
172
|
if (isExist) {
|
|
160
173
|
const pkg = await getPackageInfo(pkgName);
|
|
161
|
-
return (
|
|
174
|
+
return (pkg == null ? void 0 : pkg.version) ?? defaultVersion;
|
|
162
175
|
} else {
|
|
163
176
|
return defaultVersion;
|
|
164
177
|
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
resolveAlias,
|
|
13
13
|
shouldTransform,
|
|
14
14
|
stringifyComponentImport
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-W7GE2GWI.mjs";
|
|
16
16
|
|
|
17
17
|
// src/core/unplugin.ts
|
|
18
18
|
import { createUnplugin } from "unplugin";
|
|
@@ -166,7 +166,7 @@ async function generateDeclaration(ctx, root, filepath, removeUnused = false) {
|
|
|
166
166
|
});
|
|
167
167
|
const code = `// generated by unplugin-vue-components
|
|
168
168
|
// We suggest you to commit this file into source control
|
|
169
|
-
// Read more: https://github.com/vuejs/
|
|
169
|
+
// Read more: https://github.com/vuejs/core/pull/3399
|
|
170
170
|
import '@vue/runtime-core'
|
|
171
171
|
|
|
172
172
|
declare module '@vue/runtime-core' {
|
|
@@ -413,6 +413,23 @@ var Context = class {
|
|
|
413
413
|
this.onUpdate(path);
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
|
+
setupWatcherWebpack(watcher, emitUpdate) {
|
|
417
|
+
const { globs } = this.options;
|
|
418
|
+
watcher.on("unlink", (path) => {
|
|
419
|
+
if (!matchGlobs(path, globs))
|
|
420
|
+
return;
|
|
421
|
+
path = slash3(path);
|
|
422
|
+
this.removeComponents(path);
|
|
423
|
+
emitUpdate(path, "unlink");
|
|
424
|
+
});
|
|
425
|
+
watcher.on("add", (path) => {
|
|
426
|
+
if (!matchGlobs(path, globs))
|
|
427
|
+
return;
|
|
428
|
+
path = slash3(path);
|
|
429
|
+
this.addComponents(path);
|
|
430
|
+
emitUpdate(path, "add");
|
|
431
|
+
});
|
|
432
|
+
}
|
|
416
433
|
updateUsageMap(path, paths) {
|
|
417
434
|
if (!this._componentUsageMap[path])
|
|
418
435
|
this._componentUsageMap[path] = /* @__PURE__ */ new Set();
|
|
@@ -585,6 +602,28 @@ var unplugin_default = createUnplugin((options = {}) => {
|
|
|
585
602
|
configureServer(server) {
|
|
586
603
|
ctx.setupViteServer(server);
|
|
587
604
|
}
|
|
605
|
+
},
|
|
606
|
+
webpack(compiler) {
|
|
607
|
+
if (compiler.options.mode !== "development")
|
|
608
|
+
return;
|
|
609
|
+
let fileDepQueue = [];
|
|
610
|
+
ctx.setupWatcherWebpack(chokidar.watch(ctx.options.globs), (path, type) => {
|
|
611
|
+
fileDepQueue.push({ path, type });
|
|
612
|
+
process.nextTick(() => {
|
|
613
|
+
compiler.watching.invalidate();
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
compiler.hooks.compilation.tap("unplugin-vue-components", (compilation) => {
|
|
617
|
+
if (fileDepQueue.length) {
|
|
618
|
+
fileDepQueue.forEach(({ path, type }) => {
|
|
619
|
+
if (type === "unlink")
|
|
620
|
+
compilation.fileDependencies.delete(path);
|
|
621
|
+
else
|
|
622
|
+
compilation.fileDependencies.add(path);
|
|
623
|
+
});
|
|
624
|
+
fileDepQueue = [];
|
|
625
|
+
}
|
|
626
|
+
});
|
|
588
627
|
}
|
|
589
628
|
};
|
|
590
629
|
});
|
package/dist/esbuild.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunkMF6CXARBjs = require('./chunk-MF6CXARB.js');
|
|
4
|
+
require('./chunk-EUNTLVSW.js');
|
|
5
5
|
require('./chunk-6F4PWJZI.js');
|
|
6
6
|
|
|
7
7
|
// src/esbuild.ts
|
|
8
|
-
var esbuild_default =
|
|
8
|
+
var esbuild_default = _chunkMF6CXARBjs.unplugin_default.esbuild;
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
module.exports = esbuild_default;
|
package/dist/esbuild.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkMF6CXARBjs = require('./chunk-MF6CXARB.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkEUNTLVSWjs = require('./chunk-EUNTLVSW.js');
|
|
9
9
|
require('./chunk-6F4PWJZI.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
exports.camelCase =
|
|
15
|
+
exports.camelCase = _chunkEUNTLVSWjs.camelCase; exports.default = _chunkMF6CXARBjs.unplugin_default; exports.kebabCase = _chunkEUNTLVSWjs.kebabCase; exports.pascalCase = _chunkEUNTLVSWjs.pascalCase;
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
unplugin_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZE7BF7UU.mjs";
|
|
4
4
|
import {
|
|
5
5
|
camelCase,
|
|
6
6
|
kebabCase,
|
|
7
7
|
pascalCase
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-W7GE2GWI.mjs";
|
|
9
9
|
import "./chunk-WBQAMGXK.mjs";
|
|
10
10
|
export {
|
|
11
11
|
camelCase,
|
package/dist/nuxt.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunkMF6CXARBjs = require('./chunk-MF6CXARB.js');
|
|
4
|
+
require('./chunk-EUNTLVSW.js');
|
|
5
5
|
require('./chunk-6F4PWJZI.js');
|
|
6
6
|
|
|
7
7
|
// src/nuxt.ts
|
|
8
8
|
function nuxt_default(options) {
|
|
9
9
|
this.extendBuild((config) => {
|
|
10
10
|
config.plugins = config.plugins || [];
|
|
11
|
-
config.plugins.unshift(
|
|
11
|
+
config.plugins.unshift(_chunkMF6CXARBjs.unplugin_default.webpack(options));
|
|
12
12
|
});
|
|
13
13
|
this.nuxt.hook("vite:extend", async (vite) => {
|
|
14
14
|
vite.config.plugins = vite.config.plugins || [];
|
|
15
|
-
vite.config.plugins.push(
|
|
15
|
+
vite.config.plugins.push(_chunkMF6CXARBjs.unplugin_default.vite(options));
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
|
package/dist/nuxt.mjs
CHANGED
package/dist/resolvers.d.ts
CHANGED
|
@@ -131,6 +131,12 @@ interface IduxResolverOptions {
|
|
|
131
131
|
* import style along with components
|
|
132
132
|
*/
|
|
133
133
|
importStyle?: 'css' | 'less';
|
|
134
|
+
/**
|
|
135
|
+
* theme for import style
|
|
136
|
+
*
|
|
137
|
+
* @default 'default'
|
|
138
|
+
*/
|
|
139
|
+
importStyleTheme?: string;
|
|
134
140
|
}
|
|
135
141
|
/**
|
|
136
142
|
* Resolver for `@idux/cdk`, `@idux/components` and ``@idux/pro``
|
|
@@ -291,7 +297,7 @@ interface VeuiResolverOptions {
|
|
|
291
297
|
*
|
|
292
298
|
* @link https://github.com/ecomfe/veui
|
|
293
299
|
*/
|
|
294
|
-
declare function VeuiResolver(options
|
|
300
|
+
declare function VeuiResolver(options?: VeuiResolverOptions): ComponentResolver;
|
|
295
301
|
|
|
296
302
|
/**
|
|
297
303
|
* Resolver for View UI
|
|
@@ -397,4 +403,39 @@ interface TDesignResolverOptions {
|
|
|
397
403
|
}
|
|
398
404
|
declare function TDesignResolver(options?: TDesignResolverOptions): ComponentResolver;
|
|
399
405
|
|
|
400
|
-
|
|
406
|
+
interface LayuiVueResolverOptions {
|
|
407
|
+
/**
|
|
408
|
+
* import style along with components
|
|
409
|
+
*
|
|
410
|
+
* @default 'css'
|
|
411
|
+
*/
|
|
412
|
+
importStyle?: boolean | 'css';
|
|
413
|
+
/**
|
|
414
|
+
* resolve '@layui/layui-vue' icons
|
|
415
|
+
* requires package `@layui/icons-vue`
|
|
416
|
+
*
|
|
417
|
+
* @default false
|
|
418
|
+
*/
|
|
419
|
+
resolveIcons?: boolean;
|
|
420
|
+
/**
|
|
421
|
+
* exclude components that do not require automatic import
|
|
422
|
+
*
|
|
423
|
+
*/
|
|
424
|
+
exclude?: Array<string | RegExp>;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Resolver for layui-vue
|
|
428
|
+
*
|
|
429
|
+
* @link http://www.layui-vue.com/ for layui-vue
|
|
430
|
+
*
|
|
431
|
+
*/
|
|
432
|
+
declare function LayuiVueResolver(options?: LayuiVueResolverOptions): ComponentResolver;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Resolver for BootstrapVue
|
|
436
|
+
*
|
|
437
|
+
* @link https://github.com/bootstrap-vue/bootstrap-vue
|
|
438
|
+
*/
|
|
439
|
+
declare function BootstrapVueResolver(): ComponentResolver;
|
|
440
|
+
|
|
441
|
+
export { AntDesignVueResolver, AntDesignVueResolverOptions, ArcoResolver, ArcoResolverOptions, BootstrapVueResolver, DevResolverOptions, DevUiResolver, ElementPlusResolver, ElementPlusResolverOptions, ElementUiResolver, ElementUiResolverOptions, HeadlessUiResolver, HeadlessUiResolverOptions, IduxResolver, IduxResolverOptions, InklineResolver, LayuiVueResolver, LayuiVueResolverOptions, NaiveUiResolver, PrimeVueResolver, PrimeVueResolverOptions, QuasarResolver, TDesignResolver, TDesignResolverOptions, VantResolver, VantResolverOptions, VarletUIResolver, VarletUIResolverOptions, VeuiResolver, VeuiResolverOptions, ViewUiResolver, VueUseComponentsResolver, Vuetify3Resolver, VuetifyResolver, getResolved };
|