vite-plugin-dts 1.2.0 → 1.2.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/index.js +5 -9
- package/dist/index.mjs +5 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -299,20 +299,21 @@ function compileVueCode(code) {
|
|
|
299
299
|
id: `${index++}`
|
|
300
300
|
});
|
|
301
301
|
const classMatch = compiled.content.match(exportDefaultClassRE);
|
|
302
|
+
const plugins = scriptSetup.lang === "ts" ? ["typescript"] : void 0;
|
|
302
303
|
if (classMatch) {
|
|
303
304
|
content = compiled.content.replace(exportDefaultClassRE, "\nclass $1") + `
|
|
304
305
|
const _sfc_main = ${classMatch[1]}`;
|
|
305
306
|
if (exportDefaultRE.test(content)) {
|
|
306
|
-
content = rewriteDefault(compiled.content, "_sfc_main");
|
|
307
|
+
content = rewriteDefault(compiled.content, "_sfc_main", plugins);
|
|
307
308
|
}
|
|
308
309
|
} else {
|
|
309
|
-
content = rewriteDefault(compiled.content, "_sfc_main");
|
|
310
|
+
content = rewriteDefault(compiled.content, "_sfc_main", plugins);
|
|
310
311
|
}
|
|
311
312
|
content = transferSetupPosition(content);
|
|
312
313
|
content += "\nexport default _sfc_main\n";
|
|
313
314
|
ext = scriptSetup.lang || "js";
|
|
314
315
|
} else if (script && script.content) {
|
|
315
|
-
content = rewriteDefault(script.content, "_sfc_main");
|
|
316
|
+
content = rewriteDefault(script.content, "_sfc_main", script.lang === "ts" ? ["typescript"] : void 0);
|
|
316
317
|
content += "\nexport default _sfc_main\n";
|
|
317
318
|
ext = script.lang || "js";
|
|
318
319
|
}
|
|
@@ -437,7 +438,6 @@ function dtsPlugin(options = {}) {
|
|
|
437
438
|
const compilerOptions = (_a = options.compilerOptions) != null ? _a : {};
|
|
438
439
|
let root;
|
|
439
440
|
let entryRoot = (_b = options.entryRoot) != null ? _b : "";
|
|
440
|
-
let libName;
|
|
441
441
|
let indexName;
|
|
442
442
|
let aliases;
|
|
443
443
|
let entries;
|
|
@@ -481,11 +481,9 @@ function dtsPlugin(options = {}) {
|
|
|
481
481
|
logger.warn(import_chalk.default.yellow(`
|
|
482
482
|
${import_chalk.default.cyan("[vite:dts]")} You building not a library that may not need to generate declaration files.
|
|
483
483
|
`));
|
|
484
|
-
libName = "_default";
|
|
485
484
|
indexName = defaultIndex;
|
|
486
485
|
} else {
|
|
487
486
|
const filename = (_a2 = config.build.lib.fileName) != null ? _a2 : defaultIndex;
|
|
488
|
-
libName = config.build.lib.name || "_default";
|
|
489
487
|
indexName = typeof filename === "string" ? filename : filename("es");
|
|
490
488
|
if (!dtsRE2.test(indexName)) {
|
|
491
489
|
indexName = `${tjsRE.test(indexName) ? indexName.replace(tjsRE, "") : indexName}.d.ts`;
|
|
@@ -651,9 +649,7 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
651
649
|
let filePath = (0, import_vite2.normalizePath)((0, import_path4.relative)((0, import_path4.dirname)(typesPath), (0, import_path4.resolve)(outputDir, (0, import_path4.relative)(entryRoot, entry))));
|
|
652
650
|
filePath = filePath.replace(tsRE, "");
|
|
653
651
|
filePath = fullRelativeRE.test(filePath) ? filePath : `./${filePath}`;
|
|
654
|
-
let content = `
|
|
655
|
-
export default ${libName}
|
|
656
|
-
export * from '${filePath}'
|
|
652
|
+
let content = `export * from '${filePath}'
|
|
657
653
|
`;
|
|
658
654
|
if (typeof beforeWriteFile === "function") {
|
|
659
655
|
const result = beforeWriteFile(typesPath, content);
|
package/dist/index.mjs
CHANGED
|
@@ -278,20 +278,21 @@ function compileVueCode(code) {
|
|
|
278
278
|
id: `${index++}`
|
|
279
279
|
});
|
|
280
280
|
const classMatch = compiled.content.match(exportDefaultClassRE);
|
|
281
|
+
const plugins = scriptSetup.lang === "ts" ? ["typescript"] : void 0;
|
|
281
282
|
if (classMatch) {
|
|
282
283
|
content = compiled.content.replace(exportDefaultClassRE, "\nclass $1") + `
|
|
283
284
|
const _sfc_main = ${classMatch[1]}`;
|
|
284
285
|
if (exportDefaultRE.test(content)) {
|
|
285
|
-
content = rewriteDefault(compiled.content, "_sfc_main");
|
|
286
|
+
content = rewriteDefault(compiled.content, "_sfc_main", plugins);
|
|
286
287
|
}
|
|
287
288
|
} else {
|
|
288
|
-
content = rewriteDefault(compiled.content, "_sfc_main");
|
|
289
|
+
content = rewriteDefault(compiled.content, "_sfc_main", plugins);
|
|
289
290
|
}
|
|
290
291
|
content = transferSetupPosition(content);
|
|
291
292
|
content += "\nexport default _sfc_main\n";
|
|
292
293
|
ext = scriptSetup.lang || "js";
|
|
293
294
|
} else if (script && script.content) {
|
|
294
|
-
content = rewriteDefault(script.content, "_sfc_main");
|
|
295
|
+
content = rewriteDefault(script.content, "_sfc_main", script.lang === "ts" ? ["typescript"] : void 0);
|
|
295
296
|
content += "\nexport default _sfc_main\n";
|
|
296
297
|
ext = script.lang || "js";
|
|
297
298
|
}
|
|
@@ -419,7 +420,6 @@ function dtsPlugin(options = {}) {
|
|
|
419
420
|
const compilerOptions = (_a = options.compilerOptions) != null ? _a : {};
|
|
420
421
|
let root;
|
|
421
422
|
let entryRoot = (_b = options.entryRoot) != null ? _b : "";
|
|
422
|
-
let libName;
|
|
423
423
|
let indexName;
|
|
424
424
|
let aliases;
|
|
425
425
|
let entries;
|
|
@@ -463,11 +463,9 @@ function dtsPlugin(options = {}) {
|
|
|
463
463
|
logger.warn(chalk.yellow(`
|
|
464
464
|
${chalk.cyan("[vite:dts]")} You building not a library that may not need to generate declaration files.
|
|
465
465
|
`));
|
|
466
|
-
libName = "_default";
|
|
467
466
|
indexName = defaultIndex;
|
|
468
467
|
} else {
|
|
469
468
|
const filename = (_a2 = config.build.lib.fileName) != null ? _a2 : defaultIndex;
|
|
470
|
-
libName = config.build.lib.name || "_default";
|
|
471
469
|
indexName = typeof filename === "string" ? filename : filename("es");
|
|
472
470
|
if (!dtsRE2.test(indexName)) {
|
|
473
471
|
indexName = `${tjsRE.test(indexName) ? indexName.replace(tjsRE, "") : indexName}.d.ts`;
|
|
@@ -633,9 +631,7 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
633
631
|
let filePath = normalizePath2(relative2(dirname3(typesPath), resolve3(outputDir, relative2(entryRoot, entry))));
|
|
634
632
|
filePath = filePath.replace(tsRE, "");
|
|
635
633
|
filePath = fullRelativeRE.test(filePath) ? filePath : `./${filePath}`;
|
|
636
|
-
let content = `
|
|
637
|
-
export default ${libName}
|
|
638
|
-
export * from '${filePath}'
|
|
634
|
+
let content = `export * from '${filePath}'
|
|
639
635
|
`;
|
|
640
636
|
if (typeof beforeWriteFile === "function") {
|
|
641
637
|
const result = beforeWriteFile(typesPath, content);
|
package/package.json
CHANGED