unplugin-vue-components 0.27.1 → 0.27.3
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/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/{chunk-5LSX6IQN.js → chunk-4KHLF5I7.js} +6 -5
- package/dist/{chunk-VPUTCXXP.cjs → chunk-5RDO6MHS.cjs} +7 -6
- package/dist/chunk-OBGZSXTJ.cjs +10 -0
- package/dist/{chunk-MB5VKJR2.cjs → chunk-V7E5BH3Y.cjs} +62 -66
- package/dist/{chunk-WH3OXX67.js → chunk-YOHL3P33.js} +44 -48
- package/dist/esbuild.cjs +4 -4
- package/dist/esbuild.js +3 -3
- package/dist/index.cjs +4 -4
- package/dist/index.js +3 -3
- package/dist/nuxt.cjs +5 -5
- package/dist/nuxt.js +3 -3
- package/dist/resolvers.cjs +45 -51
- package/dist/resolvers.js +25 -31
- package/dist/rollup.cjs +4 -4
- package/dist/rollup.js +3 -3
- package/dist/rspack.cjs +4 -4
- package/dist/rspack.js +3 -3
- package/dist/{src-SFFAR3KJ.cjs → src-KNP44FKK.cjs} +7 -13
- package/dist/{src-WIQNDB4Q.js → src-QRDHCXVL.js} +7 -13
- package/dist/vite.cjs +4 -4
- package/dist/vite.js +3 -3
- package/dist/webpack.cjs +4 -4
- package/dist/webpack.js +3 -3
- package/package.json +20 -20
- package/dist/chunk-5JVO2UWC.js +0 -32
- package/dist/chunk-WJIU4Q36.cjs +0 -32
|
@@ -10,11 +10,7 @@ import {
|
|
|
10
10
|
resolveAlias,
|
|
11
11
|
shouldTransform,
|
|
12
12
|
stringifyComponentImport
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import {
|
|
15
|
-
__spreadProps,
|
|
16
|
-
__spreadValues
|
|
17
|
-
} from "./chunk-5JVO2UWC.js";
|
|
13
|
+
} from "./chunk-4KHLF5I7.js";
|
|
18
14
|
|
|
19
15
|
// src/core/unplugin.ts
|
|
20
16
|
import { existsSync as existsSync2 } from "fs";
|
|
@@ -85,7 +81,6 @@ function resolveGlobsExclude(root, glob) {
|
|
|
85
81
|
return `${excludeReg.test(glob) ? "!" : ""}${resolve(root, glob.replace(excludeReg, ""))}`;
|
|
86
82
|
}
|
|
87
83
|
function resolveOptions(options, root) {
|
|
88
|
-
var _a;
|
|
89
84
|
const resolved = Object.assign({}, defaultOptions, options);
|
|
90
85
|
resolved.resolvers = normalizeResolvers(resolved.resolvers);
|
|
91
86
|
resolved.extensions = toArray(resolved.extensions);
|
|
@@ -110,7 +105,7 @@ function resolveOptions(options, root) {
|
|
|
110
105
|
resolved.types = detectTypeImports();
|
|
111
106
|
resolved.types = resolved.types || [];
|
|
112
107
|
resolved.root = root;
|
|
113
|
-
resolved.version =
|
|
108
|
+
resolved.version = resolved.version ?? getVueVersion(root);
|
|
114
109
|
if (resolved.version < 2 || resolved.version >= 4)
|
|
115
110
|
throw new Error(`[unplugin-vue-components] unsupported version: ${resolved.version}`);
|
|
116
111
|
resolved.transformer = options.transformer || `vue${Math.trunc(resolved.version)}`;
|
|
@@ -118,8 +113,7 @@ function resolveOptions(options, root) {
|
|
|
118
113
|
return resolved;
|
|
119
114
|
}
|
|
120
115
|
function getVueVersion(root) {
|
|
121
|
-
|
|
122
|
-
const raw = ((_a = getPackageInfoSync("vue", { paths: [root] })) == null ? void 0 : _a.version) || "3";
|
|
116
|
+
const raw = getPackageInfoSync("vue", { paths: [root] })?.version || "3";
|
|
123
117
|
const version = +raw.split(".").slice(0, 2).join(".");
|
|
124
118
|
if (version === 2.7)
|
|
125
119
|
return 2.7;
|
|
@@ -133,7 +127,6 @@ import fg from "fast-glob";
|
|
|
133
127
|
import Debug from "debug";
|
|
134
128
|
var debug = Debug("unplugin-vue-components:glob");
|
|
135
129
|
function searchComponents(ctx) {
|
|
136
|
-
var _a;
|
|
137
130
|
debug(`started with: [${ctx.options.globs.join(", ")}]`);
|
|
138
131
|
const root = ctx.root;
|
|
139
132
|
const files = fg.sync(ctx.options.globs, {
|
|
@@ -142,7 +135,7 @@ function searchComponents(ctx) {
|
|
|
142
135
|
cwd: root,
|
|
143
136
|
absolute: true
|
|
144
137
|
});
|
|
145
|
-
if (!files.length && !
|
|
138
|
+
if (!files.length && !ctx.options.resolvers?.length)
|
|
146
139
|
console.warn("[unplugin-vue-components] no components found");
|
|
147
140
|
debug(`${files.length} components found.`);
|
|
148
141
|
ctx.addComponents(files);
|
|
@@ -153,13 +146,12 @@ import { dirname, isAbsolute, relative } from "path";
|
|
|
153
146
|
import { existsSync } from "fs";
|
|
154
147
|
import { mkdir, readFile, writeFile as writeFile_ } from "fs/promises";
|
|
155
148
|
import { notNullish as notNullish2, slash as slash2 } from "@antfu/utils";
|
|
156
|
-
var multilineCommentsRE =
|
|
149
|
+
var multilineCommentsRE = /\/\*.*?\*\//gs;
|
|
157
150
|
var singlelineCommentsRE = /\/\/.*$/gm;
|
|
158
151
|
function extractImports(code) {
|
|
159
152
|
return Object.fromEntries(Array.from(code.matchAll(/['"]?([^\s'"]+)['"]?\s*:\s*(.+?)[,;\n]/g)).map((i) => [i[1], i[2]]));
|
|
160
153
|
}
|
|
161
154
|
function parseDeclaration(code) {
|
|
162
|
-
var _a, _b;
|
|
163
155
|
if (!code)
|
|
164
156
|
return;
|
|
165
157
|
code = code.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, "");
|
|
@@ -167,10 +159,10 @@ function parseDeclaration(code) {
|
|
|
167
159
|
component: {},
|
|
168
160
|
directive: {}
|
|
169
161
|
};
|
|
170
|
-
const componentDeclaration =
|
|
162
|
+
const componentDeclaration = /export\s+interface\s+GlobalComponents\s*\{.*?\}/s.exec(code)?.[0];
|
|
171
163
|
if (componentDeclaration)
|
|
172
164
|
imports.component = extractImports(componentDeclaration);
|
|
173
|
-
const directiveDeclaration =
|
|
165
|
+
const directiveDeclaration = /export\s+interface\s+ComponentCustomProperties\s*\{.*?\}/s.exec(code)?.[0];
|
|
174
166
|
if (directiveDeclaration)
|
|
175
167
|
imports.directive = extractImports(directiveDeclaration);
|
|
176
168
|
return imports;
|
|
@@ -190,7 +182,10 @@ function stringifyComponentsInfo(filepath, components, importPathTransform) {
|
|
|
190
182
|
}
|
|
191
183
|
function getDeclarationImports(ctx, filepath) {
|
|
192
184
|
const component = stringifyComponentsInfo(filepath, [
|
|
193
|
-
...Object.values(
|
|
185
|
+
...Object.values({
|
|
186
|
+
...ctx.componentNameMap,
|
|
187
|
+
...ctx.componentCustomMap
|
|
188
|
+
}),
|
|
194
189
|
...resolveTypeImports(ctx.options.types)
|
|
195
190
|
], ctx.options.importPathTransform);
|
|
196
191
|
const directive = stringifyComponentsInfo(
|
|
@@ -214,8 +209,8 @@ function getDeclaration(ctx, filepath, originalImports) {
|
|
|
214
209
|
if (!imports)
|
|
215
210
|
return;
|
|
216
211
|
const declarations = {
|
|
217
|
-
component: stringifyDeclarationImports(
|
|
218
|
-
directive: stringifyDeclarationImports(
|
|
212
|
+
component: stringifyDeclarationImports({ ...originalImports?.component, ...imports.component }),
|
|
213
|
+
directive: stringifyDeclarationImports({ ...originalImports?.directive, ...imports.directive })
|
|
219
214
|
};
|
|
220
215
|
let code = `/* eslint-disable */
|
|
221
216
|
// @ts-nocheck
|
|
@@ -263,7 +258,7 @@ import Debug2 from "debug";
|
|
|
263
258
|
var debug2 = Debug2("unplugin-vue-components:transform:component");
|
|
264
259
|
function resolveVue2(code, s) {
|
|
265
260
|
const results = [];
|
|
266
|
-
for (const match of code.matchAll(/\b(_c|h)\(
|
|
261
|
+
for (const match of code.matchAll(/\b(_c|h)\(\s*['"](.+?)["']([,)])/g)) {
|
|
267
262
|
const [full, renderFunctionName, matchedName, append] = match;
|
|
268
263
|
if (match.index != null && matchedName && !matchedName.startsWith("_")) {
|
|
269
264
|
const start = match.index;
|
|
@@ -278,7 +273,7 @@ function resolveVue2(code, s) {
|
|
|
278
273
|
}
|
|
279
274
|
function resolveVue3(code, s) {
|
|
280
275
|
const results = [];
|
|
281
|
-
for (const match of code.matchAll(/_resolveComponent
|
|
276
|
+
for (const match of code.matchAll(/_resolveComponent\d*\("(.+?)"\)/g)) {
|
|
282
277
|
const matchedName = match[1];
|
|
283
278
|
if (match.index != null && matchedName && !matchedName.startsWith("_")) {
|
|
284
279
|
const start = match.index;
|
|
@@ -301,7 +296,7 @@ async function transformComponent(code, transformer2, s, ctx, sfcPath) {
|
|
|
301
296
|
const component = await ctx.findComponent(name, "component", [sfcPath]);
|
|
302
297
|
if (component) {
|
|
303
298
|
const varName = `__unplugin_components_${no}`;
|
|
304
|
-
s.prepend(`${stringifyComponentImport(
|
|
299
|
+
s.prepend(`${stringifyComponentImport({ ...component, as: varName }, ctx)};
|
|
305
300
|
`);
|
|
306
301
|
no += 1;
|
|
307
302
|
replace(varName);
|
|
@@ -316,17 +311,15 @@ import Debug3 from "debug";
|
|
|
316
311
|
// src/core/transforms/directive/vue2.ts
|
|
317
312
|
import { importModule, isPackageExists as isPackageExists3 } from "local-pkg";
|
|
318
313
|
function getRenderFnStart(program) {
|
|
319
|
-
var _a, _b;
|
|
320
314
|
const renderFn = program.body.find(
|
|
321
315
|
(node) => node.type === "VariableDeclaration" && node.declarations[0].id.type === "Identifier" && ["render", "_sfc_render"].includes(node.declarations[0].id.name)
|
|
322
316
|
);
|
|
323
|
-
const start =
|
|
317
|
+
const start = renderFn?.declarations[0].init?.body?.start;
|
|
324
318
|
if (start === null || start === void 0)
|
|
325
319
|
throw new Error("[unplugin-vue-components:directive] Cannot find render function position.");
|
|
326
320
|
return start + 1;
|
|
327
321
|
}
|
|
328
322
|
async function resolveVue22(code, s) {
|
|
329
|
-
var _a, _b, _c;
|
|
330
323
|
if (!isPackageExists3("@babel/parser"))
|
|
331
324
|
throw new Error('[unplugin-vue-components:directive] To use Vue 2 directive you will need to install Babel first: "npm install -D @babel/parser"');
|
|
332
325
|
const { parse } = await importModule("@babel/parser");
|
|
@@ -334,7 +327,7 @@ async function resolveVue22(code, s) {
|
|
|
334
327
|
sourceType: "module"
|
|
335
328
|
});
|
|
336
329
|
const nodes = [];
|
|
337
|
-
const { walk } = await import("./src-
|
|
330
|
+
const { walk } = await import("./src-QRDHCXVL.js");
|
|
338
331
|
walk(program, {
|
|
339
332
|
enter(node) {
|
|
340
333
|
if (node.type === "CallExpression")
|
|
@@ -352,20 +345,20 @@ async function resolveVue22(code, s) {
|
|
|
352
345
|
const results = [];
|
|
353
346
|
for (const node of nodes) {
|
|
354
347
|
const { callee, arguments: args } = node;
|
|
355
|
-
if (callee.type !== "Identifier" || callee.name !== "_c" ||
|
|
348
|
+
if (callee.type !== "Identifier" || callee.name !== "_c" || args[1]?.type !== "ObjectExpression")
|
|
356
349
|
continue;
|
|
357
|
-
const directives =
|
|
350
|
+
const directives = args[1].properties.find(
|
|
358
351
|
(property) => property.type === "ObjectProperty" && property.key.type === "Identifier" && property.key.name === "directives"
|
|
359
|
-
)
|
|
352
|
+
)?.value;
|
|
360
353
|
if (!directives || directives.type !== "ArrayExpression")
|
|
361
354
|
continue;
|
|
362
355
|
for (const directive of directives.elements) {
|
|
363
|
-
if (
|
|
356
|
+
if (directive?.type !== "ObjectExpression")
|
|
364
357
|
continue;
|
|
365
|
-
const nameNode =
|
|
358
|
+
const nameNode = directive.properties.find(
|
|
366
359
|
(p) => p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "name"
|
|
367
|
-
)
|
|
368
|
-
if (
|
|
360
|
+
)?.value;
|
|
361
|
+
if (nameNode?.type !== "StringLiteral")
|
|
369
362
|
continue;
|
|
370
363
|
const name = nameNode.value;
|
|
371
364
|
if (!name || name.startsWith("_"))
|
|
@@ -412,7 +405,7 @@ async function transformDirective(code, transformer2, s, ctx, sfcPath) {
|
|
|
412
405
|
if (!directive)
|
|
413
406
|
continue;
|
|
414
407
|
const varName = `__unplugin_directives_${no}`;
|
|
415
|
-
s.prepend(`${stringifyComponentImport(
|
|
408
|
+
s.prepend(`${stringifyComponentImport({ ...directive, as: varName }, ctx)};
|
|
416
409
|
`);
|
|
417
410
|
no += 1;
|
|
418
411
|
replace(varName);
|
|
@@ -450,20 +443,21 @@ var debug5 = {
|
|
|
450
443
|
var Context = class {
|
|
451
444
|
constructor(rawOptions) {
|
|
452
445
|
this.rawOptions = rawOptions;
|
|
453
|
-
this.transformer = void 0;
|
|
454
|
-
this._componentPaths = /* @__PURE__ */ new Set();
|
|
455
|
-
this._componentNameMap = {};
|
|
456
|
-
this._componentUsageMap = {};
|
|
457
|
-
this._componentCustomMap = {};
|
|
458
|
-
this._directiveCustomMap = {};
|
|
459
|
-
this.root = process.cwd();
|
|
460
|
-
this.sourcemap = true;
|
|
461
|
-
this.alias = {};
|
|
462
|
-
this._searched = false;
|
|
463
446
|
this.options = resolveOptions(rawOptions, this.root);
|
|
464
447
|
this.generateDeclaration = throttle(500, this._generateDeclaration.bind(this), { noLeading: false });
|
|
465
448
|
this.setTransformer(this.options.transformer);
|
|
466
449
|
}
|
|
450
|
+
options;
|
|
451
|
+
transformer = void 0;
|
|
452
|
+
_componentPaths = /* @__PURE__ */ new Set();
|
|
453
|
+
_componentNameMap = {};
|
|
454
|
+
_componentUsageMap = {};
|
|
455
|
+
_componentCustomMap = {};
|
|
456
|
+
_directiveCustomMap = {};
|
|
457
|
+
_server;
|
|
458
|
+
root = process.cwd();
|
|
459
|
+
sourcemap = true;
|
|
460
|
+
alias = {};
|
|
467
461
|
setRoot(root) {
|
|
468
462
|
if (this.root === root)
|
|
469
463
|
return;
|
|
@@ -616,9 +610,10 @@ var Context = class {
|
|
|
616
610
|
from: result
|
|
617
611
|
};
|
|
618
612
|
} else {
|
|
619
|
-
info =
|
|
620
|
-
as: name
|
|
621
|
-
|
|
613
|
+
info = {
|
|
614
|
+
as: name,
|
|
615
|
+
...normalizeComponentInfo(result)
|
|
616
|
+
};
|
|
622
617
|
}
|
|
623
618
|
if (type === "component")
|
|
624
619
|
this.addCustomComponents(info);
|
|
@@ -629,14 +624,14 @@ var Context = class {
|
|
|
629
624
|
return void 0;
|
|
630
625
|
}
|
|
631
626
|
normalizePath(path) {
|
|
632
|
-
|
|
633
|
-
return resolveAlias(path, ((_b = (_a = this.viteConfig) == null ? void 0 : _a.resolve) == null ? void 0 : _b.alias) || ((_c = this.viteConfig) == null ? void 0 : _c.alias) || []);
|
|
627
|
+
return resolveAlias(path, this.viteConfig?.resolve?.alias || this.viteConfig?.alias || []);
|
|
634
628
|
}
|
|
635
629
|
relative(path) {
|
|
636
630
|
if (path.startsWith("/") && !path.startsWith(this.root))
|
|
637
631
|
return slash3(path.slice(1));
|
|
638
632
|
return slash3(relative2(this.root, path));
|
|
639
633
|
}
|
|
634
|
+
_searched = false;
|
|
640
635
|
/**
|
|
641
636
|
* This search for components in with the given options.
|
|
642
637
|
* Will be called multiple times to ensure file loaded,
|
|
@@ -655,6 +650,7 @@ var Context = class {
|
|
|
655
650
|
debug5.declaration("generating");
|
|
656
651
|
return writeDeclaration(this, this.options.dts, removeUnused);
|
|
657
652
|
}
|
|
653
|
+
generateDeclaration;
|
|
658
654
|
get componentNameMap() {
|
|
659
655
|
return this._componentNameMap;
|
|
660
656
|
}
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var _chunkV7E5BH3Ycjs = require('./chunk-V7E5BH3Y.cjs');
|
|
4
|
+
require('./chunk-5RDO6MHS.cjs');
|
|
5
|
+
require('./chunk-OBGZSXTJ.cjs');
|
|
6
6
|
require('./chunk-ZBPRDZS4.cjs');
|
|
7
7
|
|
|
8
8
|
// src/esbuild.ts
|
|
9
|
-
var esbuild_default =
|
|
9
|
+
var esbuild_default = _chunkV7E5BH3Ycjs.unplugin_default.esbuild;
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
exports.default = esbuild_default;
|
package/dist/esbuild.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
unplugin_default
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-YOHL3P33.js";
|
|
4
|
+
import "./chunk-4KHLF5I7.js";
|
|
5
|
+
import "./chunk-3RG5ZIWI.js";
|
|
6
6
|
import "./chunk-6F4PWJZI.js";
|
|
7
7
|
|
|
8
8
|
// src/esbuild.ts
|
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkV7E5BH3Ycjs = require('./chunk-V7E5BH3Y.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
require('./chunk-
|
|
8
|
+
var _chunk5RDO6MHScjs = require('./chunk-5RDO6MHS.cjs');
|
|
9
|
+
require('./chunk-OBGZSXTJ.cjs');
|
|
10
10
|
require('./chunk-ZBPRDZS4.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
exports.camelCase =
|
|
16
|
+
exports.camelCase = _chunk5RDO6MHScjs.camelCase; exports.default = _chunkV7E5BH3Ycjs.unplugin_default; exports.kebabCase = _chunk5RDO6MHScjs.kebabCase; exports.pascalCase = _chunk5RDO6MHScjs.pascalCase;
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
unplugin_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YOHL3P33.js";
|
|
4
4
|
import {
|
|
5
5
|
camelCase,
|
|
6
6
|
kebabCase,
|
|
7
7
|
pascalCase
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-4KHLF5I7.js";
|
|
9
|
+
import "./chunk-3RG5ZIWI.js";
|
|
10
10
|
import "./chunk-6F4PWJZI.js";
|
|
11
11
|
export {
|
|
12
12
|
camelCase,
|
package/dist/nuxt.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var _chunkV7E5BH3Ycjs = require('./chunk-V7E5BH3Y.cjs');
|
|
4
|
+
require('./chunk-5RDO6MHS.cjs');
|
|
5
|
+
require('./chunk-OBGZSXTJ.cjs');
|
|
6
6
|
require('./chunk-ZBPRDZS4.cjs');
|
|
7
7
|
|
|
8
8
|
// src/nuxt.ts
|
|
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,
|
|
13
|
-
_kit.addVitePlugin.call(void 0,
|
|
12
|
+
_kit.addWebpackPlugin.call(void 0, _chunkV7E5BH3Ycjs.unplugin_default.webpack(options));
|
|
13
|
+
_kit.addVitePlugin.call(void 0, _chunkV7E5BH3Ycjs.unplugin_default.vite(options));
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
|
package/dist/nuxt.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
unplugin_default
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-YOHL3P33.js";
|
|
4
|
+
import "./chunk-4KHLF5I7.js";
|
|
5
|
+
import "./chunk-3RG5ZIWI.js";
|
|
6
6
|
import "./chunk-6F4PWJZI.js";
|
|
7
7
|
|
|
8
8
|
// src/nuxt.ts
|