vite-plugin-dts 3.0.1 → 3.0.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/README.md +311 -313
- package/README.zh-CN.md +309 -310
- package/dist/index.cjs +12 -6
- package/dist/index.mjs +12 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ const debug__default = /*#__PURE__*/_interopDefaultCompat(debug);
|
|
|
25
25
|
const dtsRE$1 = /\.d\.tsx?$/;
|
|
26
26
|
function rollupDeclarationFiles({
|
|
27
27
|
root,
|
|
28
|
+
configPath,
|
|
28
29
|
compilerOptions,
|
|
29
30
|
outDir,
|
|
30
31
|
entryPath,
|
|
@@ -44,7 +45,7 @@ function rollupDeclarationFiles({
|
|
|
44
45
|
mainEntryPointFilePath: entryPath,
|
|
45
46
|
bundledPackages,
|
|
46
47
|
compiler: {
|
|
47
|
-
|
|
48
|
+
tsconfigFilePath: configPath,
|
|
48
49
|
overrideTsconfig: {
|
|
49
50
|
$schema: "http://json.schemastore.org/tsconfig",
|
|
50
51
|
compilerOptions: {
|
|
@@ -86,7 +87,7 @@ function rollupDeclarationFiles({
|
|
|
86
87
|
const compilerState = apiExtractor.CompilerState.create(extractorConfig, {
|
|
87
88
|
localBuild: false,
|
|
88
89
|
showVerboseMessages: false,
|
|
89
|
-
typescriptCompilerFolder: libFolder ? node_path.resolve(libFolder
|
|
90
|
+
typescriptCompilerFolder: libFolder ? node_path.resolve(libFolder) : void 0
|
|
90
91
|
});
|
|
91
92
|
const sourceMapper = new SourceMapper_js.SourceMapper();
|
|
92
93
|
const messageRouter = new MessageRouter_js.MessageRouter({
|
|
@@ -247,13 +248,15 @@ function transformDynamicImport(content) {
|
|
|
247
248
|
);
|
|
248
249
|
const matchResult = content.match(importReg);
|
|
249
250
|
if (matchResult?.[0]) {
|
|
250
|
-
matchResult[0].match(importTypesRE)[1].trim().split(",").forEach(
|
|
251
|
+
matchResult[0].match(importTypesRE)[1].trim().split(",").forEach((type) => {
|
|
252
|
+
type && importSet.add(type.trim());
|
|
253
|
+
});
|
|
251
254
|
content = content.replace(
|
|
252
255
|
matchResult[0],
|
|
253
|
-
`import
|
|
256
|
+
`import { ${Array.from(importSet).join(", ")} } from '${libName}'`
|
|
254
257
|
);
|
|
255
258
|
} else {
|
|
256
|
-
content = `import
|
|
259
|
+
content = `import { ${Array.from(importSet).join(", ")} } from '${libName}';
|
|
257
260
|
` + content;
|
|
258
261
|
}
|
|
259
262
|
});
|
|
@@ -354,6 +357,7 @@ function dtsPlugin(options = {}) {
|
|
|
354
357
|
let root = ensureAbsolute(options.root ?? "", process.cwd());
|
|
355
358
|
let publicRoot = "";
|
|
356
359
|
let entryRoot = options.entryRoot ?? "";
|
|
360
|
+
let configPath;
|
|
357
361
|
let compilerOptions;
|
|
358
362
|
let rawCompilerOptions;
|
|
359
363
|
let outDirs;
|
|
@@ -453,7 +457,7 @@ ${kolorist.cyan(
|
|
|
453
457
|
bundleDebug("begin buildStart");
|
|
454
458
|
timeRecord = 0;
|
|
455
459
|
const startTime = Date.now();
|
|
456
|
-
|
|
460
|
+
configPath = tsconfigPath ? ensureAbsolute(tsconfigPath, root) : ts__default.findConfigFile(root, ts__default.sys.fileExists);
|
|
457
461
|
const content = configPath ? languageCore.createParsedCommandLine(ts__default, ts__default.sys, configPath) : void 0;
|
|
458
462
|
compilerOptions = {
|
|
459
463
|
...content?.options || {},
|
|
@@ -656,6 +660,7 @@ export default ${libName}
|
|
|
656
660
|
const path = resolve(outDir, `${name.replace(tsRE, "")}.d.ts`);
|
|
657
661
|
rollupDeclarationFiles({
|
|
658
662
|
root,
|
|
663
|
+
configPath,
|
|
659
664
|
compilerOptions: rawCompilerOptions,
|
|
660
665
|
outDir,
|
|
661
666
|
entryPath: path,
|
|
@@ -669,6 +674,7 @@ export default ${libName}
|
|
|
669
674
|
} else {
|
|
670
675
|
rollupDeclarationFiles({
|
|
671
676
|
root,
|
|
677
|
+
configPath,
|
|
672
678
|
compilerOptions: rawCompilerOptions,
|
|
673
679
|
outDir,
|
|
674
680
|
entryPath: typesPath,
|
package/dist/index.mjs
CHANGED
|
@@ -25,6 +25,7 @@ import { PackageJsonLookup } from '@rushstack/node-core-library';
|
|
|
25
25
|
const dtsRE$1 = /\.d\.tsx?$/;
|
|
26
26
|
function rollupDeclarationFiles({
|
|
27
27
|
root,
|
|
28
|
+
configPath,
|
|
28
29
|
compilerOptions,
|
|
29
30
|
outDir,
|
|
30
31
|
entryPath,
|
|
@@ -44,7 +45,7 @@ function rollupDeclarationFiles({
|
|
|
44
45
|
mainEntryPointFilePath: entryPath,
|
|
45
46
|
bundledPackages,
|
|
46
47
|
compiler: {
|
|
47
|
-
|
|
48
|
+
tsconfigFilePath: configPath,
|
|
48
49
|
overrideTsconfig: {
|
|
49
50
|
$schema: "http://json.schemastore.org/tsconfig",
|
|
50
51
|
compilerOptions: {
|
|
@@ -86,7 +87,7 @@ function rollupDeclarationFiles({
|
|
|
86
87
|
const compilerState = CompilerState.create(extractorConfig, {
|
|
87
88
|
localBuild: false,
|
|
88
89
|
showVerboseMessages: false,
|
|
89
|
-
typescriptCompilerFolder: libFolder ? resolve$1(libFolder
|
|
90
|
+
typescriptCompilerFolder: libFolder ? resolve$1(libFolder) : void 0
|
|
90
91
|
});
|
|
91
92
|
const sourceMapper = new SourceMapper();
|
|
92
93
|
const messageRouter = new MessageRouter({
|
|
@@ -247,13 +248,15 @@ function transformDynamicImport(content) {
|
|
|
247
248
|
);
|
|
248
249
|
const matchResult = content.match(importReg);
|
|
249
250
|
if (matchResult?.[0]) {
|
|
250
|
-
matchResult[0].match(importTypesRE)[1].trim().split(",").forEach(
|
|
251
|
+
matchResult[0].match(importTypesRE)[1].trim().split(",").forEach((type) => {
|
|
252
|
+
type && importSet.add(type.trim());
|
|
253
|
+
});
|
|
251
254
|
content = content.replace(
|
|
252
255
|
matchResult[0],
|
|
253
|
-
`import
|
|
256
|
+
`import { ${Array.from(importSet).join(", ")} } from '${libName}'`
|
|
254
257
|
);
|
|
255
258
|
} else {
|
|
256
|
-
content = `import
|
|
259
|
+
content = `import { ${Array.from(importSet).join(", ")} } from '${libName}';
|
|
257
260
|
` + content;
|
|
258
261
|
}
|
|
259
262
|
});
|
|
@@ -354,6 +357,7 @@ function dtsPlugin(options = {}) {
|
|
|
354
357
|
let root = ensureAbsolute(options.root ?? "", process.cwd());
|
|
355
358
|
let publicRoot = "";
|
|
356
359
|
let entryRoot = options.entryRoot ?? "";
|
|
360
|
+
let configPath;
|
|
357
361
|
let compilerOptions;
|
|
358
362
|
let rawCompilerOptions;
|
|
359
363
|
let outDirs;
|
|
@@ -453,7 +457,7 @@ ${cyan(
|
|
|
453
457
|
bundleDebug("begin buildStart");
|
|
454
458
|
timeRecord = 0;
|
|
455
459
|
const startTime = Date.now();
|
|
456
|
-
|
|
460
|
+
configPath = tsconfigPath ? ensureAbsolute(tsconfigPath, root) : ts.findConfigFile(root, ts.sys.fileExists);
|
|
457
461
|
const content = configPath ? createParsedCommandLine(ts, ts.sys, configPath) : void 0;
|
|
458
462
|
compilerOptions = {
|
|
459
463
|
...content?.options || {},
|
|
@@ -656,6 +660,7 @@ export default ${libName}
|
|
|
656
660
|
const path = resolve(outDir, `${name.replace(tsRE, "")}.d.ts`);
|
|
657
661
|
rollupDeclarationFiles({
|
|
658
662
|
root,
|
|
663
|
+
configPath,
|
|
659
664
|
compilerOptions: rawCompilerOptions,
|
|
660
665
|
outDir,
|
|
661
666
|
entryPath: path,
|
|
@@ -669,6 +674,7 @@ export default ${libName}
|
|
|
669
674
|
} else {
|
|
670
675
|
rollupDeclarationFiles({
|
|
671
676
|
root,
|
|
677
|
+
configPath,
|
|
672
678
|
compilerOptions: rawCompilerOptions,
|
|
673
679
|
outDir,
|
|
674
680
|
entryPath: typesPath,
|