unplugin-vue-components 0.27.2 → 0.27.4
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 +6 -2
- package/dist/{chunk-JWQK2ERM.cjs → chunk-23WSNQH3.cjs} +66 -65
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/{chunk-VPUTCXXP.cjs → chunk-6IWOTYMJ.cjs} +24 -7
- package/dist/{chunk-DLVGSKLE.js → chunk-B4WNWTB4.js} +49 -48
- package/dist/chunk-OBGZSXTJ.cjs +10 -0
- package/dist/{chunk-5LSX6IQN.js → chunk-VFBNI2IV.js} +23 -6
- 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 +47 -90
- package/dist/resolvers.d.cts +3 -3
- package/dist/resolvers.d.ts +3 -3
- package/dist/resolvers.js +27 -70
- 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-ZMUOH6GK.cjs → src-KNP44FKK.cjs} +1 -1
- package/dist/{src-RBAWKBDF.js → src-QRDHCXVL.js} +1 -1
- package/dist/types.d.cts +5 -1
- package/dist/types.d.ts +5 -1
- 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 +19 -19
- package/dist/chunk-HMX3D6IV.js +0 -31
- package/dist/chunk-W4CCXOOA.cjs +0 -31
package/README.md
CHANGED
|
@@ -358,7 +358,7 @@ Components({
|
|
|
358
358
|
extensions: ['vue'],
|
|
359
359
|
|
|
360
360
|
// Glob patterns to match file names to be detected as components.
|
|
361
|
-
// When specified, the `dirs` and `
|
|
361
|
+
// When specified, the `dirs`, `extensions`, and `directoryAsNamespace` options will be ignored.
|
|
362
362
|
// If you want to exclude components being registered, use negative globs with leading `!`.
|
|
363
363
|
globs: ['src/components/*.{vue}'],
|
|
364
364
|
|
|
@@ -398,10 +398,14 @@ Components({
|
|
|
398
398
|
allowOverrides: false,
|
|
399
399
|
|
|
400
400
|
// Filters for transforming targets (components to insert the auto import)
|
|
401
|
-
// Note these are NOT about including/excluding components registered - use `globs` for that
|
|
401
|
+
// Note these are NOT about including/excluding components registered - use `globs` or `excludeNames` for that
|
|
402
402
|
include: [/\.vue$/, /\.vue\?vue/],
|
|
403
403
|
exclude: [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/],
|
|
404
404
|
|
|
405
|
+
// Filters for component names that will not be imported
|
|
406
|
+
// Use for globally imported async components or other conflicts that the plugin cannot detect
|
|
407
|
+
excludeNames: [/^Async.+/],
|
|
408
|
+
|
|
405
409
|
// Vue version of project. It will detect automatically if not specified.
|
|
406
410
|
// Acceptable value: 2 | 2.7 | 3
|
|
407
411
|
version: 2.7,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -10,11 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var _chunkVPUTCXXPcjs = require('./chunk-VPUTCXXP.cjs');
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var _chunkW4CCXOOAcjs = require('./chunk-W4CCXOOA.cjs');
|
|
14
|
+
var _chunk6IWOTYMJcjs = require('./chunk-6IWOTYMJ.cjs');
|
|
18
15
|
|
|
19
16
|
// src/core/unplugin.ts
|
|
20
17
|
var _fs = require('fs');
|
|
@@ -85,7 +82,6 @@ function resolveGlobsExclude(root, glob) {
|
|
|
85
82
|
return `${excludeReg.test(glob) ? "!" : ""}${_path.resolve.call(void 0, root, glob.replace(excludeReg, ""))}`;
|
|
86
83
|
}
|
|
87
84
|
function resolveOptions(options, root) {
|
|
88
|
-
var _a;
|
|
89
85
|
const resolved = Object.assign({}, defaultOptions, options);
|
|
90
86
|
resolved.resolvers = normalizeResolvers(resolved.resolvers);
|
|
91
87
|
resolved.extensions = _utils.toArray.call(void 0, resolved.extensions);
|
|
@@ -110,7 +106,7 @@ function resolveOptions(options, root) {
|
|
|
110
106
|
resolved.types = detectTypeImports();
|
|
111
107
|
resolved.types = resolved.types || [];
|
|
112
108
|
resolved.root = root;
|
|
113
|
-
resolved.version = (
|
|
109
|
+
resolved.version = _nullishCoalesce(resolved.version, () => ( getVueVersion(root)));
|
|
114
110
|
if (resolved.version < 2 || resolved.version >= 4)
|
|
115
111
|
throw new Error(`[unplugin-vue-components] unsupported version: ${resolved.version}`);
|
|
116
112
|
resolved.transformer = options.transformer || `vue${Math.trunc(resolved.version)}`;
|
|
@@ -118,8 +114,7 @@ function resolveOptions(options, root) {
|
|
|
118
114
|
return resolved;
|
|
119
115
|
}
|
|
120
116
|
function getVueVersion(root) {
|
|
121
|
-
|
|
122
|
-
const raw = ((_a = _localpkg.getPackageInfoSync.call(void 0, "vue", { paths: [root] })) == null ? void 0 : _a.version) || "3";
|
|
117
|
+
const raw = _optionalChain([_localpkg.getPackageInfoSync.call(void 0, "vue", { paths: [_path.join.call(void 0, root, "/")] }), 'optionalAccess', _ => _.version]) || "3";
|
|
123
118
|
const version = +raw.split(".").slice(0, 2).join(".");
|
|
124
119
|
if (version === 2.7)
|
|
125
120
|
return 2.7;
|
|
@@ -133,7 +128,6 @@ var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_f
|
|
|
133
128
|
|
|
134
129
|
var debug = _debug2.default.call(void 0, "unplugin-vue-components:glob");
|
|
135
130
|
function searchComponents(ctx) {
|
|
136
|
-
var _a;
|
|
137
131
|
debug(`started with: [${ctx.options.globs.join(", ")}]`);
|
|
138
132
|
const root = ctx.root;
|
|
139
133
|
const files = _fastglob2.default.sync(ctx.options.globs, {
|
|
@@ -142,7 +136,7 @@ function searchComponents(ctx) {
|
|
|
142
136
|
cwd: root,
|
|
143
137
|
absolute: true
|
|
144
138
|
});
|
|
145
|
-
if (!files.length && !(
|
|
139
|
+
if (!files.length && !_optionalChain([ctx, 'access', _2 => _2.options, 'access', _3 => _3.resolvers, 'optionalAccess', _4 => _4.length]))
|
|
146
140
|
console.warn("[unplugin-vue-components] no components found");
|
|
147
141
|
debug(`${files.length} components found.`);
|
|
148
142
|
ctx.addComponents(files);
|
|
@@ -153,13 +147,12 @@ function searchComponents(ctx) {
|
|
|
153
147
|
|
|
154
148
|
var _promises = require('fs/promises');
|
|
155
149
|
|
|
156
|
-
var multilineCommentsRE =
|
|
150
|
+
var multilineCommentsRE = /\/\*.*?\*\//gs;
|
|
157
151
|
var singlelineCommentsRE = /\/\/.*$/gm;
|
|
158
152
|
function extractImports(code) {
|
|
159
153
|
return Object.fromEntries(Array.from(code.matchAll(/['"]?([^\s'"]+)['"]?\s*:\s*(.+?)[,;\n]/g)).map((i) => [i[1], i[2]]));
|
|
160
154
|
}
|
|
161
155
|
function parseDeclaration(code) {
|
|
162
|
-
var _a, _b;
|
|
163
156
|
if (!code)
|
|
164
157
|
return;
|
|
165
158
|
code = code.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, "");
|
|
@@ -167,10 +160,10 @@ function parseDeclaration(code) {
|
|
|
167
160
|
component: {},
|
|
168
161
|
directive: {}
|
|
169
162
|
};
|
|
170
|
-
const componentDeclaration = (
|
|
163
|
+
const componentDeclaration = _optionalChain([/export\s+interface\s+GlobalComponents\s*\{.*?\}/s, 'access', _5 => _5.exec, 'call', _6 => _6(code), 'optionalAccess', _7 => _7[0]]);
|
|
171
164
|
if (componentDeclaration)
|
|
172
165
|
imports.component = extractImports(componentDeclaration);
|
|
173
|
-
const directiveDeclaration = (
|
|
166
|
+
const directiveDeclaration = _optionalChain([/export\s+interface\s+ComponentCustomProperties\s*\{.*?\}/s, 'access', _8 => _8.exec, 'call', _9 => _9(code), 'optionalAccess', _10 => _10[0]]);
|
|
174
167
|
if (directiveDeclaration)
|
|
175
168
|
imports.directive = extractImports(directiveDeclaration);
|
|
176
169
|
return imports;
|
|
@@ -178,7 +171,7 @@ function parseDeclaration(code) {
|
|
|
178
171
|
function stringifyComponentInfo(filepath, { from: path, as: name, name: importName }, importPathTransform) {
|
|
179
172
|
if (!name)
|
|
180
173
|
return void 0;
|
|
181
|
-
path =
|
|
174
|
+
path = _chunk6IWOTYMJcjs.getTransformedPath.call(void 0, path, importPathTransform);
|
|
182
175
|
const related = _path.isAbsolute.call(void 0, path) ? `./${_path.relative.call(void 0, _path.dirname.call(void 0, filepath), path)}` : path;
|
|
183
176
|
const entry = `typeof import('${_utils.slash.call(void 0, related)}')['${importName || "default"}']`;
|
|
184
177
|
return [name, entry];
|
|
@@ -190,7 +183,10 @@ function stringifyComponentsInfo(filepath, components, importPathTransform) {
|
|
|
190
183
|
}
|
|
191
184
|
function getDeclarationImports(ctx, filepath) {
|
|
192
185
|
const component = stringifyComponentsInfo(filepath, [
|
|
193
|
-
...Object.values(
|
|
186
|
+
...Object.values({
|
|
187
|
+
...ctx.componentNameMap,
|
|
188
|
+
...ctx.componentCustomMap
|
|
189
|
+
}),
|
|
194
190
|
...resolveTypeImports(ctx.options.types)
|
|
195
191
|
], ctx.options.importPathTransform);
|
|
196
192
|
const directive = stringifyComponentsInfo(
|
|
@@ -214,8 +210,8 @@ function getDeclaration(ctx, filepath, originalImports) {
|
|
|
214
210
|
if (!imports)
|
|
215
211
|
return;
|
|
216
212
|
const declarations = {
|
|
217
|
-
component: stringifyDeclarationImports(
|
|
218
|
-
directive: stringifyDeclarationImports(
|
|
213
|
+
component: stringifyDeclarationImports({ ..._optionalChain([originalImports, 'optionalAccess', _11 => _11.component]), ...imports.component }),
|
|
214
|
+
directive: stringifyDeclarationImports({ ..._optionalChain([originalImports, 'optionalAccess', _12 => _12.directive]), ...imports.directive })
|
|
219
215
|
};
|
|
220
216
|
let code = `/* eslint-disable */
|
|
221
217
|
// @ts-nocheck
|
|
@@ -263,7 +259,7 @@ var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireD
|
|
|
263
259
|
var debug2 = _debug2.default.call(void 0, "unplugin-vue-components:transform:component");
|
|
264
260
|
function resolveVue2(code, s) {
|
|
265
261
|
const results = [];
|
|
266
|
-
for (const match of code.matchAll(/\b(_c|h)\(
|
|
262
|
+
for (const match of code.matchAll(/\b(_c|h)\(\s*['"](.+?)["']([,)])/g)) {
|
|
267
263
|
const [full, renderFunctionName, matchedName, append] = match;
|
|
268
264
|
if (match.index != null && matchedName && !matchedName.startsWith("_")) {
|
|
269
265
|
const start = match.index;
|
|
@@ -278,7 +274,7 @@ function resolveVue2(code, s) {
|
|
|
278
274
|
}
|
|
279
275
|
function resolveVue3(code, s) {
|
|
280
276
|
const results = [];
|
|
281
|
-
for (const match of code.matchAll(/_resolveComponent
|
|
277
|
+
for (const match of code.matchAll(/_resolveComponent\d*\("(.+?)"\)/g)) {
|
|
282
278
|
const matchedName = match[1];
|
|
283
279
|
if (match.index != null && matchedName && !matchedName.startsWith("_")) {
|
|
284
280
|
const start = match.index;
|
|
@@ -296,12 +292,12 @@ async function transformComponent(code, transformer2, s, ctx, sfcPath) {
|
|
|
296
292
|
const results = transformer2 === "vue2" ? resolveVue2(code, s) : resolveVue3(code, s);
|
|
297
293
|
for (const { rawName, replace } of results) {
|
|
298
294
|
debug2(`| ${rawName}`);
|
|
299
|
-
const name =
|
|
295
|
+
const name = _chunk6IWOTYMJcjs.pascalCase.call(void 0, rawName);
|
|
300
296
|
ctx.updateUsageMap(sfcPath, [name]);
|
|
301
297
|
const component = await ctx.findComponent(name, "component", [sfcPath]);
|
|
302
298
|
if (component) {
|
|
303
299
|
const varName = `__unplugin_components_${no}`;
|
|
304
|
-
s.prepend(`${
|
|
300
|
+
s.prepend(`${_chunk6IWOTYMJcjs.stringifyComponentImport.call(void 0, { ...component, as: varName }, ctx)};
|
|
305
301
|
`);
|
|
306
302
|
no += 1;
|
|
307
303
|
replace(varName);
|
|
@@ -316,17 +312,15 @@ async function transformComponent(code, transformer2, s, ctx, sfcPath) {
|
|
|
316
312
|
// src/core/transforms/directive/vue2.ts
|
|
317
313
|
|
|
318
314
|
function getRenderFnStart(program) {
|
|
319
|
-
var _a, _b;
|
|
320
315
|
const renderFn = program.body.find(
|
|
321
316
|
(node) => node.type === "VariableDeclaration" && node.declarations[0].id.type === "Identifier" && ["render", "_sfc_render"].includes(node.declarations[0].id.name)
|
|
322
317
|
);
|
|
323
|
-
const start = (
|
|
318
|
+
const start = _optionalChain([renderFn, 'optionalAccess', _13 => _13.declarations, 'access', _14 => _14[0], 'access', _15 => _15.init, 'optionalAccess', _16 => _16.body, 'optionalAccess', _17 => _17.start]);
|
|
324
319
|
if (start === null || start === void 0)
|
|
325
320
|
throw new Error("[unplugin-vue-components:directive] Cannot find render function position.");
|
|
326
321
|
return start + 1;
|
|
327
322
|
}
|
|
328
323
|
async function resolveVue22(code, s) {
|
|
329
|
-
var _a, _b, _c;
|
|
330
324
|
if (!_localpkg.isPackageExists.call(void 0, "@babel/parser"))
|
|
331
325
|
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
326
|
const { parse } = await _localpkg.importModule.call(void 0, "@babel/parser");
|
|
@@ -334,7 +328,7 @@ async function resolveVue22(code, s) {
|
|
|
334
328
|
sourceType: "module"
|
|
335
329
|
});
|
|
336
330
|
const nodes = [];
|
|
337
|
-
const { walk } = await Promise.resolve().then(() => require("./src-
|
|
331
|
+
const { walk } = await Promise.resolve().then(() => _interopRequireWildcard(require("./src-KNP44FKK.cjs")));
|
|
338
332
|
walk(program, {
|
|
339
333
|
enter(node) {
|
|
340
334
|
if (node.type === "CallExpression")
|
|
@@ -352,20 +346,20 @@ async function resolveVue22(code, s) {
|
|
|
352
346
|
const results = [];
|
|
353
347
|
for (const node of nodes) {
|
|
354
348
|
const { callee, arguments: args } = node;
|
|
355
|
-
if (callee.type !== "Identifier" || callee.name !== "_c" || (
|
|
349
|
+
if (callee.type !== "Identifier" || callee.name !== "_c" || _optionalChain([args, 'access', _18 => _18[1], 'optionalAccess', _19 => _19.type]) !== "ObjectExpression")
|
|
356
350
|
continue;
|
|
357
|
-
const directives = (
|
|
351
|
+
const directives = _optionalChain([args, 'access', _20 => _20[1], 'access', _21 => _21.properties, 'access', _22 => _22.find, 'call', _23 => _23(
|
|
358
352
|
(property) => property.type === "ObjectProperty" && property.key.type === "Identifier" && property.key.name === "directives"
|
|
359
|
-
)
|
|
353
|
+
), 'optionalAccess', _24 => _24.value]);
|
|
360
354
|
if (!directives || directives.type !== "ArrayExpression")
|
|
361
355
|
continue;
|
|
362
356
|
for (const directive of directives.elements) {
|
|
363
|
-
if ((directive
|
|
357
|
+
if (_optionalChain([directive, 'optionalAccess', _25 => _25.type]) !== "ObjectExpression")
|
|
364
358
|
continue;
|
|
365
|
-
const nameNode = (
|
|
359
|
+
const nameNode = _optionalChain([directive, 'access', _26 => _26.properties, 'access', _27 => _27.find, 'call', _28 => _28(
|
|
366
360
|
(p) => p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "name"
|
|
367
|
-
)
|
|
368
|
-
if ((nameNode
|
|
361
|
+
), 'optionalAccess', _29 => _29.value]);
|
|
362
|
+
if (_optionalChain([nameNode, 'optionalAccess', _30 => _30.type]) !== "StringLiteral")
|
|
369
363
|
continue;
|
|
370
364
|
const name = nameNode.value;
|
|
371
365
|
if (!name || name.startsWith("_"))
|
|
@@ -406,13 +400,13 @@ async function transformDirective(code, transformer2, s, ctx, sfcPath) {
|
|
|
406
400
|
const results = await (transformer2 === "vue2" ? resolveVue22(code, s) : resolveVue32(code, s));
|
|
407
401
|
for (const { rawName, replace } of results) {
|
|
408
402
|
debug3(`| ${rawName}`);
|
|
409
|
-
const name = `${
|
|
403
|
+
const name = `${_chunk6IWOTYMJcjs.DIRECTIVE_IMPORT_PREFIX}${_chunk6IWOTYMJcjs.pascalCase.call(void 0, rawName)}`;
|
|
410
404
|
ctx.updateUsageMap(sfcPath, [name]);
|
|
411
405
|
const directive = await ctx.findComponent(name, "directive", [sfcPath]);
|
|
412
406
|
if (!directive)
|
|
413
407
|
continue;
|
|
414
408
|
const varName = `__unplugin_directives_${no}`;
|
|
415
|
-
s.prepend(`${
|
|
409
|
+
s.prepend(`${_chunk6IWOTYMJcjs.stringifyComponentImport.call(void 0, { ...directive, as: varName }, ctx)};
|
|
416
410
|
`);
|
|
417
411
|
no += 1;
|
|
418
412
|
replace(varName);
|
|
@@ -431,7 +425,7 @@ function transformer(ctx, transformer2) {
|
|
|
431
425
|
await transformComponent(code, transformer2, s, ctx, sfcPath);
|
|
432
426
|
if (ctx.options.directives)
|
|
433
427
|
await transformDirective(code, transformer2, s, ctx, sfcPath);
|
|
434
|
-
s.prepend(
|
|
428
|
+
s.prepend(_chunk6IWOTYMJcjs.DISABLE_COMMENT);
|
|
435
429
|
const result = { code: s.toString() };
|
|
436
430
|
if (ctx.sourcemap)
|
|
437
431
|
result.map = s.generateMap({ source: id, includeContent: true, hires: "boundary" });
|
|
@@ -447,23 +441,24 @@ var debug5 = {
|
|
|
447
441
|
declaration: _debug2.default.call(void 0, "unplugin-vue-components:declaration"),
|
|
448
442
|
env: _debug2.default.call(void 0, "unplugin-vue-components:env")
|
|
449
443
|
};
|
|
450
|
-
var Context = class {
|
|
451
|
-
constructor(rawOptions) {
|
|
444
|
+
var Context = (_class = class {
|
|
445
|
+
constructor(rawOptions) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);_class.prototype.__init10.call(this);
|
|
452
446
|
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 = _process2.default.cwd();
|
|
460
|
-
this.sourcemap = true;
|
|
461
|
-
this.alias = {};
|
|
462
|
-
this._searched = false;
|
|
463
447
|
this.options = resolveOptions(rawOptions, this.root);
|
|
464
448
|
this.generateDeclaration = _utils.throttle.call(void 0, 500, this._generateDeclaration.bind(this), { noLeading: false });
|
|
465
449
|
this.setTransformer(this.options.transformer);
|
|
466
450
|
}
|
|
451
|
+
|
|
452
|
+
__init() {this.transformer = void 0}
|
|
453
|
+
__init2() {this._componentPaths = /* @__PURE__ */ new Set()}
|
|
454
|
+
__init3() {this._componentNameMap = {}}
|
|
455
|
+
__init4() {this._componentUsageMap = {}}
|
|
456
|
+
__init5() {this._componentCustomMap = {}}
|
|
457
|
+
__init6() {this._directiveCustomMap = {}}
|
|
458
|
+
|
|
459
|
+
__init7() {this.root = _process2.default.cwd()}
|
|
460
|
+
__init8() {this.sourcemap = true}
|
|
461
|
+
__init9() {this.alias = {}}
|
|
467
462
|
setRoot(root) {
|
|
468
463
|
if (this.root === root)
|
|
469
464
|
return;
|
|
@@ -476,7 +471,7 @@ var Context = class {
|
|
|
476
471
|
this.transformer = transformer(this, name || "vue3");
|
|
477
472
|
}
|
|
478
473
|
transform(code, id) {
|
|
479
|
-
const { path, query } =
|
|
474
|
+
const { path, query } = _chunk6IWOTYMJcjs.parseId.call(void 0, id);
|
|
480
475
|
return this.transformer(code, id, path, query);
|
|
481
476
|
}
|
|
482
477
|
setupViteServer(server) {
|
|
@@ -488,14 +483,14 @@ var Context = class {
|
|
|
488
483
|
setupWatcher(watcher) {
|
|
489
484
|
const { globs } = this.options;
|
|
490
485
|
watcher.on("unlink", (path) => {
|
|
491
|
-
if (!
|
|
486
|
+
if (!_chunk6IWOTYMJcjs.matchGlobs.call(void 0, path, globs))
|
|
492
487
|
return;
|
|
493
488
|
path = _utils.slash.call(void 0, path);
|
|
494
489
|
this.removeComponents(path);
|
|
495
490
|
this.onUpdate(path);
|
|
496
491
|
});
|
|
497
492
|
watcher.on("add", (path) => {
|
|
498
|
-
if (!
|
|
493
|
+
if (!_chunk6IWOTYMJcjs.matchGlobs.call(void 0, path, globs))
|
|
499
494
|
return;
|
|
500
495
|
path = _utils.slash.call(void 0, path);
|
|
501
496
|
this.addComponents(path);
|
|
@@ -508,14 +503,14 @@ var Context = class {
|
|
|
508
503
|
setupWatcherWebpack(watcher, emitUpdate) {
|
|
509
504
|
const { globs } = this.options;
|
|
510
505
|
watcher.on("unlink", (path) => {
|
|
511
|
-
if (!
|
|
506
|
+
if (!_chunk6IWOTYMJcjs.matchGlobs.call(void 0, path, globs))
|
|
512
507
|
return;
|
|
513
508
|
path = _utils.slash.call(void 0, path);
|
|
514
509
|
this.removeComponents(path);
|
|
515
510
|
emitUpdate(path, "unlink");
|
|
516
511
|
});
|
|
517
512
|
watcher.on("add", (path) => {
|
|
518
|
-
if (!
|
|
513
|
+
if (!_chunk6IWOTYMJcjs.matchGlobs.call(void 0, path, globs))
|
|
519
514
|
return;
|
|
520
515
|
path = _utils.slash.call(void 0, path);
|
|
521
516
|
this.addComponents(path);
|
|
@@ -571,7 +566,7 @@ var Context = class {
|
|
|
571
566
|
updates: []
|
|
572
567
|
};
|
|
573
568
|
const timestamp = +/* @__PURE__ */ new Date();
|
|
574
|
-
const name =
|
|
569
|
+
const name = _chunk6IWOTYMJcjs.pascalCase.call(void 0, _chunk6IWOTYMJcjs.getNameFromFilePath.call(void 0, path, this.options));
|
|
575
570
|
Object.entries(this._componentUsageMap).forEach(([key, values]) => {
|
|
576
571
|
if (values.has(name)) {
|
|
577
572
|
const r = `/${_utils.slash.call(void 0, _path.relative.call(void 0, this.root, key))}`;
|
|
@@ -589,7 +584,11 @@ var Context = class {
|
|
|
589
584
|
updateComponentNameMap() {
|
|
590
585
|
this._componentNameMap = {};
|
|
591
586
|
Array.from(this._componentPaths).forEach((path) => {
|
|
592
|
-
const name =
|
|
587
|
+
const name = _chunk6IWOTYMJcjs.pascalCase.call(void 0, _chunk6IWOTYMJcjs.getNameFromFilePath.call(void 0, path, this.options));
|
|
588
|
+
if (_chunk6IWOTYMJcjs.isExclude.call(void 0, name, this.options.excludeNames)) {
|
|
589
|
+
debug5.components("exclude", name);
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
593
592
|
if (this._componentNameMap[name] && !this.options.allowOverrides) {
|
|
594
593
|
console.warn(`[unplugin-vue-components] component "${name}"(${path}) has naming conflicts with other components, ignored.`);
|
|
595
594
|
return;
|
|
@@ -607,7 +606,7 @@ var Context = class {
|
|
|
607
606
|
for (const resolver of this.options.resolvers) {
|
|
608
607
|
if (resolver.type !== type)
|
|
609
608
|
continue;
|
|
610
|
-
const result = await resolver.resolve(type === "directive" ? name.slice(
|
|
609
|
+
const result = await resolver.resolve(type === "directive" ? name.slice(_chunk6IWOTYMJcjs.DIRECTIVE_IMPORT_PREFIX.length) : name);
|
|
611
610
|
if (!result)
|
|
612
611
|
continue;
|
|
613
612
|
if (typeof result === "string") {
|
|
@@ -616,9 +615,10 @@ var Context = class {
|
|
|
616
615
|
from: result
|
|
617
616
|
};
|
|
618
617
|
} else {
|
|
619
|
-
info =
|
|
620
|
-
as: name
|
|
621
|
-
|
|
618
|
+
info = {
|
|
619
|
+
as: name,
|
|
620
|
+
..._chunk6IWOTYMJcjs.normalizeComponentInfo.call(void 0, result)
|
|
621
|
+
};
|
|
622
622
|
}
|
|
623
623
|
if (type === "component")
|
|
624
624
|
this.addCustomComponents(info);
|
|
@@ -629,14 +629,14 @@ var Context = class {
|
|
|
629
629
|
return void 0;
|
|
630
630
|
}
|
|
631
631
|
normalizePath(path) {
|
|
632
|
-
|
|
633
|
-
return _chunkVPUTCXXPcjs.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) || []);
|
|
632
|
+
return _chunk6IWOTYMJcjs.resolveAlias.call(void 0, path, _optionalChain([this, 'access', _31 => _31.viteConfig, 'optionalAccess', _32 => _32.resolve, 'optionalAccess', _33 => _33.alias]) || _optionalChain([this, 'access', _34 => _34.viteConfig, 'optionalAccess', _35 => _35.alias]) || []);
|
|
634
633
|
}
|
|
635
634
|
relative(path) {
|
|
636
635
|
if (path.startsWith("/") && !path.startsWith(this.root))
|
|
637
636
|
return _utils.slash.call(void 0, path.slice(1));
|
|
638
637
|
return _utils.slash.call(void 0, _path.relative.call(void 0, this.root, path));
|
|
639
638
|
}
|
|
639
|
+
__init10() {this._searched = false}
|
|
640
640
|
/**
|
|
641
641
|
* This search for components in with the given options.
|
|
642
642
|
* Will be called multiple times to ensure file loaded,
|
|
@@ -655,6 +655,7 @@ var Context = class {
|
|
|
655
655
|
debug5.declaration("generating");
|
|
656
656
|
return writeDeclaration(this, this.options.dts, removeUnused);
|
|
657
657
|
}
|
|
658
|
+
|
|
658
659
|
get componentNameMap() {
|
|
659
660
|
return this._componentNameMap;
|
|
660
661
|
}
|
|
@@ -664,7 +665,7 @@ var Context = class {
|
|
|
664
665
|
get directiveCustomMap() {
|
|
665
666
|
return this._directiveCustomMap;
|
|
666
667
|
}
|
|
667
|
-
};
|
|
668
|
+
}, _class);
|
|
668
669
|
|
|
669
670
|
// src/core/unplugin.ts
|
|
670
671
|
var PLUGIN_NAME = "unplugin:webpack";
|
|
@@ -679,7 +680,7 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
|
|
|
679
680
|
return await ctx.findComponent(name, "component", filename ? [filename] : []);
|
|
680
681
|
},
|
|
681
682
|
stringifyImport(info) {
|
|
682
|
-
return
|
|
683
|
+
return _chunk6IWOTYMJcjs.stringifyComponentImport.call(void 0, info, ctx);
|
|
683
684
|
}
|
|
684
685
|
};
|
|
685
686
|
return {
|
|
@@ -690,7 +691,7 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
|
|
|
690
691
|
return filter(id);
|
|
691
692
|
},
|
|
692
693
|
async transform(code, id) {
|
|
693
|
-
if (!
|
|
694
|
+
if (!_chunk6IWOTYMJcjs.shouldTransform.call(void 0, code))
|
|
694
695
|
return null;
|
|
695
696
|
try {
|
|
696
697
|
const result = await ctx.transform(code, id);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__require
|
|
10
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/core/utils.ts
|
|
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(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/core/utils.ts
|
|
2
2
|
var _path = require('path');
|
|
3
3
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
4
4
|
var _minimatch = require('minimatch');
|
|
@@ -47,8 +47,10 @@ function isEmpty(value) {
|
|
|
47
47
|
}
|
|
48
48
|
function matchGlobs(filepath, globs) {
|
|
49
49
|
for (const glob of globs) {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
const isNegated = glob.startsWith("!");
|
|
51
|
+
const match = _minimatch.minimatch.call(void 0, _utils.slash.call(void 0, filepath), isNegated ? glob.slice(1) : glob);
|
|
52
|
+
if (match)
|
|
53
|
+
return !isNegated;
|
|
52
54
|
}
|
|
53
55
|
return false;
|
|
54
56
|
}
|
|
@@ -111,7 +113,7 @@ function getNameFromFilePath(filePath, options) {
|
|
|
111
113
|
if (directoryAsNamespace) {
|
|
112
114
|
if (globalNamespaces.some((name) => folders.includes(name)))
|
|
113
115
|
folders = folders.filter((f) => !globalNamespaces.includes(f));
|
|
114
|
-
folders = folders.map((f) => f.replace(/[^a-
|
|
116
|
+
folders = folders.map((f) => f.replace(/[^a-z0-9\-]/gi, ""));
|
|
115
117
|
if (filename.toLowerCase() === "index")
|
|
116
118
|
filename = "";
|
|
117
119
|
if (!isEmpty(folders)) {
|
|
@@ -151,12 +153,11 @@ function resolveAlias(filepath, alias) {
|
|
|
151
153
|
return result;
|
|
152
154
|
}
|
|
153
155
|
async function getPkgVersion(pkgName, defaultVersion) {
|
|
154
|
-
var _a;
|
|
155
156
|
try {
|
|
156
157
|
const isExist = _localpkg.isPackageExists.call(void 0, pkgName);
|
|
157
158
|
if (isExist) {
|
|
158
159
|
const pkg = await _localpkg.getPackageInfo.call(void 0, pkgName);
|
|
159
|
-
return (
|
|
160
|
+
return _nullishCoalesce(_optionalChain([pkg, 'optionalAccess', _2 => _2.version]), () => ( defaultVersion));
|
|
160
161
|
} else {
|
|
161
162
|
return defaultVersion;
|
|
162
163
|
}
|
|
@@ -170,6 +171,22 @@ function shouldTransform(code) {
|
|
|
170
171
|
return false;
|
|
171
172
|
return true;
|
|
172
173
|
}
|
|
174
|
+
function isExclude(name, exclude) {
|
|
175
|
+
if (!exclude)
|
|
176
|
+
return false;
|
|
177
|
+
if (typeof exclude === "string")
|
|
178
|
+
return name === exclude;
|
|
179
|
+
if (exclude instanceof RegExp)
|
|
180
|
+
return !!name.match(exclude);
|
|
181
|
+
if (Array.isArray(exclude)) {
|
|
182
|
+
for (const item of exclude) {
|
|
183
|
+
if (name === item || name.match(item))
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
|
|
173
190
|
|
|
174
191
|
|
|
175
192
|
|
|
@@ -187,4 +204,4 @@ function shouldTransform(code) {
|
|
|
187
204
|
|
|
188
205
|
|
|
189
206
|
|
|
190
|
-
exports.DISABLE_COMMENT = DISABLE_COMMENT; exports.DIRECTIVE_IMPORT_PREFIX = DIRECTIVE_IMPORT_PREFIX; exports.isSSR = isSSR; exports.pascalCase = pascalCase; exports.camelCase = camelCase; exports.kebabCase = kebabCase; exports.parseId = parseId; exports.matchGlobs = matchGlobs; exports.getTransformedPath = getTransformedPath; exports.normalizeComponentInfo = normalizeComponentInfo; exports.stringifyComponentImport = stringifyComponentImport; exports.getNameFromFilePath = getNameFromFilePath; exports.resolveAlias = resolveAlias; exports.getPkgVersion = getPkgVersion; exports.shouldTransform = shouldTransform;
|
|
207
|
+
exports.DISABLE_COMMENT = DISABLE_COMMENT; exports.DIRECTIVE_IMPORT_PREFIX = DIRECTIVE_IMPORT_PREFIX; exports.isSSR = isSSR; exports.pascalCase = pascalCase; exports.camelCase = camelCase; exports.kebabCase = kebabCase; exports.parseId = parseId; exports.matchGlobs = matchGlobs; exports.getTransformedPath = getTransformedPath; exports.normalizeComponentInfo = normalizeComponentInfo; exports.stringifyComponentImport = stringifyComponentImport; exports.getNameFromFilePath = getNameFromFilePath; exports.resolveAlias = resolveAlias; exports.getPkgVersion = getPkgVersion; exports.shouldTransform = shouldTransform; exports.isExclude = isExclude;
|