vite-plugin-dts 3.8.3 → 3.9.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/README.md +7 -0
- package/README.zh-CN.md +9 -2
- package/dist/index.cjs +38 -54
- package/dist/index.d.cts +7 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.mjs +38 -54
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -355,6 +355,13 @@ export interface PluginOptions {
|
|
|
355
355
|
}
|
|
356
356
|
>,
|
|
357
357
|
|
|
358
|
+
/**
|
|
359
|
+
* Hook called after rolling up declaration files
|
|
360
|
+
*
|
|
361
|
+
* @default () => {}
|
|
362
|
+
*/
|
|
363
|
+
afterRollup?: (result: ExtractorResult) => MaybePromise<void>,
|
|
364
|
+
|
|
358
365
|
/**
|
|
359
366
|
* Hook called after all declaration files are written
|
|
360
367
|
*
|
package/README.zh-CN.md
CHANGED
|
@@ -269,7 +269,7 @@ export interface PluginOptions {
|
|
|
269
269
|
insertTypesEntry?: boolean,
|
|
270
270
|
|
|
271
271
|
/**
|
|
272
|
-
*
|
|
272
|
+
* 设置是否将发出的类型文件打包进单个文件
|
|
273
273
|
*
|
|
274
274
|
* 基于 `@microsoft/api-extractor`,过程将会消耗一些时间
|
|
275
275
|
*
|
|
@@ -356,7 +356,14 @@ export interface PluginOptions {
|
|
|
356
356
|
>,
|
|
357
357
|
|
|
358
358
|
/**
|
|
359
|
-
*
|
|
359
|
+
* 类型文件被打包进单个文件后的钩子
|
|
360
|
+
*
|
|
361
|
+
* @default () => {}
|
|
362
|
+
*/
|
|
363
|
+
afterRollup?: (result: ExtractorResult) => MaybePromise<void>,
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* 在所有类型文件被写入后的钩子
|
|
360
367
|
*
|
|
361
368
|
* 它会接收一个记录了那些最终被写入的文件的映射(path -> content)
|
|
362
369
|
*
|
package/dist/index.cjs
CHANGED
|
@@ -307,14 +307,13 @@ function rollupDeclarationFiles({
|
|
|
307
307
|
configObjectFullPath,
|
|
308
308
|
packageJsonFullPath: tryGetPkgPath(configObjectFullPath)
|
|
309
309
|
});
|
|
310
|
-
|
|
310
|
+
return apiExtractor.Extractor.invoke(extractorConfig, {
|
|
311
311
|
localBuild: false,
|
|
312
312
|
showVerboseMessages: false,
|
|
313
313
|
showDiagnostics: false,
|
|
314
314
|
typescriptCompilerFolder: libFolder ? node_path.resolve(libFolder) : void 0,
|
|
315
315
|
...rollupOptions
|
|
316
316
|
});
|
|
317
|
-
return result.succeeded;
|
|
318
317
|
}
|
|
319
318
|
|
|
320
319
|
const jsonRE = /\.json$/;
|
|
@@ -457,18 +456,17 @@ function transformCode(options) {
|
|
|
457
456
|
const importMap = /* @__PURE__ */ new Map();
|
|
458
457
|
const usedDefault = /* @__PURE__ */ new Map();
|
|
459
458
|
const declareModules = [];
|
|
459
|
+
const toLibName = (origin) => {
|
|
460
|
+
const name = transformAlias(origin, dir, options.aliases, options.aliasesExclude);
|
|
461
|
+
return options.cleanVueFileName ? name.replace(/\.vue$/, "") : name;
|
|
462
|
+
};
|
|
460
463
|
let indexCount = 0;
|
|
461
464
|
walkSourceFile(ast, (node, parent) => {
|
|
462
465
|
if (ts__default.isImportDeclaration(node)) {
|
|
463
466
|
if (!node.importClause) {
|
|
464
467
|
options.clearPureImport && s.remove(node.pos, node.end);
|
|
465
468
|
} else if (ts__default.isStringLiteral(node.moduleSpecifier) && (node.importClause.name || node.importClause.namedBindings && ts__default.isNamedImports(node.importClause.namedBindings))) {
|
|
466
|
-
const libName =
|
|
467
|
-
node.moduleSpecifier.text,
|
|
468
|
-
dir,
|
|
469
|
-
options.aliases,
|
|
470
|
-
options.aliasesExclude
|
|
471
|
-
);
|
|
469
|
+
const libName = toLibName(node.moduleSpecifier.text);
|
|
472
470
|
const importSet = importMap.get(libName) ?? importMap.set(libName, /* @__PURE__ */ new Set()).get(libName);
|
|
473
471
|
if (node.importClause.name && !usedDefault.has(libName)) {
|
|
474
472
|
const usedType = node.importClause.name.escapedText;
|
|
@@ -489,12 +487,7 @@ function transformCode(options) {
|
|
|
489
487
|
return false;
|
|
490
488
|
}
|
|
491
489
|
if (ts__default.isImportTypeNode(node) && node.qualifier && ts__default.isLiteralTypeNode(node.argument) && ts__default.isIdentifier(node.qualifier) && ts__default.isStringLiteral(node.argument.literal)) {
|
|
492
|
-
const libName =
|
|
493
|
-
node.argument.literal.text,
|
|
494
|
-
dir,
|
|
495
|
-
options.aliases,
|
|
496
|
-
options.aliasesExclude
|
|
497
|
-
);
|
|
490
|
+
const libName = toLibName(node.argument.literal.text);
|
|
498
491
|
if (!options.staticImport) {
|
|
499
492
|
s.update(node.argument.literal.pos, node.argument.literal.end, `'${libName}'`);
|
|
500
493
|
return !!node.typeArguments;
|
|
@@ -516,23 +509,19 @@ function transformCode(options) {
|
|
|
516
509
|
return !!node.typeArguments;
|
|
517
510
|
}
|
|
518
511
|
if (ts__default.isCallExpression(node) && node.expression.kind === ts__default.SyntaxKind.ImportKeyword && ts__default.isStringLiteral(node.arguments[0])) {
|
|
519
|
-
|
|
520
|
-
node.arguments[0].
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
options.aliasesExclude
|
|
512
|
+
s.update(
|
|
513
|
+
node.arguments[0].pos,
|
|
514
|
+
node.arguments[0].end,
|
|
515
|
+
`'${toLibName(node.arguments[0].text)}'`
|
|
524
516
|
);
|
|
525
|
-
s.update(node.arguments[0].pos, node.arguments[0].end, `'${libName}'`);
|
|
526
517
|
return false;
|
|
527
518
|
}
|
|
528
519
|
if (ts__default.isExportDeclaration(node) && node.moduleSpecifier && ts__default.isStringLiteral(node.moduleSpecifier)) {
|
|
529
|
-
|
|
530
|
-
node.moduleSpecifier.
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
options.aliasesExclude
|
|
520
|
+
s.update(
|
|
521
|
+
node.moduleSpecifier.pos,
|
|
522
|
+
node.moduleSpecifier.end,
|
|
523
|
+
` '${toLibName(node.moduleSpecifier.text)}'`
|
|
534
524
|
);
|
|
535
|
-
s.update(node.moduleSpecifier.pos, node.moduleSpecifier.end, ` '${libName}'`);
|
|
536
525
|
return false;
|
|
537
526
|
}
|
|
538
527
|
if (ts__default.isModuleDeclaration(node)) {
|
|
@@ -544,10 +533,12 @@ function transformCode(options) {
|
|
|
544
533
|
return false;
|
|
545
534
|
}
|
|
546
535
|
});
|
|
536
|
+
let prependImports = "";
|
|
547
537
|
importMap.forEach((importSet, libName) => {
|
|
548
|
-
|
|
549
|
-
|
|
538
|
+
prependImports += `import { ${Array.from(importSet).join(", ")} } from '${libName}';
|
|
539
|
+
`;
|
|
550
540
|
});
|
|
541
|
+
s.prepend(prependImports);
|
|
551
542
|
return {
|
|
552
543
|
content: s.toString(),
|
|
553
544
|
declareModules
|
|
@@ -624,6 +615,7 @@ function dtsPlugin(options = {}) {
|
|
|
624
615
|
strictOutput = true,
|
|
625
616
|
afterDiagnostic = noop,
|
|
626
617
|
beforeWriteFile = noop,
|
|
618
|
+
afterRollup = noop,
|
|
627
619
|
afterBuild = noop
|
|
628
620
|
} = options;
|
|
629
621
|
let root = ensureAbsolute(options.root ?? "", process.cwd());
|
|
@@ -942,7 +934,6 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
942
934
|
}
|
|
943
935
|
bundleDebug("emit output patch");
|
|
944
936
|
const currentDir = host.getCurrentDirectory();
|
|
945
|
-
const vuePathRE = /['"](.+)\.vue['"]/g;
|
|
946
937
|
await runParallel(
|
|
947
938
|
node_os.cpus().length,
|
|
948
939
|
Array.from(outputFiles.entries()),
|
|
@@ -956,7 +947,8 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
956
947
|
aliases,
|
|
957
948
|
aliasesExclude,
|
|
958
949
|
staticImport,
|
|
959
|
-
clearPureImport
|
|
950
|
+
clearPureImport,
|
|
951
|
+
cleanVueFileName
|
|
960
952
|
});
|
|
961
953
|
content = result.content;
|
|
962
954
|
declareModules.push(...result.declareModules);
|
|
@@ -968,7 +960,6 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
968
960
|
cleanVueFileName ? filePath.replace(".vue.d.ts", ".d.ts") : filePath
|
|
969
961
|
)
|
|
970
962
|
);
|
|
971
|
-
content = cleanVueFileName ? content.replace(vuePathRE, '"$1"') : content;
|
|
972
963
|
if (isMapFile) {
|
|
973
964
|
try {
|
|
974
965
|
const sourceMap = JSON.parse(content);
|
|
@@ -1043,37 +1034,30 @@ export default ${libName}
|
|
|
1043
1034
|
}
|
|
1044
1035
|
const rollupFiles = /* @__PURE__ */ new Set();
|
|
1045
1036
|
const compilerOptions2 = configPath ? getTsConfig(configPath, host.readFile).compilerOptions : rawCompilerOptions;
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
const path = cleanPath(resolve(outDir, tsToDts(name)));
|
|
1049
|
-
rollupDeclarationFiles({
|
|
1050
|
-
root,
|
|
1051
|
-
configPath,
|
|
1052
|
-
compilerOptions: compilerOptions2,
|
|
1053
|
-
outDir,
|
|
1054
|
-
entryPath: path,
|
|
1055
|
-
fileName: node_path.basename(path),
|
|
1056
|
-
libFolder,
|
|
1057
|
-
rollupConfig,
|
|
1058
|
-
rollupOptions
|
|
1059
|
-
});
|
|
1060
|
-
emittedFiles.delete(path);
|
|
1061
|
-
rollupFiles.add(path);
|
|
1062
|
-
}
|
|
1063
|
-
} else {
|
|
1064
|
-
rollupDeclarationFiles({
|
|
1037
|
+
const rollup = async (path) => {
|
|
1038
|
+
const result = rollupDeclarationFiles({
|
|
1065
1039
|
root,
|
|
1066
1040
|
configPath,
|
|
1067
1041
|
compilerOptions: compilerOptions2,
|
|
1068
1042
|
outDir,
|
|
1069
|
-
entryPath:
|
|
1070
|
-
fileName: node_path.basename(
|
|
1043
|
+
entryPath: path,
|
|
1044
|
+
fileName: node_path.basename(path),
|
|
1071
1045
|
libFolder,
|
|
1072
1046
|
rollupConfig,
|
|
1073
1047
|
rollupOptions
|
|
1074
1048
|
});
|
|
1075
|
-
emittedFiles.delete(
|
|
1076
|
-
rollupFiles.add(
|
|
1049
|
+
emittedFiles.delete(path);
|
|
1050
|
+
rollupFiles.add(path);
|
|
1051
|
+
if (typeof afterRollup === "function") {
|
|
1052
|
+
await unwrapPromise(afterRollup(result));
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
if (multiple) {
|
|
1056
|
+
await runParallel(node_os.cpus().length, entryNames, async (name) => {
|
|
1057
|
+
await rollup(cleanPath(resolve(outDir, tsToDts(name))));
|
|
1058
|
+
});
|
|
1059
|
+
} else {
|
|
1060
|
+
await rollup(typesPath);
|
|
1077
1061
|
}
|
|
1078
1062
|
await runParallel(node_os.cpus().length, Array.from(emittedFiles.keys()), (f) => promises.unlink(f));
|
|
1079
1063
|
removeDirIfEmpty(outDir);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
2
|
import { LogLevel } from 'vite';
|
|
3
3
|
import ts from 'typescript';
|
|
4
|
-
import { IExtractorInvokeOptions, IExtractorConfigPrepareOptions } from '@microsoft/api-extractor';
|
|
4
|
+
import { IExtractorInvokeOptions, ExtractorResult, IExtractorConfigPrepareOptions } from '@microsoft/api-extractor';
|
|
5
5
|
|
|
6
6
|
type MaybePromise<T> = T | Promise<T>;
|
|
7
7
|
type RollupConfig = Omit<IExtractorConfigPrepareOptions['configObject'], 'projectFolder' | 'mainEntryPointFilePath' | 'compiler' | 'dtsRollup'>;
|
|
@@ -213,6 +213,12 @@ interface PluginOptions {
|
|
|
213
213
|
filePath?: string;
|
|
214
214
|
content?: string;
|
|
215
215
|
}>;
|
|
216
|
+
/**
|
|
217
|
+
* Hook called after rolling up declaration files
|
|
218
|
+
*
|
|
219
|
+
* @default () => {}
|
|
220
|
+
*/
|
|
221
|
+
afterRollup?: (result: ExtractorResult) => MaybePromise<void>;
|
|
216
222
|
/**
|
|
217
223
|
* Hook called after all declaration files are written
|
|
218
224
|
*
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
2
|
import { LogLevel } from 'vite';
|
|
3
3
|
import ts from 'typescript';
|
|
4
|
-
import { IExtractorInvokeOptions, IExtractorConfigPrepareOptions } from '@microsoft/api-extractor';
|
|
4
|
+
import { IExtractorInvokeOptions, ExtractorResult, IExtractorConfigPrepareOptions } from '@microsoft/api-extractor';
|
|
5
5
|
|
|
6
6
|
type MaybePromise<T> = T | Promise<T>;
|
|
7
7
|
type RollupConfig = Omit<IExtractorConfigPrepareOptions['configObject'], 'projectFolder' | 'mainEntryPointFilePath' | 'compiler' | 'dtsRollup'>;
|
|
@@ -213,6 +213,12 @@ interface PluginOptions {
|
|
|
213
213
|
filePath?: string;
|
|
214
214
|
content?: string;
|
|
215
215
|
}>;
|
|
216
|
+
/**
|
|
217
|
+
* Hook called after rolling up declaration files
|
|
218
|
+
*
|
|
219
|
+
* @default () => {}
|
|
220
|
+
*/
|
|
221
|
+
afterRollup?: (result: ExtractorResult) => MaybePromise<void>;
|
|
216
222
|
/**
|
|
217
223
|
* Hook called after all declaration files are written
|
|
218
224
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
2
|
import { LogLevel } from 'vite';
|
|
3
3
|
import ts from 'typescript';
|
|
4
|
-
import { IExtractorInvokeOptions, IExtractorConfigPrepareOptions } from '@microsoft/api-extractor';
|
|
4
|
+
import { IExtractorInvokeOptions, ExtractorResult, IExtractorConfigPrepareOptions } from '@microsoft/api-extractor';
|
|
5
5
|
|
|
6
6
|
type MaybePromise<T> = T | Promise<T>;
|
|
7
7
|
type RollupConfig = Omit<IExtractorConfigPrepareOptions['configObject'], 'projectFolder' | 'mainEntryPointFilePath' | 'compiler' | 'dtsRollup'>;
|
|
@@ -213,6 +213,12 @@ interface PluginOptions {
|
|
|
213
213
|
filePath?: string;
|
|
214
214
|
content?: string;
|
|
215
215
|
}>;
|
|
216
|
+
/**
|
|
217
|
+
* Hook called after rolling up declaration files
|
|
218
|
+
*
|
|
219
|
+
* @default () => {}
|
|
220
|
+
*/
|
|
221
|
+
afterRollup?: (result: ExtractorResult) => MaybePromise<void>;
|
|
216
222
|
/**
|
|
217
223
|
* Hook called after all declaration files are written
|
|
218
224
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -304,14 +304,13 @@ function rollupDeclarationFiles({
|
|
|
304
304
|
configObjectFullPath,
|
|
305
305
|
packageJsonFullPath: tryGetPkgPath(configObjectFullPath)
|
|
306
306
|
});
|
|
307
|
-
|
|
307
|
+
return Extractor.invoke(extractorConfig, {
|
|
308
308
|
localBuild: false,
|
|
309
309
|
showVerboseMessages: false,
|
|
310
310
|
showDiagnostics: false,
|
|
311
311
|
typescriptCompilerFolder: libFolder ? resolve$1(libFolder) : void 0,
|
|
312
312
|
...rollupOptions
|
|
313
313
|
});
|
|
314
|
-
return result.succeeded;
|
|
315
314
|
}
|
|
316
315
|
|
|
317
316
|
const jsonRE = /\.json$/;
|
|
@@ -454,18 +453,17 @@ function transformCode(options) {
|
|
|
454
453
|
const importMap = /* @__PURE__ */ new Map();
|
|
455
454
|
const usedDefault = /* @__PURE__ */ new Map();
|
|
456
455
|
const declareModules = [];
|
|
456
|
+
const toLibName = (origin) => {
|
|
457
|
+
const name = transformAlias(origin, dir, options.aliases, options.aliasesExclude);
|
|
458
|
+
return options.cleanVueFileName ? name.replace(/\.vue$/, "") : name;
|
|
459
|
+
};
|
|
457
460
|
let indexCount = 0;
|
|
458
461
|
walkSourceFile(ast, (node, parent) => {
|
|
459
462
|
if (ts.isImportDeclaration(node)) {
|
|
460
463
|
if (!node.importClause) {
|
|
461
464
|
options.clearPureImport && s.remove(node.pos, node.end);
|
|
462
465
|
} else if (ts.isStringLiteral(node.moduleSpecifier) && (node.importClause.name || node.importClause.namedBindings && ts.isNamedImports(node.importClause.namedBindings))) {
|
|
463
|
-
const libName =
|
|
464
|
-
node.moduleSpecifier.text,
|
|
465
|
-
dir,
|
|
466
|
-
options.aliases,
|
|
467
|
-
options.aliasesExclude
|
|
468
|
-
);
|
|
466
|
+
const libName = toLibName(node.moduleSpecifier.text);
|
|
469
467
|
const importSet = importMap.get(libName) ?? importMap.set(libName, /* @__PURE__ */ new Set()).get(libName);
|
|
470
468
|
if (node.importClause.name && !usedDefault.has(libName)) {
|
|
471
469
|
const usedType = node.importClause.name.escapedText;
|
|
@@ -486,12 +484,7 @@ function transformCode(options) {
|
|
|
486
484
|
return false;
|
|
487
485
|
}
|
|
488
486
|
if (ts.isImportTypeNode(node) && node.qualifier && ts.isLiteralTypeNode(node.argument) && ts.isIdentifier(node.qualifier) && ts.isStringLiteral(node.argument.literal)) {
|
|
489
|
-
const libName =
|
|
490
|
-
node.argument.literal.text,
|
|
491
|
-
dir,
|
|
492
|
-
options.aliases,
|
|
493
|
-
options.aliasesExclude
|
|
494
|
-
);
|
|
487
|
+
const libName = toLibName(node.argument.literal.text);
|
|
495
488
|
if (!options.staticImport) {
|
|
496
489
|
s.update(node.argument.literal.pos, node.argument.literal.end, `'${libName}'`);
|
|
497
490
|
return !!node.typeArguments;
|
|
@@ -513,23 +506,19 @@ function transformCode(options) {
|
|
|
513
506
|
return !!node.typeArguments;
|
|
514
507
|
}
|
|
515
508
|
if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword && ts.isStringLiteral(node.arguments[0])) {
|
|
516
|
-
|
|
517
|
-
node.arguments[0].
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
options.aliasesExclude
|
|
509
|
+
s.update(
|
|
510
|
+
node.arguments[0].pos,
|
|
511
|
+
node.arguments[0].end,
|
|
512
|
+
`'${toLibName(node.arguments[0].text)}'`
|
|
521
513
|
);
|
|
522
|
-
s.update(node.arguments[0].pos, node.arguments[0].end, `'${libName}'`);
|
|
523
514
|
return false;
|
|
524
515
|
}
|
|
525
516
|
if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
526
|
-
|
|
527
|
-
node.moduleSpecifier.
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
options.aliasesExclude
|
|
517
|
+
s.update(
|
|
518
|
+
node.moduleSpecifier.pos,
|
|
519
|
+
node.moduleSpecifier.end,
|
|
520
|
+
` '${toLibName(node.moduleSpecifier.text)}'`
|
|
531
521
|
);
|
|
532
|
-
s.update(node.moduleSpecifier.pos, node.moduleSpecifier.end, ` '${libName}'`);
|
|
533
522
|
return false;
|
|
534
523
|
}
|
|
535
524
|
if (ts.isModuleDeclaration(node)) {
|
|
@@ -541,10 +530,12 @@ function transformCode(options) {
|
|
|
541
530
|
return false;
|
|
542
531
|
}
|
|
543
532
|
});
|
|
533
|
+
let prependImports = "";
|
|
544
534
|
importMap.forEach((importSet, libName) => {
|
|
545
|
-
|
|
546
|
-
|
|
535
|
+
prependImports += `import { ${Array.from(importSet).join(", ")} } from '${libName}';
|
|
536
|
+
`;
|
|
547
537
|
});
|
|
538
|
+
s.prepend(prependImports);
|
|
548
539
|
return {
|
|
549
540
|
content: s.toString(),
|
|
550
541
|
declareModules
|
|
@@ -621,6 +612,7 @@ function dtsPlugin(options = {}) {
|
|
|
621
612
|
strictOutput = true,
|
|
622
613
|
afterDiagnostic = noop,
|
|
623
614
|
beforeWriteFile = noop,
|
|
615
|
+
afterRollup = noop,
|
|
624
616
|
afterBuild = noop
|
|
625
617
|
} = options;
|
|
626
618
|
let root = ensureAbsolute(options.root ?? "", process.cwd());
|
|
@@ -939,7 +931,6 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
939
931
|
}
|
|
940
932
|
bundleDebug("emit output patch");
|
|
941
933
|
const currentDir = host.getCurrentDirectory();
|
|
942
|
-
const vuePathRE = /['"](.+)\.vue['"]/g;
|
|
943
934
|
await runParallel(
|
|
944
935
|
cpus().length,
|
|
945
936
|
Array.from(outputFiles.entries()),
|
|
@@ -953,7 +944,8 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
953
944
|
aliases,
|
|
954
945
|
aliasesExclude,
|
|
955
946
|
staticImport,
|
|
956
|
-
clearPureImport
|
|
947
|
+
clearPureImport,
|
|
948
|
+
cleanVueFileName
|
|
957
949
|
});
|
|
958
950
|
content = result.content;
|
|
959
951
|
declareModules.push(...result.declareModules);
|
|
@@ -965,7 +957,6 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
965
957
|
cleanVueFileName ? filePath.replace(".vue.d.ts", ".d.ts") : filePath
|
|
966
958
|
)
|
|
967
959
|
);
|
|
968
|
-
content = cleanVueFileName ? content.replace(vuePathRE, '"$1"') : content;
|
|
969
960
|
if (isMapFile) {
|
|
970
961
|
try {
|
|
971
962
|
const sourceMap = JSON.parse(content);
|
|
@@ -1040,37 +1031,30 @@ export default ${libName}
|
|
|
1040
1031
|
}
|
|
1041
1032
|
const rollupFiles = /* @__PURE__ */ new Set();
|
|
1042
1033
|
const compilerOptions2 = configPath ? getTsConfig(configPath, host.readFile).compilerOptions : rawCompilerOptions;
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
const path = cleanPath(resolve(outDir, tsToDts(name)));
|
|
1046
|
-
rollupDeclarationFiles({
|
|
1047
|
-
root,
|
|
1048
|
-
configPath,
|
|
1049
|
-
compilerOptions: compilerOptions2,
|
|
1050
|
-
outDir,
|
|
1051
|
-
entryPath: path,
|
|
1052
|
-
fileName: basename(path),
|
|
1053
|
-
libFolder,
|
|
1054
|
-
rollupConfig,
|
|
1055
|
-
rollupOptions
|
|
1056
|
-
});
|
|
1057
|
-
emittedFiles.delete(path);
|
|
1058
|
-
rollupFiles.add(path);
|
|
1059
|
-
}
|
|
1060
|
-
} else {
|
|
1061
|
-
rollupDeclarationFiles({
|
|
1034
|
+
const rollup = async (path) => {
|
|
1035
|
+
const result = rollupDeclarationFiles({
|
|
1062
1036
|
root,
|
|
1063
1037
|
configPath,
|
|
1064
1038
|
compilerOptions: compilerOptions2,
|
|
1065
1039
|
outDir,
|
|
1066
|
-
entryPath:
|
|
1067
|
-
fileName: basename(
|
|
1040
|
+
entryPath: path,
|
|
1041
|
+
fileName: basename(path),
|
|
1068
1042
|
libFolder,
|
|
1069
1043
|
rollupConfig,
|
|
1070
1044
|
rollupOptions
|
|
1071
1045
|
});
|
|
1072
|
-
emittedFiles.delete(
|
|
1073
|
-
rollupFiles.add(
|
|
1046
|
+
emittedFiles.delete(path);
|
|
1047
|
+
rollupFiles.add(path);
|
|
1048
|
+
if (typeof afterRollup === "function") {
|
|
1049
|
+
await unwrapPromise(afterRollup(result));
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
if (multiple) {
|
|
1053
|
+
await runParallel(cpus().length, entryNames, async (name) => {
|
|
1054
|
+
await rollup(cleanPath(resolve(outDir, tsToDts(name))));
|
|
1055
|
+
});
|
|
1056
|
+
} else {
|
|
1057
|
+
await rollup(typesPath);
|
|
1074
1058
|
}
|
|
1075
1059
|
await runParallel(cpus().length, Array.from(emittedFiles.keys()), (f) => unlink(f));
|
|
1076
1060
|
removeDirIfEmpty(outDir);
|