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
|
@@ -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
|
+
};
|
|
@@ -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(slash(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 = isPackageExists(pkgName);
|
|
157
158
|
if (isExist) {
|
|
158
159
|
const pkg = await getPackageInfo(pkgName);
|
|
159
|
-
return
|
|
160
|
+
return pkg?.version ?? defaultVersion;
|
|
160
161
|
} else {
|
|
161
162
|
return defaultVersion;
|
|
162
163
|
}
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});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
|
+
|
|
9
|
+
|
|
10
|
+
exports.__require = __require;
|
|
@@ -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 _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,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var _chunkWJIU4Q36cjs = require('./chunk-WJIU4Q36.cjs');
|
|
13
|
+
var _chunk5RDO6MHScjs = require('./chunk-5RDO6MHS.cjs');
|
|
18
14
|
|
|
19
15
|
// src/core/unplugin.ts
|
|
20
16
|
var _fs = require('fs');
|
|
@@ -85,7 +81,6 @@ function resolveGlobsExclude(root, glob) {
|
|
|
85
81
|
return `${excludeReg.test(glob) ? "!" : ""}${_path.resolve.call(void 0, 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 = _utils.toArray.call(void 0, 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 = _nullishCoalesce(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 = _localpkg.getPackageInfoSync.call(void 0, "vue", { paths: [root] })) == null ? void 0 : _a.version) || "3";
|
|
116
|
+
const raw = _optionalChain([_localpkg.getPackageInfoSync.call(void 0, "vue", { paths: [root] }), 'optionalAccess', _ => _.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 @@ var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_f
|
|
|
133
127
|
|
|
134
128
|
var debug = _debug2.default.call(void 0, "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 = _fastglob2.default.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 && !_optionalChain([ctx, 'access', _2 => _2.options, 'access', _3 => _3.resolvers, 'optionalAccess', _4 => _4.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 @@ function searchComponents(ctx) {
|
|
|
153
146
|
|
|
154
147
|
var _promises = require('fs/promises');
|
|
155
148
|
|
|
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 = _optionalChain([/export\s+interface\s+GlobalComponents\s*\{.*?\}/s, 'access', _5 => _5.exec, 'call', _6 => _6(code), 'optionalAccess', _7 => _7[0]]);
|
|
171
163
|
if (componentDeclaration)
|
|
172
164
|
imports.component = extractImports(componentDeclaration);
|
|
173
|
-
const directiveDeclaration = (
|
|
165
|
+
const directiveDeclaration = _optionalChain([/export\s+interface\s+ComponentCustomProperties\s*\{.*?\}/s, 'access', _8 => _8.exec, 'call', _9 => _9(code), 'optionalAccess', _10 => _10[0]]);
|
|
174
166
|
if (directiveDeclaration)
|
|
175
167
|
imports.directive = extractImports(directiveDeclaration);
|
|
176
168
|
return imports;
|
|
@@ -178,7 +170,7 @@ function parseDeclaration(code) {
|
|
|
178
170
|
function stringifyComponentInfo(filepath, { from: path, as: name, name: importName }, importPathTransform) {
|
|
179
171
|
if (!name)
|
|
180
172
|
return void 0;
|
|
181
|
-
path =
|
|
173
|
+
path = _chunk5RDO6MHScjs.getTransformedPath.call(void 0, path, importPathTransform);
|
|
182
174
|
const related = _path.isAbsolute.call(void 0, path) ? `./${_path.relative.call(void 0, _path.dirname.call(void 0, filepath), path)}` : path;
|
|
183
175
|
const entry = `typeof import('${_utils.slash.call(void 0, related)}')['${importName || "default"}']`;
|
|
184
176
|
return [name, entry];
|
|
@@ -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({ ..._optionalChain([originalImports, 'optionalAccess', _11 => _11.component]), ...imports.component }),
|
|
213
|
+
directive: stringifyDeclarationImports({ ..._optionalChain([originalImports, 'optionalAccess', _12 => _12.directive]), ...imports.directive })
|
|
219
214
|
};
|
|
220
215
|
let code = `/* eslint-disable */
|
|
221
216
|
// @ts-nocheck
|
|
@@ -263,7 +258,7 @@ var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireD
|
|
|
263
258
|
var debug2 = _debug2.default.call(void 0, "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;
|
|
@@ -296,12 +291,12 @@ async function transformComponent(code, transformer2, s, ctx, sfcPath) {
|
|
|
296
291
|
const results = transformer2 === "vue2" ? resolveVue2(code, s) : resolveVue3(code, s);
|
|
297
292
|
for (const { rawName, replace } of results) {
|
|
298
293
|
debug2(`| ${rawName}`);
|
|
299
|
-
const name =
|
|
294
|
+
const name = _chunk5RDO6MHScjs.pascalCase.call(void 0, rawName);
|
|
300
295
|
ctx.updateUsageMap(sfcPath, [name]);
|
|
301
296
|
const component = await ctx.findComponent(name, "component", [sfcPath]);
|
|
302
297
|
if (component) {
|
|
303
298
|
const varName = `__unplugin_components_${no}`;
|
|
304
|
-
s.prepend(`${
|
|
299
|
+
s.prepend(`${_chunk5RDO6MHScjs.stringifyComponentImport.call(void 0, { ...component, as: varName }, ctx)};
|
|
305
300
|
`);
|
|
306
301
|
no += 1;
|
|
307
302
|
replace(varName);
|
|
@@ -316,17 +311,15 @@ async function transformComponent(code, transformer2, s, ctx, sfcPath) {
|
|
|
316
311
|
// src/core/transforms/directive/vue2.ts
|
|
317
312
|
|
|
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 = _optionalChain([renderFn, 'optionalAccess', _13 => _13.declarations, 'access', _14 => _14[0], 'access', _15 => _15.init, 'optionalAccess', _16 => _16.body, 'optionalAccess', _17 => _17.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 (!_localpkg.isPackageExists.call(void 0, "@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 _localpkg.importModule.call(void 0, "@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 Promise.resolve().then(() => require("./src-
|
|
330
|
+
const { walk } = await Promise.resolve().then(() => require("./src-KNP44FKK.cjs"));
|
|
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" || _optionalChain([args, 'access', _18 => _18[1], 'optionalAccess', _19 => _19.type]) !== "ObjectExpression")
|
|
356
349
|
continue;
|
|
357
|
-
const directives = (
|
|
350
|
+
const directives = _optionalChain([args, 'access', _20 => _20[1], 'access', _21 => _21.properties, 'access', _22 => _22.find, 'call', _23 => _23(
|
|
358
351
|
(property) => property.type === "ObjectProperty" && property.key.type === "Identifier" && property.key.name === "directives"
|
|
359
|
-
)
|
|
352
|
+
), 'optionalAccess', _24 => _24.value]);
|
|
360
353
|
if (!directives || directives.type !== "ArrayExpression")
|
|
361
354
|
continue;
|
|
362
355
|
for (const directive of directives.elements) {
|
|
363
|
-
if ((directive
|
|
356
|
+
if (_optionalChain([directive, 'optionalAccess', _25 => _25.type]) !== "ObjectExpression")
|
|
364
357
|
continue;
|
|
365
|
-
const nameNode = (
|
|
358
|
+
const nameNode = _optionalChain([directive, 'access', _26 => _26.properties, 'access', _27 => _27.find, 'call', _28 => _28(
|
|
366
359
|
(p) => p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "name"
|
|
367
|
-
)
|
|
368
|
-
if ((nameNode
|
|
360
|
+
), 'optionalAccess', _29 => _29.value]);
|
|
361
|
+
if (_optionalChain([nameNode, 'optionalAccess', _30 => _30.type]) !== "StringLiteral")
|
|
369
362
|
continue;
|
|
370
363
|
const name = nameNode.value;
|
|
371
364
|
if (!name || name.startsWith("_"))
|
|
@@ -406,13 +399,13 @@ async function transformDirective(code, transformer2, s, ctx, sfcPath) {
|
|
|
406
399
|
const results = await (transformer2 === "vue2" ? resolveVue22(code, s) : resolveVue32(code, s));
|
|
407
400
|
for (const { rawName, replace } of results) {
|
|
408
401
|
debug3(`| ${rawName}`);
|
|
409
|
-
const name = `${
|
|
402
|
+
const name = `${_chunk5RDO6MHScjs.DIRECTIVE_IMPORT_PREFIX}${_chunk5RDO6MHScjs.pascalCase.call(void 0, rawName)}`;
|
|
410
403
|
ctx.updateUsageMap(sfcPath, [name]);
|
|
411
404
|
const directive = await ctx.findComponent(name, "directive", [sfcPath]);
|
|
412
405
|
if (!directive)
|
|
413
406
|
continue;
|
|
414
407
|
const varName = `__unplugin_directives_${no}`;
|
|
415
|
-
s.prepend(`${
|
|
408
|
+
s.prepend(`${_chunk5RDO6MHScjs.stringifyComponentImport.call(void 0, { ...directive, as: varName }, ctx)};
|
|
416
409
|
`);
|
|
417
410
|
no += 1;
|
|
418
411
|
replace(varName);
|
|
@@ -431,7 +424,7 @@ function transformer(ctx, transformer2) {
|
|
|
431
424
|
await transformComponent(code, transformer2, s, ctx, sfcPath);
|
|
432
425
|
if (ctx.options.directives)
|
|
433
426
|
await transformDirective(code, transformer2, s, ctx, sfcPath);
|
|
434
|
-
s.prepend(
|
|
427
|
+
s.prepend(_chunk5RDO6MHScjs.DISABLE_COMMENT);
|
|
435
428
|
const result = { code: s.toString() };
|
|
436
429
|
if (ctx.sourcemap)
|
|
437
430
|
result.map = s.generateMap({ source: id, includeContent: true, hires: "boundary" });
|
|
@@ -447,23 +440,24 @@ var debug5 = {
|
|
|
447
440
|
declaration: _debug2.default.call(void 0, "unplugin-vue-components:declaration"),
|
|
448
441
|
env: _debug2.default.call(void 0, "unplugin-vue-components:env")
|
|
449
442
|
};
|
|
450
|
-
var Context = class {
|
|
451
|
-
constructor(rawOptions) {
|
|
443
|
+
var Context = (_class = class {
|
|
444
|
+
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
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 = _process2.default.cwd();
|
|
460
|
-
this.sourcemap = true;
|
|
461
|
-
this.alias = {};
|
|
462
|
-
this._searched = false;
|
|
463
446
|
this.options = resolveOptions(rawOptions, this.root);
|
|
464
447
|
this.generateDeclaration = _utils.throttle.call(void 0, 500, this._generateDeclaration.bind(this), { noLeading: false });
|
|
465
448
|
this.setTransformer(this.options.transformer);
|
|
466
449
|
}
|
|
450
|
+
|
|
451
|
+
__init() {this.transformer = void 0}
|
|
452
|
+
__init2() {this._componentPaths = /* @__PURE__ */ new Set()}
|
|
453
|
+
__init3() {this._componentNameMap = {}}
|
|
454
|
+
__init4() {this._componentUsageMap = {}}
|
|
455
|
+
__init5() {this._componentCustomMap = {}}
|
|
456
|
+
__init6() {this._directiveCustomMap = {}}
|
|
457
|
+
|
|
458
|
+
__init7() {this.root = _process2.default.cwd()}
|
|
459
|
+
__init8() {this.sourcemap = true}
|
|
460
|
+
__init9() {this.alias = {}}
|
|
467
461
|
setRoot(root) {
|
|
468
462
|
if (this.root === root)
|
|
469
463
|
return;
|
|
@@ -476,7 +470,7 @@ var Context = class {
|
|
|
476
470
|
this.transformer = transformer(this, name || "vue3");
|
|
477
471
|
}
|
|
478
472
|
transform(code, id) {
|
|
479
|
-
const { path, query } =
|
|
473
|
+
const { path, query } = _chunk5RDO6MHScjs.parseId.call(void 0, id);
|
|
480
474
|
return this.transformer(code, id, path, query);
|
|
481
475
|
}
|
|
482
476
|
setupViteServer(server) {
|
|
@@ -488,14 +482,14 @@ var Context = class {
|
|
|
488
482
|
setupWatcher(watcher) {
|
|
489
483
|
const { globs } = this.options;
|
|
490
484
|
watcher.on("unlink", (path) => {
|
|
491
|
-
if (!
|
|
485
|
+
if (!_chunk5RDO6MHScjs.matchGlobs.call(void 0, path, globs))
|
|
492
486
|
return;
|
|
493
487
|
path = _utils.slash.call(void 0, path);
|
|
494
488
|
this.removeComponents(path);
|
|
495
489
|
this.onUpdate(path);
|
|
496
490
|
});
|
|
497
491
|
watcher.on("add", (path) => {
|
|
498
|
-
if (!
|
|
492
|
+
if (!_chunk5RDO6MHScjs.matchGlobs.call(void 0, path, globs))
|
|
499
493
|
return;
|
|
500
494
|
path = _utils.slash.call(void 0, path);
|
|
501
495
|
this.addComponents(path);
|
|
@@ -508,14 +502,14 @@ var Context = class {
|
|
|
508
502
|
setupWatcherWebpack(watcher, emitUpdate) {
|
|
509
503
|
const { globs } = this.options;
|
|
510
504
|
watcher.on("unlink", (path) => {
|
|
511
|
-
if (!
|
|
505
|
+
if (!_chunk5RDO6MHScjs.matchGlobs.call(void 0, path, globs))
|
|
512
506
|
return;
|
|
513
507
|
path = _utils.slash.call(void 0, path);
|
|
514
508
|
this.removeComponents(path);
|
|
515
509
|
emitUpdate(path, "unlink");
|
|
516
510
|
});
|
|
517
511
|
watcher.on("add", (path) => {
|
|
518
|
-
if (!
|
|
512
|
+
if (!_chunk5RDO6MHScjs.matchGlobs.call(void 0, path, globs))
|
|
519
513
|
return;
|
|
520
514
|
path = _utils.slash.call(void 0, path);
|
|
521
515
|
this.addComponents(path);
|
|
@@ -571,7 +565,7 @@ var Context = class {
|
|
|
571
565
|
updates: []
|
|
572
566
|
};
|
|
573
567
|
const timestamp = +/* @__PURE__ */ new Date();
|
|
574
|
-
const name =
|
|
568
|
+
const name = _chunk5RDO6MHScjs.pascalCase.call(void 0, _chunk5RDO6MHScjs.getNameFromFilePath.call(void 0, path, this.options));
|
|
575
569
|
Object.entries(this._componentUsageMap).forEach(([key, values]) => {
|
|
576
570
|
if (values.has(name)) {
|
|
577
571
|
const r = `/${_utils.slash.call(void 0, _path.relative.call(void 0, this.root, key))}`;
|
|
@@ -589,7 +583,7 @@ var Context = class {
|
|
|
589
583
|
updateComponentNameMap() {
|
|
590
584
|
this._componentNameMap = {};
|
|
591
585
|
Array.from(this._componentPaths).forEach((path) => {
|
|
592
|
-
const name =
|
|
586
|
+
const name = _chunk5RDO6MHScjs.pascalCase.call(void 0, _chunk5RDO6MHScjs.getNameFromFilePath.call(void 0, path, this.options));
|
|
593
587
|
if (this._componentNameMap[name] && !this.options.allowOverrides) {
|
|
594
588
|
console.warn(`[unplugin-vue-components] component "${name}"(${path}) has naming conflicts with other components, ignored.`);
|
|
595
589
|
return;
|
|
@@ -607,7 +601,7 @@ var Context = class {
|
|
|
607
601
|
for (const resolver of this.options.resolvers) {
|
|
608
602
|
if (resolver.type !== type)
|
|
609
603
|
continue;
|
|
610
|
-
const result = await resolver.resolve(type === "directive" ? name.slice(
|
|
604
|
+
const result = await resolver.resolve(type === "directive" ? name.slice(_chunk5RDO6MHScjs.DIRECTIVE_IMPORT_PREFIX.length) : name);
|
|
611
605
|
if (!result)
|
|
612
606
|
continue;
|
|
613
607
|
if (typeof result === "string") {
|
|
@@ -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
|
+
..._chunk5RDO6MHScjs.normalizeComponentInfo.call(void 0, 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 _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) || []);
|
|
627
|
+
return _chunk5RDO6MHScjs.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
628
|
}
|
|
635
629
|
relative(path) {
|
|
636
630
|
if (path.startsWith("/") && !path.startsWith(this.root))
|
|
637
631
|
return _utils.slash.call(void 0, path.slice(1));
|
|
638
632
|
return _utils.slash.call(void 0, _path.relative.call(void 0, this.root, path));
|
|
639
633
|
}
|
|
634
|
+
__init10() {this._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
|
+
|
|
658
654
|
get componentNameMap() {
|
|
659
655
|
return this._componentNameMap;
|
|
660
656
|
}
|
|
@@ -664,7 +660,7 @@ var Context = class {
|
|
|
664
660
|
get directiveCustomMap() {
|
|
665
661
|
return this._directiveCustomMap;
|
|
666
662
|
}
|
|
667
|
-
};
|
|
663
|
+
}, _class);
|
|
668
664
|
|
|
669
665
|
// src/core/unplugin.ts
|
|
670
666
|
var PLUGIN_NAME = "unplugin:webpack";
|
|
@@ -679,7 +675,7 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
|
|
|
679
675
|
return await ctx.findComponent(name, "component", filename ? [filename] : []);
|
|
680
676
|
},
|
|
681
677
|
stringifyImport(info) {
|
|
682
|
-
return
|
|
678
|
+
return _chunk5RDO6MHScjs.stringifyComponentImport.call(void 0, info, ctx);
|
|
683
679
|
}
|
|
684
680
|
};
|
|
685
681
|
return {
|
|
@@ -690,7 +686,7 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
|
|
|
690
686
|
return filter(id);
|
|
691
687
|
},
|
|
692
688
|
async transform(code, id) {
|
|
693
|
-
if (!
|
|
689
|
+
if (!_chunk5RDO6MHScjs.shouldTransform.call(void 0, code))
|
|
694
690
|
return null;
|
|
695
691
|
try {
|
|
696
692
|
const result = await ctx.transform(code, id);
|