unplugin-vue-components 0.20.0 → 0.21.1
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-FD6BQCQ7.js → chunk-2GXY7E6X.js} +7 -5
- package/dist/{chunk-O6TSTZRE.mjs → chunk-667B3WUW.mjs} +6 -4
- package/dist/{chunk-46PS2JCI.js → chunk-N4XEWXLG.js} +136 -74
- package/dist/{chunk-7NLFLZZX.mjs → chunk-SX77T22J.mjs} +122 -60
- 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.js +20 -20
- package/dist/resolvers.mjs +1 -1
- package/dist/rollup.js +3 -3
- package/dist/rollup.mjs +2 -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 +22 -21
|
@@ -10,6 +10,7 @@ var _localpkg = require('local-pkg');
|
|
|
10
10
|
|
|
11
11
|
// src/core/constants.ts
|
|
12
12
|
var DISABLE_COMMENT = "/* unplugin-vue-components disabled */";
|
|
13
|
+
var DIRECTIVE_IMPORT_PREFIX = "v";
|
|
13
14
|
|
|
14
15
|
// src/core/utils.ts
|
|
15
16
|
var isSSR = Boolean(process.env.SSR || process.env.SSG || process.env.VITE_SSR || process.env.VITE_SSG);
|
|
@@ -51,9 +52,9 @@ function matchGlobs(filepath, globs) {
|
|
|
51
52
|
}
|
|
52
53
|
return false;
|
|
53
54
|
}
|
|
54
|
-
function getTransformedPath(path,
|
|
55
|
-
if (
|
|
56
|
-
const result =
|
|
55
|
+
function getTransformedPath(path, importPathTransform) {
|
|
56
|
+
if (importPathTransform) {
|
|
57
|
+
const result = importPathTransform(path);
|
|
57
58
|
if (result != null)
|
|
58
59
|
path = result;
|
|
59
60
|
}
|
|
@@ -81,7 +82,7 @@ function normalizeComponetInfo(info) {
|
|
|
81
82
|
return info;
|
|
82
83
|
}
|
|
83
84
|
function stringifyComponentImport({ as: name, from: path, name: importName, sideEffects }, ctx) {
|
|
84
|
-
path = getTransformedPath(path, ctx);
|
|
85
|
+
path = getTransformedPath(path, ctx.options.importPathTransform);
|
|
85
86
|
const imports = [
|
|
86
87
|
stringifyImport({ as: name, from: path, name: importName })
|
|
87
88
|
];
|
|
@@ -180,4 +181,5 @@ function resolveImportPath(importName) {
|
|
|
180
181
|
|
|
181
182
|
|
|
182
183
|
|
|
183
|
-
|
|
184
|
+
|
|
185
|
+
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.normalizeComponetInfo = normalizeComponetInfo; exports.stringifyComponentImport = stringifyComponentImport; exports.getNameFromFilePath = getNameFromFilePath; exports.resolveAlias = resolveAlias; exports.getPkgVersion = getPkgVersion; exports.shouldTransform = shouldTransform; exports.resolveImportPath = resolveImportPath;
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
// src/core/constants.ts
|
|
12
12
|
var DISABLE_COMMENT = "/* unplugin-vue-components disabled */";
|
|
13
|
+
var DIRECTIVE_IMPORT_PREFIX = "v";
|
|
13
14
|
|
|
14
15
|
// src/core/utils.ts
|
|
15
16
|
var isSSR = Boolean(process.env.SSR || process.env.SSG || process.env.VITE_SSR || process.env.VITE_SSG);
|
|
@@ -51,9 +52,9 @@ function matchGlobs(filepath, globs) {
|
|
|
51
52
|
}
|
|
52
53
|
return false;
|
|
53
54
|
}
|
|
54
|
-
function getTransformedPath(path,
|
|
55
|
-
if (
|
|
56
|
-
const result =
|
|
55
|
+
function getTransformedPath(path, importPathTransform) {
|
|
56
|
+
if (importPathTransform) {
|
|
57
|
+
const result = importPathTransform(path);
|
|
57
58
|
if (result != null)
|
|
58
59
|
path = result;
|
|
59
60
|
}
|
|
@@ -81,7 +82,7 @@ function normalizeComponetInfo(info) {
|
|
|
81
82
|
return info;
|
|
82
83
|
}
|
|
83
84
|
function stringifyComponentImport({ as: name, from: path, name: importName, sideEffects }, ctx) {
|
|
84
|
-
path = getTransformedPath(path, ctx);
|
|
85
|
+
path = getTransformedPath(path, ctx.options.importPathTransform);
|
|
85
86
|
const imports = [
|
|
86
87
|
stringifyImport({ as: name, from: path, name: importName })
|
|
87
88
|
];
|
|
@@ -166,6 +167,7 @@ function resolveImportPath(importName) {
|
|
|
166
167
|
|
|
167
168
|
export {
|
|
168
169
|
DISABLE_COMMENT,
|
|
170
|
+
DIRECTIVE_IMPORT_PREFIX,
|
|
169
171
|
isSSR,
|
|
170
172
|
pascalCase,
|
|
171
173
|
camelCase,
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
var _chunk2GXY7E6Xjs = require('./chunk-2GXY7E6X.js');
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
|
|
@@ -17,6 +18,7 @@ var _chunkFD6BQCQ7js = require('./chunk-FD6BQCQ7.js');
|
|
|
17
18
|
var _chunkBTQOTIPQjs = require('./chunk-BTQOTIPQ.js');
|
|
18
19
|
|
|
19
20
|
// src/core/unplugin.ts
|
|
21
|
+
var _fs = require('fs');
|
|
20
22
|
var _unplugin = require('unplugin');
|
|
21
23
|
var _pluginutils = require('@rollup/pluginutils');
|
|
22
24
|
var _chokidar = require('chokidar'); var _chokidar2 = _interopRequireDefault(_chokidar);
|
|
@@ -68,6 +70,7 @@ var defaultOptions = {
|
|
|
68
70
|
deep: true,
|
|
69
71
|
dts: _localpkg.isPackageExists.call(void 0, "typescript"),
|
|
70
72
|
directoryAsNamespace: false,
|
|
73
|
+
collapseSamePrefixes: false,
|
|
71
74
|
globalNamespaces: [],
|
|
72
75
|
resolvers: [],
|
|
73
76
|
importPathTransform: (v) => v,
|
|
@@ -133,54 +136,98 @@ function searchComponents(ctx) {
|
|
|
133
136
|
|
|
134
137
|
// src/core/declaration.ts
|
|
135
138
|
|
|
136
|
-
var _fs = require('fs');
|
|
137
139
|
|
|
140
|
+
var _promises = require('fs/promises');
|
|
141
|
+
|
|
142
|
+
var multilineCommentsRE = /\/\*.*?\*\//gms;
|
|
143
|
+
var singlelineCommentsRE = /\/\/.*$/gm;
|
|
144
|
+
function extractImports(code) {
|
|
145
|
+
return Object.fromEntries(Array.from(code.matchAll(/['"]?([^\s'"]+)['"]?\s*:\s*(.+?)[,;\n]/g)).map((i) => [i[1], i[2]]));
|
|
146
|
+
}
|
|
138
147
|
function parseDeclaration(code) {
|
|
148
|
+
var _a, _b;
|
|
139
149
|
if (!code)
|
|
140
|
-
return
|
|
141
|
-
|
|
150
|
+
return;
|
|
151
|
+
code = code.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, "");
|
|
152
|
+
const imports = {
|
|
153
|
+
component: {},
|
|
154
|
+
directive: {}
|
|
155
|
+
};
|
|
156
|
+
const componentDeclaration = (_a = /export\s+interface\s+GlobalComponents\s*{(.*?)}/s.exec(code)) == null ? void 0 : _a[0];
|
|
157
|
+
if (componentDeclaration)
|
|
158
|
+
imports.component = extractImports(componentDeclaration);
|
|
159
|
+
const directiveDeclaration = (_b = /export\s+interface\s+ComponentCustomProperties\s*{(.*?)}/s.exec(code)) == null ? void 0 : _b[0];
|
|
160
|
+
if (directiveDeclaration)
|
|
161
|
+
imports.directive = extractImports(directiveDeclaration);
|
|
162
|
+
return imports;
|
|
142
163
|
}
|
|
143
|
-
|
|
144
|
-
|
|
164
|
+
function stringifyComponentInfo(filepath, { from: path, as: name, name: importName }, importPathTransform) {
|
|
165
|
+
if (!name)
|
|
166
|
+
return void 0;
|
|
167
|
+
path = _chunk2GXY7E6Xjs.getTransformedPath.call(void 0, path, importPathTransform);
|
|
168
|
+
const related = _path.isAbsolute.call(void 0, path) ? `./${_path.relative.call(void 0, _path.dirname.call(void 0, filepath), path)}` : path;
|
|
169
|
+
const entry = `typeof import('${_utils.slash.call(void 0, related)}')['${importName || "default"}']`;
|
|
170
|
+
return [name, entry];
|
|
171
|
+
}
|
|
172
|
+
function stringifyComponentsInfo(filepath, components, importPathTransform) {
|
|
173
|
+
return Object.fromEntries(components.map((info) => stringifyComponentInfo(filepath, info, importPathTransform)).filter(_utils.notNullish));
|
|
174
|
+
}
|
|
175
|
+
function getDeclarationImports(ctx, filepath) {
|
|
176
|
+
const component = stringifyComponentsInfo(filepath, [
|
|
145
177
|
...Object.values(_chunkBTQOTIPQjs.__spreadValues.call(void 0, _chunkBTQOTIPQjs.__spreadValues.call(void 0, {}, ctx.componentNameMap), ctx.componentCustomMap)),
|
|
146
178
|
...resolveTypeImports(ctx.options.types)
|
|
147
|
-
];
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
return void 0;
|
|
151
|
-
path = _chunkFD6BQCQ7js.getTransformedPath.call(void 0, path, ctx);
|
|
152
|
-
const related = _path.isAbsolute.call(void 0, path) ? `./${_path.relative.call(void 0, _path.dirname.call(void 0, filepath), path)}` : path;
|
|
153
|
-
let entry = `typeof import('${_utils.slash.call(void 0, related)}')`;
|
|
154
|
-
if (importName)
|
|
155
|
-
entry += `['${importName}']`;
|
|
156
|
-
else
|
|
157
|
-
entry += "['default']";
|
|
158
|
-
return [name, entry];
|
|
159
|
-
}).filter(_utils.notNullish));
|
|
160
|
-
if (!Object.keys(imports).length)
|
|
179
|
+
], ctx.options.importPathTransform);
|
|
180
|
+
const directive = stringifyComponentsInfo(filepath, Object.values(ctx.directiveCustomMap), ctx.options.importPathTransform);
|
|
181
|
+
if (Object.keys(component).length + Object.keys(directive).length === 0)
|
|
161
182
|
return;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
183
|
+
return { component, directive };
|
|
184
|
+
}
|
|
185
|
+
function stringifyDeclarationImports(imports) {
|
|
186
|
+
return Object.entries(imports).sort(([a], [b]) => a.localeCompare(b)).map(([name, v]) => {
|
|
165
187
|
if (!/^\w+$/.test(name))
|
|
166
188
|
name = `'${name}'`;
|
|
167
189
|
return `${name}: ${v}`;
|
|
168
190
|
});
|
|
169
|
-
|
|
191
|
+
}
|
|
192
|
+
function getDeclaration(ctx, filepath, originalImports) {
|
|
193
|
+
const imports = getDeclarationImports(ctx, filepath);
|
|
194
|
+
if (!imports)
|
|
195
|
+
return;
|
|
196
|
+
const declarations = {
|
|
197
|
+
component: stringifyDeclarationImports(_chunkBTQOTIPQjs.__spreadValues.call(void 0, _chunkBTQOTIPQjs.__spreadValues.call(void 0, {}, originalImports == null ? void 0 : originalImports.component), imports.component)),
|
|
198
|
+
directive: stringifyDeclarationImports(_chunkBTQOTIPQjs.__spreadValues.call(void 0, _chunkBTQOTIPQjs.__spreadValues.call(void 0, {}, originalImports == null ? void 0 : originalImports.directive), imports.directive))
|
|
199
|
+
};
|
|
200
|
+
let code = `// generated by unplugin-vue-components
|
|
170
201
|
// We suggest you to commit this file into source control
|
|
171
202
|
// Read more: https://github.com/vuejs/core/pull/3399
|
|
172
203
|
import '@vue/runtime-core'
|
|
173
204
|
|
|
174
|
-
|
|
205
|
+
export {}
|
|
206
|
+
|
|
207
|
+
declare module '@vue/runtime-core' {`;
|
|
208
|
+
if (Object.keys(declarations.component).length > 0) {
|
|
209
|
+
code += `
|
|
175
210
|
export interface GlobalComponents {
|
|
176
|
-
${
|
|
211
|
+
${declarations.component.join("\n ")}
|
|
212
|
+
}`;
|
|
213
|
+
}
|
|
214
|
+
if (Object.keys(declarations.directive).length > 0) {
|
|
215
|
+
code += `
|
|
216
|
+
export interface ComponentCustomProperties {
|
|
217
|
+
${declarations.directive.join("\n ")}
|
|
218
|
+
}`;
|
|
177
219
|
}
|
|
220
|
+
code += "\n}\n";
|
|
221
|
+
return code;
|
|
178
222
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
223
|
+
async function writeDeclaration(ctx, filepath, removeUnused = false) {
|
|
224
|
+
const originalContent = _fs.existsSync.call(void 0, filepath) ? await _promises.readFile.call(void 0, filepath, "utf-8") : "";
|
|
225
|
+
const originalImports = removeUnused ? void 0 : parseDeclaration(originalContent);
|
|
226
|
+
const code = getDeclaration(ctx, filepath, originalImports);
|
|
227
|
+
if (!code)
|
|
228
|
+
return;
|
|
182
229
|
if (code !== originalContent)
|
|
183
|
-
await
|
|
230
|
+
await _promises.writeFile.call(void 0, filepath, code, "utf-8");
|
|
184
231
|
}
|
|
185
232
|
|
|
186
233
|
// src/core/transformer.ts
|
|
@@ -225,12 +272,12 @@ async function transformComponent(code, transformer2, s, ctx, sfcPath) {
|
|
|
225
272
|
const results = transformer2 === "vue2" ? resolveVue2(code, s) : resolveVue3(code, s);
|
|
226
273
|
for (const { rawName, replace } of results) {
|
|
227
274
|
debug2(`| ${rawName}`);
|
|
228
|
-
const name =
|
|
275
|
+
const name = _chunk2GXY7E6Xjs.pascalCase.call(void 0, rawName);
|
|
229
276
|
ctx.updateUsageMap(sfcPath, [name]);
|
|
230
277
|
const component = await ctx.findComponent(name, "component", [sfcPath]);
|
|
231
278
|
if (component) {
|
|
232
279
|
const varName = `__unplugin_components_${no}`;
|
|
233
|
-
s.prepend(`${
|
|
280
|
+
s.prepend(`${_chunk2GXY7E6Xjs.stringifyComponentImport.call(void 0, _chunkBTQOTIPQjs.__spreadProps.call(void 0, _chunkBTQOTIPQjs.__spreadValues.call(void 0, {}, component), { as: varName }), ctx)};
|
|
234
281
|
`);
|
|
235
282
|
no += 1;
|
|
236
283
|
replace(varName);
|
|
@@ -322,13 +369,13 @@ async function transformDirective(code, transformer2, s, ctx, sfcPath) {
|
|
|
322
369
|
const results = await (transformer2 === "vue2" ? resolveVue22(code, s) : resolveVue32(code, s));
|
|
323
370
|
for (const { rawName, replace } of results) {
|
|
324
371
|
debug3(`| ${rawName}`);
|
|
325
|
-
const name =
|
|
372
|
+
const name = `${_chunk2GXY7E6Xjs.DIRECTIVE_IMPORT_PREFIX}${_chunk2GXY7E6Xjs.pascalCase.call(void 0, rawName)}`;
|
|
326
373
|
ctx.updateUsageMap(sfcPath, [name]);
|
|
327
374
|
const directive = await ctx.findComponent(name, "directive", [sfcPath]);
|
|
328
375
|
if (!directive)
|
|
329
376
|
continue;
|
|
330
377
|
const varName = `__unplugin_directives_${no}`;
|
|
331
|
-
s.prepend(`${
|
|
378
|
+
s.prepend(`${_chunk2GXY7E6Xjs.stringifyComponentImport.call(void 0, _chunkBTQOTIPQjs.__spreadProps.call(void 0, _chunkBTQOTIPQjs.__spreadValues.call(void 0, {}, directive), { as: varName }), ctx)};
|
|
332
379
|
`);
|
|
333
380
|
no += 1;
|
|
334
381
|
replace(varName);
|
|
@@ -347,7 +394,7 @@ function transformer(ctx, transformer2) {
|
|
|
347
394
|
await transformComponent(code, transformer2, s, ctx, sfcPath);
|
|
348
395
|
if (ctx.options.directives)
|
|
349
396
|
await transformDirective(code, transformer2, s, ctx, sfcPath);
|
|
350
|
-
s.prepend(
|
|
397
|
+
s.prepend(_chunk2GXY7E6Xjs.DISABLE_COMMENT);
|
|
351
398
|
const result = { code: s.toString() };
|
|
352
399
|
if (ctx.sourcemap)
|
|
353
400
|
result.map = s.generateMap({ source: id, includeContent: true });
|
|
@@ -371,12 +418,13 @@ var Context = class {
|
|
|
371
418
|
this._componentNameMap = {};
|
|
372
419
|
this._componentUsageMap = {};
|
|
373
420
|
this._componentCustomMap = {};
|
|
421
|
+
this._directiveCustomMap = {};
|
|
374
422
|
this.root = process.cwd();
|
|
375
423
|
this.sourcemap = true;
|
|
376
424
|
this.alias = {};
|
|
377
425
|
this._searched = false;
|
|
378
426
|
this.options = resolveOptions(rawOptions, this.root);
|
|
379
|
-
this.generateDeclaration = _utils.throttle.call(void 0, 500, false, this.
|
|
427
|
+
this.generateDeclaration = _utils.throttle.call(void 0, 500, false, this._generateDeclaration.bind(this));
|
|
380
428
|
this.setTransformer(this.options.transformer);
|
|
381
429
|
}
|
|
382
430
|
setRoot(root) {
|
|
@@ -391,7 +439,7 @@ var Context = class {
|
|
|
391
439
|
this.transformer = transformer(this, name || "vue3");
|
|
392
440
|
}
|
|
393
441
|
transform(code, id) {
|
|
394
|
-
const { path, query } =
|
|
442
|
+
const { path, query } = _chunk2GXY7E6Xjs.parseId.call(void 0, id);
|
|
395
443
|
return this.transformer(code, id, path, query);
|
|
396
444
|
}
|
|
397
445
|
setupViteServer(server) {
|
|
@@ -403,14 +451,14 @@ var Context = class {
|
|
|
403
451
|
setupWatcher(watcher) {
|
|
404
452
|
const { globs } = this.options;
|
|
405
453
|
watcher.on("unlink", (path) => {
|
|
406
|
-
if (!
|
|
454
|
+
if (!_chunk2GXY7E6Xjs.matchGlobs.call(void 0, path, globs))
|
|
407
455
|
return;
|
|
408
456
|
path = _utils.slash.call(void 0, path);
|
|
409
457
|
this.removeComponents(path);
|
|
410
458
|
this.onUpdate(path);
|
|
411
459
|
});
|
|
412
460
|
watcher.on("add", (path) => {
|
|
413
|
-
if (!
|
|
461
|
+
if (!_chunk2GXY7E6Xjs.matchGlobs.call(void 0, path, globs))
|
|
414
462
|
return;
|
|
415
463
|
path = _utils.slash.call(void 0, path);
|
|
416
464
|
this.addComponents(path);
|
|
@@ -420,14 +468,14 @@ var Context = class {
|
|
|
420
468
|
setupWatcherWebpack(watcher, emitUpdate) {
|
|
421
469
|
const { globs } = this.options;
|
|
422
470
|
watcher.on("unlink", (path) => {
|
|
423
|
-
if (!
|
|
471
|
+
if (!_chunk2GXY7E6Xjs.matchGlobs.call(void 0, path, globs))
|
|
424
472
|
return;
|
|
425
473
|
path = _utils.slash.call(void 0, path);
|
|
426
474
|
this.removeComponents(path);
|
|
427
475
|
emitUpdate(path, "unlink");
|
|
428
476
|
});
|
|
429
477
|
watcher.on("add", (path) => {
|
|
430
|
-
if (!
|
|
478
|
+
if (!_chunk2GXY7E6Xjs.matchGlobs.call(void 0, path, globs))
|
|
431
479
|
return;
|
|
432
480
|
path = _utils.slash.call(void 0, path);
|
|
433
481
|
this.addComponents(path);
|
|
@@ -455,6 +503,10 @@ var Context = class {
|
|
|
455
503
|
if (info.as)
|
|
456
504
|
this._componentCustomMap[info.as] = info;
|
|
457
505
|
}
|
|
506
|
+
addCustomDirectives(info) {
|
|
507
|
+
if (info.as)
|
|
508
|
+
this._directiveCustomMap[info.as] = info;
|
|
509
|
+
}
|
|
458
510
|
removeComponents(paths) {
|
|
459
511
|
debug5.components("remove", paths);
|
|
460
512
|
const size = this._componentPaths.size;
|
|
@@ -474,7 +526,7 @@ var Context = class {
|
|
|
474
526
|
updates: []
|
|
475
527
|
};
|
|
476
528
|
const timestamp = +new Date();
|
|
477
|
-
const name =
|
|
529
|
+
const name = _chunk2GXY7E6Xjs.pascalCase.call(void 0, _chunk2GXY7E6Xjs.getNameFromFilePath.call(void 0, path, this.options));
|
|
478
530
|
Object.entries(this._componentUsageMap).forEach(([key, values]) => {
|
|
479
531
|
if (values.has(name)) {
|
|
480
532
|
const r = `/${_utils.slash.call(void 0, _path.relative.call(void 0, this.root, key))}`;
|
|
@@ -492,7 +544,7 @@ var Context = class {
|
|
|
492
544
|
updateComponentNameMap() {
|
|
493
545
|
this._componentNameMap = {};
|
|
494
546
|
Array.from(this._componentPaths).forEach((path) => {
|
|
495
|
-
const name =
|
|
547
|
+
const name = _chunk2GXY7E6Xjs.pascalCase.call(void 0, _chunk2GXY7E6Xjs.getNameFromFilePath.call(void 0, path, this.options));
|
|
496
548
|
if (this._componentNameMap[name] && !this.options.allowOverrides) {
|
|
497
549
|
console.warn(`[unplugin-vue-components] component "${name}"(${path}) has naming conflicts with other components, ignored.`);
|
|
498
550
|
return;
|
|
@@ -510,29 +562,30 @@ var Context = class {
|
|
|
510
562
|
for (const resolver of this.options.resolvers) {
|
|
511
563
|
if (resolver.type !== type)
|
|
512
564
|
continue;
|
|
513
|
-
const result = await resolver.resolve(name);
|
|
514
|
-
if (result)
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
}, _chunkFD6BQCQ7js.normalizeComponetInfo.call(void 0, result));
|
|
526
|
-
this.addCustomComponents(info);
|
|
527
|
-
return info;
|
|
528
|
-
}
|
|
565
|
+
const result = await resolver.resolve(type === "directive" ? name.slice(_chunk2GXY7E6Xjs.DIRECTIVE_IMPORT_PREFIX.length) : name);
|
|
566
|
+
if (!result)
|
|
567
|
+
continue;
|
|
568
|
+
if (typeof result === "string") {
|
|
569
|
+
info = {
|
|
570
|
+
as: name,
|
|
571
|
+
from: result
|
|
572
|
+
};
|
|
573
|
+
} else {
|
|
574
|
+
info = _chunkBTQOTIPQjs.__spreadValues.call(void 0, {
|
|
575
|
+
as: name
|
|
576
|
+
}, _chunk2GXY7E6Xjs.normalizeComponetInfo.call(void 0, result));
|
|
529
577
|
}
|
|
578
|
+
if (type === "component")
|
|
579
|
+
this.addCustomComponents(info);
|
|
580
|
+
else if (type === "directive")
|
|
581
|
+
this.addCustomDirectives(info);
|
|
582
|
+
return info;
|
|
530
583
|
}
|
|
531
584
|
return void 0;
|
|
532
585
|
}
|
|
533
586
|
normalizePath(path) {
|
|
534
587
|
var _a, _b, _c;
|
|
535
|
-
return
|
|
588
|
+
return _chunk2GXY7E6Xjs.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) || []);
|
|
536
589
|
}
|
|
537
590
|
relative(path) {
|
|
538
591
|
if (path.startsWith("/") && !path.startsWith(this.root))
|
|
@@ -546,11 +599,11 @@ var Context = class {
|
|
|
546
599
|
debug5.search(this._componentNameMap);
|
|
547
600
|
this._searched = true;
|
|
548
601
|
}
|
|
549
|
-
|
|
602
|
+
_generateDeclaration(removeUnused = !this._server) {
|
|
550
603
|
if (!this.options.dts)
|
|
551
604
|
return;
|
|
552
605
|
debug5.decleration("generating");
|
|
553
|
-
|
|
606
|
+
return writeDeclaration(this, this.options.dts, removeUnused);
|
|
554
607
|
}
|
|
555
608
|
get componentNameMap() {
|
|
556
609
|
return this._componentNameMap;
|
|
@@ -558,9 +611,13 @@ var Context = class {
|
|
|
558
611
|
get componentCustomMap() {
|
|
559
612
|
return this._componentCustomMap;
|
|
560
613
|
}
|
|
614
|
+
get directiveCustomMap() {
|
|
615
|
+
return this._directiveCustomMap;
|
|
616
|
+
}
|
|
561
617
|
};
|
|
562
618
|
|
|
563
619
|
// src/core/unplugin.ts
|
|
620
|
+
var PLUGIN_NAME = "unplugin:webpack";
|
|
564
621
|
var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
|
|
565
622
|
const filter = _pluginutils.createFilter.call(void 0, options.include || [/\.vue$/, /\.vue\?vue/], options.exclude || [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/]);
|
|
566
623
|
const ctx = new Context(options);
|
|
@@ -569,7 +626,7 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
|
|
|
569
626
|
return await ctx.findComponent(name, "component", filename ? [filename] : []);
|
|
570
627
|
},
|
|
571
628
|
stringifyImport(info) {
|
|
572
|
-
return
|
|
629
|
+
return _chunk2GXY7E6Xjs.stringifyComponentImport.call(void 0, info, ctx);
|
|
573
630
|
}
|
|
574
631
|
};
|
|
575
632
|
return {
|
|
@@ -580,7 +637,7 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
|
|
|
580
637
|
return filter(id);
|
|
581
638
|
},
|
|
582
639
|
async transform(code, id) {
|
|
583
|
-
if (!
|
|
640
|
+
if (!_chunk2GXY7E6Xjs.shouldTransform.call(void 0, code))
|
|
584
641
|
return null;
|
|
585
642
|
try {
|
|
586
643
|
const result = await ctx.transform(code, id);
|
|
@@ -596,9 +653,10 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
|
|
|
596
653
|
ctx.sourcemap = true;
|
|
597
654
|
if (config.plugins.find((i) => i.name === "vite-plugin-vue2"))
|
|
598
655
|
ctx.setTransformer("vue2");
|
|
599
|
-
if (options.dts) {
|
|
656
|
+
if (ctx.options.dts) {
|
|
600
657
|
ctx.searchGlob();
|
|
601
|
-
ctx.
|
|
658
|
+
if (!_fs.existsSync.call(void 0, ctx.options.dts))
|
|
659
|
+
ctx.generateDeclaration();
|
|
602
660
|
}
|
|
603
661
|
if (config.build.watch && config.command === "build")
|
|
604
662
|
ctx.setupWatcher(_chokidar2.default.watch(ctx.options.globs));
|
|
@@ -608,16 +666,20 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
|
|
|
608
666
|
}
|
|
609
667
|
},
|
|
610
668
|
webpack(compiler) {
|
|
611
|
-
|
|
612
|
-
return;
|
|
669
|
+
let watcher;
|
|
613
670
|
let fileDepQueue = [];
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
671
|
+
compiler.hooks.watchRun.tap(PLUGIN_NAME, () => {
|
|
672
|
+
if (!watcher && compiler.watching) {
|
|
673
|
+
watcher = compiler.watching;
|
|
674
|
+
ctx.setupWatcherWebpack(_chokidar2.default.watch(ctx.options.globs), (path, type) => {
|
|
675
|
+
fileDepQueue.push({ path, type });
|
|
676
|
+
process.nextTick(() => {
|
|
677
|
+
watcher.invalidate();
|
|
678
|
+
});
|
|
679
|
+
});
|
|
680
|
+
}
|
|
619
681
|
});
|
|
620
|
-
compiler.hooks.compilation.tap(
|
|
682
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
621
683
|
if (fileDepQueue.length) {
|
|
622
684
|
fileDepQueue.forEach(({ path, type }) => {
|
|
623
685
|
if (type === "unlink")
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DIRECTIVE_IMPORT_PREFIX,
|
|
2
3
|
DISABLE_COMMENT,
|
|
3
4
|
getNameFromFilePath,
|
|
4
5
|
getTransformedPath,
|
|
@@ -9,7 +10,7 @@ import {
|
|
|
9
10
|
resolveAlias,
|
|
10
11
|
shouldTransform,
|
|
11
12
|
stringifyComponentImport
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-667B3WUW.mjs";
|
|
13
14
|
import {
|
|
14
15
|
__require,
|
|
15
16
|
__spreadProps,
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
} from "./chunk-ZKNUHGJ4.mjs";
|
|
18
19
|
|
|
19
20
|
// src/core/unplugin.ts
|
|
21
|
+
import { existsSync as existsSync2 } from "fs";
|
|
20
22
|
import { createUnplugin } from "unplugin";
|
|
21
23
|
import { createFilter } from "@rollup/pluginutils";
|
|
22
24
|
import chokidar from "chokidar";
|
|
@@ -68,6 +70,7 @@ var defaultOptions = {
|
|
|
68
70
|
deep: true,
|
|
69
71
|
dts: isPackageExists2("typescript"),
|
|
70
72
|
directoryAsNamespace: false,
|
|
73
|
+
collapseSamePrefixes: false,
|
|
71
74
|
globalNamespaces: [],
|
|
72
75
|
resolvers: [],
|
|
73
76
|
importPathTransform: (v) => v,
|
|
@@ -133,54 +136,98 @@ function searchComponents(ctx) {
|
|
|
133
136
|
|
|
134
137
|
// src/core/declaration.ts
|
|
135
138
|
import { dirname, isAbsolute, relative } from "path";
|
|
136
|
-
import { existsSync
|
|
139
|
+
import { existsSync } from "fs";
|
|
140
|
+
import { readFile, writeFile } from "fs/promises";
|
|
137
141
|
import { notNullish as notNullish2, slash as slash2 } from "@antfu/utils";
|
|
142
|
+
var multilineCommentsRE = /\/\*.*?\*\//gms;
|
|
143
|
+
var singlelineCommentsRE = /\/\/.*$/gm;
|
|
144
|
+
function extractImports(code) {
|
|
145
|
+
return Object.fromEntries(Array.from(code.matchAll(/['"]?([^\s'"]+)['"]?\s*:\s*(.+?)[,;\n]/g)).map((i) => [i[1], i[2]]));
|
|
146
|
+
}
|
|
138
147
|
function parseDeclaration(code) {
|
|
148
|
+
var _a, _b;
|
|
139
149
|
if (!code)
|
|
140
|
-
return
|
|
141
|
-
|
|
150
|
+
return;
|
|
151
|
+
code = code.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, "");
|
|
152
|
+
const imports = {
|
|
153
|
+
component: {},
|
|
154
|
+
directive: {}
|
|
155
|
+
};
|
|
156
|
+
const componentDeclaration = (_a = /export\s+interface\s+GlobalComponents\s*{(.*?)}/s.exec(code)) == null ? void 0 : _a[0];
|
|
157
|
+
if (componentDeclaration)
|
|
158
|
+
imports.component = extractImports(componentDeclaration);
|
|
159
|
+
const directiveDeclaration = (_b = /export\s+interface\s+ComponentCustomProperties\s*{(.*?)}/s.exec(code)) == null ? void 0 : _b[0];
|
|
160
|
+
if (directiveDeclaration)
|
|
161
|
+
imports.directive = extractImports(directiveDeclaration);
|
|
162
|
+
return imports;
|
|
142
163
|
}
|
|
143
|
-
|
|
144
|
-
|
|
164
|
+
function stringifyComponentInfo(filepath, { from: path, as: name, name: importName }, importPathTransform) {
|
|
165
|
+
if (!name)
|
|
166
|
+
return void 0;
|
|
167
|
+
path = getTransformedPath(path, importPathTransform);
|
|
168
|
+
const related = isAbsolute(path) ? `./${relative(dirname(filepath), path)}` : path;
|
|
169
|
+
const entry = `typeof import('${slash2(related)}')['${importName || "default"}']`;
|
|
170
|
+
return [name, entry];
|
|
171
|
+
}
|
|
172
|
+
function stringifyComponentsInfo(filepath, components, importPathTransform) {
|
|
173
|
+
return Object.fromEntries(components.map((info) => stringifyComponentInfo(filepath, info, importPathTransform)).filter(notNullish2));
|
|
174
|
+
}
|
|
175
|
+
function getDeclarationImports(ctx, filepath) {
|
|
176
|
+
const component = stringifyComponentsInfo(filepath, [
|
|
145
177
|
...Object.values(__spreadValues(__spreadValues({}, ctx.componentNameMap), ctx.componentCustomMap)),
|
|
146
178
|
...resolveTypeImports(ctx.options.types)
|
|
147
|
-
];
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
return void 0;
|
|
151
|
-
path = getTransformedPath(path, ctx);
|
|
152
|
-
const related = isAbsolute(path) ? `./${relative(dirname(filepath), path)}` : path;
|
|
153
|
-
let entry = `typeof import('${slash2(related)}')`;
|
|
154
|
-
if (importName)
|
|
155
|
-
entry += `['${importName}']`;
|
|
156
|
-
else
|
|
157
|
-
entry += "['default']";
|
|
158
|
-
return [name, entry];
|
|
159
|
-
}).filter(notNullish2));
|
|
160
|
-
if (!Object.keys(imports).length)
|
|
179
|
+
], ctx.options.importPathTransform);
|
|
180
|
+
const directive = stringifyComponentsInfo(filepath, Object.values(ctx.directiveCustomMap), ctx.options.importPathTransform);
|
|
181
|
+
if (Object.keys(component).length + Object.keys(directive).length === 0)
|
|
161
182
|
return;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
183
|
+
return { component, directive };
|
|
184
|
+
}
|
|
185
|
+
function stringifyDeclarationImports(imports) {
|
|
186
|
+
return Object.entries(imports).sort(([a], [b]) => a.localeCompare(b)).map(([name, v]) => {
|
|
165
187
|
if (!/^\w+$/.test(name))
|
|
166
188
|
name = `'${name}'`;
|
|
167
189
|
return `${name}: ${v}`;
|
|
168
190
|
});
|
|
169
|
-
|
|
191
|
+
}
|
|
192
|
+
function getDeclaration(ctx, filepath, originalImports) {
|
|
193
|
+
const imports = getDeclarationImports(ctx, filepath);
|
|
194
|
+
if (!imports)
|
|
195
|
+
return;
|
|
196
|
+
const declarations = {
|
|
197
|
+
component: stringifyDeclarationImports(__spreadValues(__spreadValues({}, originalImports == null ? void 0 : originalImports.component), imports.component)),
|
|
198
|
+
directive: stringifyDeclarationImports(__spreadValues(__spreadValues({}, originalImports == null ? void 0 : originalImports.directive), imports.directive))
|
|
199
|
+
};
|
|
200
|
+
let code = `// generated by unplugin-vue-components
|
|
170
201
|
// We suggest you to commit this file into source control
|
|
171
202
|
// Read more: https://github.com/vuejs/core/pull/3399
|
|
172
203
|
import '@vue/runtime-core'
|
|
173
204
|
|
|
174
|
-
|
|
205
|
+
export {}
|
|
206
|
+
|
|
207
|
+
declare module '@vue/runtime-core' {`;
|
|
208
|
+
if (Object.keys(declarations.component).length > 0) {
|
|
209
|
+
code += `
|
|
175
210
|
export interface GlobalComponents {
|
|
176
|
-
${
|
|
211
|
+
${declarations.component.join("\n ")}
|
|
212
|
+
}`;
|
|
213
|
+
}
|
|
214
|
+
if (Object.keys(declarations.directive).length > 0) {
|
|
215
|
+
code += `
|
|
216
|
+
export interface ComponentCustomProperties {
|
|
217
|
+
${declarations.directive.join("\n ")}
|
|
218
|
+
}`;
|
|
177
219
|
}
|
|
220
|
+
code += "\n}\n";
|
|
221
|
+
return code;
|
|
178
222
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
223
|
+
async function writeDeclaration(ctx, filepath, removeUnused = false) {
|
|
224
|
+
const originalContent = existsSync(filepath) ? await readFile(filepath, "utf-8") : "";
|
|
225
|
+
const originalImports = removeUnused ? void 0 : parseDeclaration(originalContent);
|
|
226
|
+
const code = getDeclaration(ctx, filepath, originalImports);
|
|
227
|
+
if (!code)
|
|
228
|
+
return;
|
|
182
229
|
if (code !== originalContent)
|
|
183
|
-
await
|
|
230
|
+
await writeFile(filepath, code, "utf-8");
|
|
184
231
|
}
|
|
185
232
|
|
|
186
233
|
// src/core/transformer.ts
|
|
@@ -322,7 +369,7 @@ async function transformDirective(code, transformer2, s, ctx, sfcPath) {
|
|
|
322
369
|
const results = await (transformer2 === "vue2" ? resolveVue22(code, s) : resolveVue32(code, s));
|
|
323
370
|
for (const { rawName, replace } of results) {
|
|
324
371
|
debug3(`| ${rawName}`);
|
|
325
|
-
const name = pascalCase(rawName)
|
|
372
|
+
const name = `${DIRECTIVE_IMPORT_PREFIX}${pascalCase(rawName)}`;
|
|
326
373
|
ctx.updateUsageMap(sfcPath, [name]);
|
|
327
374
|
const directive = await ctx.findComponent(name, "directive", [sfcPath]);
|
|
328
375
|
if (!directive)
|
|
@@ -371,12 +418,13 @@ var Context = class {
|
|
|
371
418
|
this._componentNameMap = {};
|
|
372
419
|
this._componentUsageMap = {};
|
|
373
420
|
this._componentCustomMap = {};
|
|
421
|
+
this._directiveCustomMap = {};
|
|
374
422
|
this.root = process.cwd();
|
|
375
423
|
this.sourcemap = true;
|
|
376
424
|
this.alias = {};
|
|
377
425
|
this._searched = false;
|
|
378
426
|
this.options = resolveOptions(rawOptions, this.root);
|
|
379
|
-
this.generateDeclaration = throttle(500, false, this.
|
|
427
|
+
this.generateDeclaration = throttle(500, false, this._generateDeclaration.bind(this));
|
|
380
428
|
this.setTransformer(this.options.transformer);
|
|
381
429
|
}
|
|
382
430
|
setRoot(root) {
|
|
@@ -455,6 +503,10 @@ var Context = class {
|
|
|
455
503
|
if (info.as)
|
|
456
504
|
this._componentCustomMap[info.as] = info;
|
|
457
505
|
}
|
|
506
|
+
addCustomDirectives(info) {
|
|
507
|
+
if (info.as)
|
|
508
|
+
this._directiveCustomMap[info.as] = info;
|
|
509
|
+
}
|
|
458
510
|
removeComponents(paths) {
|
|
459
511
|
debug5.components("remove", paths);
|
|
460
512
|
const size = this._componentPaths.size;
|
|
@@ -510,23 +562,24 @@ var Context = class {
|
|
|
510
562
|
for (const resolver of this.options.resolvers) {
|
|
511
563
|
if (resolver.type !== type)
|
|
512
564
|
continue;
|
|
513
|
-
const result = await resolver.resolve(name);
|
|
514
|
-
if (result)
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
}, normalizeComponetInfo(result));
|
|
526
|
-
this.addCustomComponents(info);
|
|
527
|
-
return info;
|
|
528
|
-
}
|
|
565
|
+
const result = await resolver.resolve(type === "directive" ? name.slice(DIRECTIVE_IMPORT_PREFIX.length) : name);
|
|
566
|
+
if (!result)
|
|
567
|
+
continue;
|
|
568
|
+
if (typeof result === "string") {
|
|
569
|
+
info = {
|
|
570
|
+
as: name,
|
|
571
|
+
from: result
|
|
572
|
+
};
|
|
573
|
+
} else {
|
|
574
|
+
info = __spreadValues({
|
|
575
|
+
as: name
|
|
576
|
+
}, normalizeComponetInfo(result));
|
|
529
577
|
}
|
|
578
|
+
if (type === "component")
|
|
579
|
+
this.addCustomComponents(info);
|
|
580
|
+
else if (type === "directive")
|
|
581
|
+
this.addCustomDirectives(info);
|
|
582
|
+
return info;
|
|
530
583
|
}
|
|
531
584
|
return void 0;
|
|
532
585
|
}
|
|
@@ -546,11 +599,11 @@ var Context = class {
|
|
|
546
599
|
debug5.search(this._componentNameMap);
|
|
547
600
|
this._searched = true;
|
|
548
601
|
}
|
|
549
|
-
|
|
602
|
+
_generateDeclaration(removeUnused = !this._server) {
|
|
550
603
|
if (!this.options.dts)
|
|
551
604
|
return;
|
|
552
605
|
debug5.decleration("generating");
|
|
553
|
-
|
|
606
|
+
return writeDeclaration(this, this.options.dts, removeUnused);
|
|
554
607
|
}
|
|
555
608
|
get componentNameMap() {
|
|
556
609
|
return this._componentNameMap;
|
|
@@ -558,9 +611,13 @@ var Context = class {
|
|
|
558
611
|
get componentCustomMap() {
|
|
559
612
|
return this._componentCustomMap;
|
|
560
613
|
}
|
|
614
|
+
get directiveCustomMap() {
|
|
615
|
+
return this._directiveCustomMap;
|
|
616
|
+
}
|
|
561
617
|
};
|
|
562
618
|
|
|
563
619
|
// src/core/unplugin.ts
|
|
620
|
+
var PLUGIN_NAME = "unplugin:webpack";
|
|
564
621
|
var unplugin_default = createUnplugin((options = {}) => {
|
|
565
622
|
const filter = createFilter(options.include || [/\.vue$/, /\.vue\?vue/], options.exclude || [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/]);
|
|
566
623
|
const ctx = new Context(options);
|
|
@@ -596,9 +653,10 @@ var unplugin_default = createUnplugin((options = {}) => {
|
|
|
596
653
|
ctx.sourcemap = true;
|
|
597
654
|
if (config.plugins.find((i) => i.name === "vite-plugin-vue2"))
|
|
598
655
|
ctx.setTransformer("vue2");
|
|
599
|
-
if (options.dts) {
|
|
656
|
+
if (ctx.options.dts) {
|
|
600
657
|
ctx.searchGlob();
|
|
601
|
-
ctx.
|
|
658
|
+
if (!existsSync2(ctx.options.dts))
|
|
659
|
+
ctx.generateDeclaration();
|
|
602
660
|
}
|
|
603
661
|
if (config.build.watch && config.command === "build")
|
|
604
662
|
ctx.setupWatcher(chokidar.watch(ctx.options.globs));
|
|
@@ -608,16 +666,20 @@ var unplugin_default = createUnplugin((options = {}) => {
|
|
|
608
666
|
}
|
|
609
667
|
},
|
|
610
668
|
webpack(compiler) {
|
|
611
|
-
|
|
612
|
-
return;
|
|
669
|
+
let watcher;
|
|
613
670
|
let fileDepQueue = [];
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
671
|
+
compiler.hooks.watchRun.tap(PLUGIN_NAME, () => {
|
|
672
|
+
if (!watcher && compiler.watching) {
|
|
673
|
+
watcher = compiler.watching;
|
|
674
|
+
ctx.setupWatcherWebpack(chokidar.watch(ctx.options.globs), (path, type) => {
|
|
675
|
+
fileDepQueue.push({ path, type });
|
|
676
|
+
process.nextTick(() => {
|
|
677
|
+
watcher.invalidate();
|
|
678
|
+
});
|
|
679
|
+
});
|
|
680
|
+
}
|
|
619
681
|
});
|
|
620
|
-
compiler.hooks.compilation.tap(
|
|
682
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
621
683
|
if (fileDepQueue.length) {
|
|
622
684
|
fileDepQueue.forEach(({ path, type }) => {
|
|
623
685
|
if (type === "unlink")
|
package/dist/esbuild.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunkN4XEWXLGjs = require('./chunk-N4XEWXLG.js');
|
|
4
|
+
require('./chunk-2GXY7E6X.js');
|
|
5
5
|
require('./chunk-BTQOTIPQ.js');
|
|
6
6
|
require('./chunk-6F4PWJZI.js');
|
|
7
7
|
|
|
8
8
|
// src/esbuild.ts
|
|
9
|
-
var esbuild_default =
|
|
9
|
+
var esbuild_default = _chunkN4XEWXLGjs.unplugin_default.esbuild;
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
module.exports = esbuild_default;
|
package/dist/esbuild.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkN4XEWXLGjs = require('./chunk-N4XEWXLG.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk2GXY7E6Xjs = require('./chunk-2GXY7E6X.js');
|
|
9
9
|
require('./chunk-BTQOTIPQ.js');
|
|
10
10
|
require('./chunk-6F4PWJZI.js');
|
|
11
11
|
|
|
@@ -13,4 +13,4 @@ require('./chunk-6F4PWJZI.js');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
exports.camelCase =
|
|
16
|
+
exports.camelCase = _chunk2GXY7E6Xjs.camelCase; exports.default = _chunkN4XEWXLGjs.unplugin_default; exports.kebabCase = _chunk2GXY7E6Xjs.kebabCase; exports.pascalCase = _chunk2GXY7E6Xjs.pascalCase;
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
unplugin_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SX77T22J.mjs";
|
|
4
4
|
import {
|
|
5
5
|
camelCase,
|
|
6
6
|
kebabCase,
|
|
7
7
|
pascalCase
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-667B3WUW.mjs";
|
|
9
9
|
import "./chunk-ZKNUHGJ4.mjs";
|
|
10
10
|
import "./chunk-WBQAMGXK.mjs";
|
|
11
11
|
export {
|
package/dist/nuxt.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunkN4XEWXLGjs = require('./chunk-N4XEWXLG.js');
|
|
4
|
+
require('./chunk-2GXY7E6X.js');
|
|
5
5
|
require('./chunk-BTQOTIPQ.js');
|
|
6
6
|
require('./chunk-6F4PWJZI.js');
|
|
7
7
|
|
|
@@ -9,11 +9,11 @@ require('./chunk-6F4PWJZI.js');
|
|
|
9
9
|
function nuxt_default(options) {
|
|
10
10
|
this.extendBuild((config) => {
|
|
11
11
|
config.plugins = config.plugins || [];
|
|
12
|
-
config.plugins.unshift(
|
|
12
|
+
config.plugins.unshift(_chunkN4XEWXLGjs.unplugin_default.webpack(options));
|
|
13
13
|
});
|
|
14
14
|
this.nuxt.hook("vite:extend", async (vite) => {
|
|
15
15
|
vite.config.plugins = vite.config.plugins || [];
|
|
16
|
-
vite.config.plugins.push(
|
|
16
|
+
vite.config.plugins.push(_chunkN4XEWXLGjs.unplugin_default.vite(options));
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
|
package/dist/nuxt.mjs
CHANGED
package/dist/resolvers.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk2GXY7E6Xjs = require('./chunk-2GXY7E6X.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -165,7 +165,7 @@ function getStyleDir(compName) {
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
if (!styleDir)
|
|
168
|
-
styleDir =
|
|
168
|
+
styleDir = _chunk2GXY7E6Xjs.kebabCase.call(void 0, compName);
|
|
169
169
|
return styleDir;
|
|
170
170
|
}
|
|
171
171
|
function getSideEffects(compName, options) {
|
|
@@ -350,7 +350,7 @@ function resolveComponent(name, options) {
|
|
|
350
350
|
from: "@element-plus/icons-vue"
|
|
351
351
|
};
|
|
352
352
|
}
|
|
353
|
-
const partialName =
|
|
353
|
+
const partialName = _chunk2GXY7E6Xjs.kebabCase.call(void 0, name.slice(2));
|
|
354
354
|
const { version, ssr } = options;
|
|
355
355
|
if (compareVersions.compare(version, "1.1.0-beta.1", ">=")) {
|
|
356
356
|
return {
|
|
@@ -397,7 +397,7 @@ function ElementPlusResolver(options = {}) {
|
|
|
397
397
|
return optionsResolved;
|
|
398
398
|
optionsResolved = _chunkBTQOTIPQjs.__spreadValues.call(void 0, {
|
|
399
399
|
ssr: false,
|
|
400
|
-
version: await
|
|
400
|
+
version: await _chunk2GXY7E6Xjs.getPkgVersion.call(void 0, "element-plus", "2.2.2"),
|
|
401
401
|
importStyle: "css",
|
|
402
402
|
directives: true,
|
|
403
403
|
exclude: void 0
|
|
@@ -443,7 +443,7 @@ function ElementUiResolver(options = {}) {
|
|
|
443
443
|
resolve: (name) => {
|
|
444
444
|
if (/^El[A-Z]/.test(name)) {
|
|
445
445
|
const compName = name.slice(2);
|
|
446
|
-
const partialName =
|
|
446
|
+
const partialName = _chunk2GXY7E6Xjs.kebabCase.call(void 0, compName);
|
|
447
447
|
if (partialName === "collapse-transition") {
|
|
448
448
|
return {
|
|
449
449
|
from: `element-ui/lib/transitions/${partialName}`
|
|
@@ -553,7 +553,7 @@ function IduxResolver(options = {}) {
|
|
|
553
553
|
let dirname = specialComponents[name];
|
|
554
554
|
if (!dirname) {
|
|
555
555
|
const nameIndex = packageName === "pro" ? 2 : 1;
|
|
556
|
-
dirname =
|
|
556
|
+
dirname = _chunk2GXY7E6Xjs.kebabCase.call(void 0, name).split("-")[nameIndex];
|
|
557
557
|
}
|
|
558
558
|
const path = `@idux/${packageName}/${dirname}`;
|
|
559
559
|
let sideEffects;
|
|
@@ -719,10 +719,10 @@ function PrimeVueResolver(options = {}) {
|
|
|
719
719
|
}
|
|
720
720
|
|
|
721
721
|
// src/core/resolvers/vant.ts
|
|
722
|
-
var moduleType =
|
|
722
|
+
var moduleType = _chunk2GXY7E6Xjs.isSSR ? "lib" : "es";
|
|
723
723
|
function getSideEffects4(dirName, options) {
|
|
724
724
|
const { importStyle = true } = options;
|
|
725
|
-
if (!importStyle ||
|
|
725
|
+
if (!importStyle || _chunk2GXY7E6Xjs.isSSR)
|
|
726
726
|
return;
|
|
727
727
|
if (importStyle === "less")
|
|
728
728
|
return `vant/${moduleType}/${dirName}/style/less`;
|
|
@@ -739,7 +739,7 @@ function VantResolver(options = {}) {
|
|
|
739
739
|
return {
|
|
740
740
|
name: partialName,
|
|
741
741
|
from: `vant/${moduleType}`,
|
|
742
|
-
sideEffects: getSideEffects4(
|
|
742
|
+
sideEffects: getSideEffects4(_chunk2GXY7E6Xjs.kebabCase.call(void 0, partialName), options)
|
|
743
743
|
};
|
|
744
744
|
}
|
|
745
745
|
}
|
|
@@ -758,9 +758,9 @@ function getResolved(name, options) {
|
|
|
758
758
|
const sideEffects = [];
|
|
759
759
|
if (importStyle || importCss) {
|
|
760
760
|
if (importStyle === "less" || importLess)
|
|
761
|
-
sideEffects.push(`${path}/es/${
|
|
761
|
+
sideEffects.push(`${path}/es/${_chunk2GXY7E6Xjs.kebabCase.call(void 0, name)}/style/less.js`);
|
|
762
762
|
else
|
|
763
|
-
sideEffects.push(`${path}/es/${
|
|
763
|
+
sideEffects.push(`${path}/es/${_chunk2GXY7E6Xjs.kebabCase.call(void 0, name)}/style`);
|
|
764
764
|
}
|
|
765
765
|
return {
|
|
766
766
|
from: path,
|
|
@@ -820,15 +820,15 @@ function VeuiResolver(options = {}) {
|
|
|
820
820
|
};
|
|
821
821
|
}
|
|
822
822
|
var formatters = {
|
|
823
|
-
"kebab-case":
|
|
824
|
-
"camelCase":
|
|
825
|
-
"PascalCase":
|
|
823
|
+
"kebab-case": _chunk2GXY7E6Xjs.kebabCase,
|
|
824
|
+
"camelCase": _chunk2GXY7E6Xjs.camelCase,
|
|
825
|
+
"PascalCase": _chunk2GXY7E6Xjs.pascalCase
|
|
826
826
|
};
|
|
827
827
|
var peerPaths = /* @__PURE__ */ new Map();
|
|
828
828
|
function assertPeerPath(peerPath) {
|
|
829
829
|
if (!peerPaths.has(peerPath)) {
|
|
830
830
|
try {
|
|
831
|
-
|
|
831
|
+
_chunk2GXY7E6Xjs.resolveImportPath.call(void 0, peerPath);
|
|
832
832
|
peerPaths.set(peerPath, true);
|
|
833
833
|
} catch (e) {
|
|
834
834
|
peerPaths.set(peerPath, false);
|
|
@@ -880,12 +880,12 @@ function getCompDir(compName) {
|
|
|
880
880
|
for (let i = 0; i < total; i++) {
|
|
881
881
|
const matcher = matchComponents2[i];
|
|
882
882
|
if (compName.match(matcher.pattern)) {
|
|
883
|
-
compPath = `${matcher.compDir}/${
|
|
883
|
+
compPath = `${matcher.compDir}/${_chunk2GXY7E6Xjs.kebabCase.call(void 0, compName)}.vue`;
|
|
884
884
|
break;
|
|
885
885
|
}
|
|
886
886
|
}
|
|
887
887
|
if (!compPath)
|
|
888
|
-
compPath =
|
|
888
|
+
compPath = _chunk2GXY7E6Xjs.kebabCase.call(void 0, compName);
|
|
889
889
|
return compPath;
|
|
890
890
|
}
|
|
891
891
|
function ViewUiResolver() {
|
|
@@ -994,7 +994,7 @@ function getSideEffects7(name) {
|
|
|
994
994
|
function componentsResolver(name) {
|
|
995
995
|
if (!name.match(/^D[A-Z]/))
|
|
996
996
|
return;
|
|
997
|
-
const resolveId =
|
|
997
|
+
const resolveId = _chunk2GXY7E6Xjs.kebabCase.call(void 0, name = name.slice(1));
|
|
998
998
|
return {
|
|
999
999
|
from: LIB_NAME,
|
|
1000
1000
|
as: name,
|
|
@@ -1142,7 +1142,7 @@ var matchComponents3 = [
|
|
|
1142
1142
|
function getComponentStyleDir(importName, importStyle) {
|
|
1143
1143
|
if (["ConfigProvider", "Icon"].includes(importName))
|
|
1144
1144
|
return void 0;
|
|
1145
|
-
let componentDir =
|
|
1145
|
+
let componentDir = _chunk2GXY7E6Xjs.kebabCase.call(void 0, importName);
|
|
1146
1146
|
for (const item of matchComponents3) {
|
|
1147
1147
|
if (item.pattern.test(importName)) {
|
|
1148
1148
|
componentDir = item.componentDir;
|
|
@@ -1182,7 +1182,7 @@ function ArcoResolver(options = {}) {
|
|
|
1182
1182
|
// src/core/resolvers/tdesign.ts
|
|
1183
1183
|
function getSideEffects8(importName, options) {
|
|
1184
1184
|
const { library = "vue", importStyle = "css" } = options;
|
|
1185
|
-
let fileName =
|
|
1185
|
+
let fileName = _chunk2GXY7E6Xjs.kebabCase.call(void 0, importName);
|
|
1186
1186
|
if (!importStyle)
|
|
1187
1187
|
return;
|
|
1188
1188
|
if (["config-provider", "icon"].includes(fileName))
|
package/dist/resolvers.mjs
CHANGED
package/dist/rollup.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunkN4XEWXLGjs = require('./chunk-N4XEWXLG.js');
|
|
4
|
+
require('./chunk-2GXY7E6X.js');
|
|
5
5
|
require('./chunk-BTQOTIPQ.js');
|
|
6
6
|
require('./chunk-6F4PWJZI.js');
|
|
7
7
|
|
|
8
8
|
// src/rollup.ts
|
|
9
|
-
var rollup_default =
|
|
9
|
+
var rollup_default = _chunkN4XEWXLGjs.unplugin_default.rollup;
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
module.exports = rollup_default;
|
package/dist/rollup.mjs
CHANGED
package/dist/vite.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunkN4XEWXLGjs = require('./chunk-N4XEWXLG.js');
|
|
4
|
+
require('./chunk-2GXY7E6X.js');
|
|
5
5
|
require('./chunk-BTQOTIPQ.js');
|
|
6
6
|
require('./chunk-6F4PWJZI.js');
|
|
7
7
|
|
|
8
8
|
// src/vite.ts
|
|
9
|
-
var vite_default =
|
|
9
|
+
var vite_default = _chunkN4XEWXLGjs.unplugin_default.vite;
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
module.exports = vite_default;
|
package/dist/vite.mjs
CHANGED
package/dist/webpack.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunkN4XEWXLGjs = require('./chunk-N4XEWXLG.js');
|
|
4
|
+
require('./chunk-2GXY7E6X.js');
|
|
5
5
|
require('./chunk-BTQOTIPQ.js');
|
|
6
6
|
require('./chunk-6F4PWJZI.js');
|
|
7
7
|
|
|
8
8
|
// src/webpack.ts
|
|
9
|
-
var webpack_default =
|
|
9
|
+
var webpack_default = _chunkN4XEWXLGjs.unplugin_default.webpack;
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
module.exports = webpack_default;
|
package/dist/webpack.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-vue-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"packageManager": "pnpm@7.1.5",
|
|
5
5
|
"description": "Components auto importing for Vue",
|
|
6
6
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
@@ -63,6 +63,17 @@
|
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=14"
|
|
65
65
|
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"build": "tsup && esno scripts/postbuild.ts",
|
|
68
|
+
"dev": "tsup --watch src",
|
|
69
|
+
"example:build": "npm -C examples/vite-vue3 run build",
|
|
70
|
+
"example:dev": "npm -C examples/vite-vue3 run dev",
|
|
71
|
+
"prepublishOnly": "npm run build",
|
|
72
|
+
"lint": "eslint .",
|
|
73
|
+
"release": "bumpp && npm publish",
|
|
74
|
+
"test": "vitest",
|
|
75
|
+
"test:update": "vitest --u"
|
|
76
|
+
},
|
|
66
77
|
"peerDependencies": {
|
|
67
78
|
"@babel/parser": "^7.15.8",
|
|
68
79
|
"vue": "2 || 3"
|
|
@@ -82,39 +93,29 @@
|
|
|
82
93
|
"magic-string": "^0.26.2",
|
|
83
94
|
"minimatch": "^5.1.0",
|
|
84
95
|
"resolve": "^1.22.1",
|
|
85
|
-
"unplugin": "^0.7.
|
|
96
|
+
"unplugin": "^0.7.1"
|
|
86
97
|
},
|
|
87
98
|
"devDependencies": {
|
|
88
|
-
"@antfu/eslint-config": "^0.25.
|
|
89
|
-
"@babel/parser": "^7.18.
|
|
90
|
-
"@babel/types": "^7.18.
|
|
99
|
+
"@antfu/eslint-config": "^0.25.2",
|
|
100
|
+
"@babel/parser": "^7.18.6",
|
|
101
|
+
"@babel/types": "^7.18.7",
|
|
91
102
|
"@types/debug": "^4.1.7",
|
|
92
103
|
"@types/minimatch": "^3.0.5",
|
|
93
104
|
"@types/node": "^18.0.0",
|
|
94
105
|
"@types/resolve": "^1.20.2",
|
|
95
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
106
|
+
"@typescript-eslint/eslint-plugin": "^5.30.0",
|
|
96
107
|
"bumpp": "^8.2.1",
|
|
97
108
|
"compare-versions": "^4.1.3",
|
|
98
|
-
"element-plus": "^2.2.
|
|
109
|
+
"element-plus": "^2.2.7",
|
|
99
110
|
"eslint": "^8.18.0",
|
|
100
111
|
"esno": "^0.16.3",
|
|
101
112
|
"estree-walker": "^3.0.1",
|
|
102
|
-
"pathe": "^0.3.
|
|
113
|
+
"pathe": "^0.3.2",
|
|
103
114
|
"rollup": "^2.75.7",
|
|
104
115
|
"tsup": "^6.1.2",
|
|
105
116
|
"typescript": "^4.7.4",
|
|
106
|
-
"vite": "^2.9.
|
|
107
|
-
"vitest": "^0.
|
|
117
|
+
"vite": "^2.9.13",
|
|
118
|
+
"vitest": "^0.16.0",
|
|
108
119
|
"vue": "3.2.37"
|
|
109
|
-
},
|
|
110
|
-
"scripts": {
|
|
111
|
-
"build": "tsup && esno scripts/postbuild.ts",
|
|
112
|
-
"dev": "tsup --watch src",
|
|
113
|
-
"example:build": "npm -C examples/vite-vue3 run build",
|
|
114
|
-
"example:dev": "npm -C examples/vite-vue3 run dev",
|
|
115
|
-
"lint": "eslint .",
|
|
116
|
-
"release": "bumpp --commit --tag --push",
|
|
117
|
-
"test": "vitest",
|
|
118
|
-
"test:update": "vitest --u"
|
|
119
120
|
}
|
|
120
|
-
}
|
|
121
|
+
}
|