vite-plugin-dts 3.6.4 → 3.7.0

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 CHANGED
@@ -59,18 +59,6 @@ Starting with `3.0.0`, you can use this plugin with Rollup.
59
59
 
60
60
  Here are some FAQ's and solutions.
61
61
 
62
- ### Missing some declaration files after build (before `1.7.0`)
63
-
64
- By default, the `skipDiagnostics` option is set to `true` which means type diagnostics will be skipped during the build process (some projects may have diagnostic tools such as `vue-tsc`). Files with type errors which interrupt the build process will not be emitted (declaration files won't be generated).
65
-
66
- If your project doesn't use type diagnostic tools, you can set `skipDiagnostics: false` and `logDiagnostics: true` to turn on diagnostic and logging features of this plugin. Type errors during build will be logged to the terminal.
67
-
68
- ### Type error when using both `script` and `setup-script` in Vue component (before `3.0.0`)
69
-
70
- This is usually caused by using the `defineComponent` function in both `script` and `setup-script`. When `vue/compiler-sfc` compiles these files, the default export result from `script` gets merged with the parameter object of `defineComponent` from `setup-script`. This is incompatible with parameters and types returned from `defineComponent`. This results in a type error.
71
-
72
- Here is a simple [example](https://github.com/qmhc/vite-plugin-dts/blob/main/examples/vue/components/BothScripts.vue). You should remove the `defineComponent` in `script` and export a native object directly.
73
-
74
62
  ### Type errors that are unable to infer types from packages in `node_modules`
75
63
 
76
64
  This is an existing [TypeScript issue](https://github.com/microsoft/TypeScript/issues/42873) where TypeScript infers types from packages located in `node_modules` through soft links (pnpm). A workaround is to add `baseUrl` to your `tsconfig.json` and specify the `paths` for these packages:
@@ -86,6 +74,33 @@ This is an existing [TypeScript issue](https://github.com/microsoft/TypeScript/i
86
74
  }
87
75
  ```
88
76
 
77
+ ### `Internal Error` occurs when using `rollupTypes: true`
78
+
79
+ Refer to this [issue](https://github.com/microsoft/rushstack/issues/3875), it's due to a limitation of `@microsoft/api-extractor` or TypeScript resolver.
80
+
81
+ The main reason is that `baseUrl` is specified in `tsconfig.json` and non-standard paths are used directly when imported.
82
+
83
+ For example: `baseUrl: 'src'` is specified and importing from `<root>/src/components/index.ts` in `<root>/src/index.ts`, and `import 'components'` is used instead of `import './components'`.
84
+
85
+ Currently, you need to avoid the above situation, or use aliases instead (with the `paths` option).
86
+
87
+ <details>
88
+ <summary>Legacy</summary>
89
+
90
+ ### Missing some declaration files after build (before `1.7.0`)
91
+
92
+ By default, the `skipDiagnostics` option is set to `true` which means type diagnostics will be skipped during the build process (some projects may have diagnostic tools such as `vue-tsc`). Files with type errors which interrupt the build process will not be emitted (declaration files won't be generated).
93
+
94
+ If your project doesn't use type diagnostic tools, you can set `skipDiagnostics: false` and `logDiagnostics: true` to turn on diagnostic and logging features of this plugin. Type errors during build will be logged to the terminal.
95
+
96
+ ### Type error when using both `script` and `setup-script` in Vue component (before `3.0.0`)
97
+
98
+ This is usually caused by using the `defineComponent` function in both `script` and `setup-script`. When `vue/compiler-sfc` compiles these files, the default export result from `script` gets merged with the parameter object of `defineComponent` from `setup-script`. This is incompatible with parameters and types returned from `defineComponent`. This results in a type error.
99
+
100
+ Here is a simple [example](https://github.com/qmhc/vite-plugin-dts/blob/main/examples/vue/components/BothScripts.vue). You should remove the `defineComponent` in `script` and export a native object directly.
101
+
102
+ </details>
103
+
89
104
  ## Options
90
105
 
91
106
  ```ts
@@ -343,6 +358,8 @@ export interface PluginOptions {
343
358
  /**
344
359
  * Hook called after all declaration files are written
345
360
  *
361
+ * It will be received a map (path -> content) that records those emitted files
362
+ *
346
363
  * @default () => {}
347
364
  */
348
365
  afterBuild?: () => MaybePromise<void>
@@ -354,7 +371,7 @@ export interface PluginOptions {
354
371
  Thanks for all the contributions!
355
372
 
356
373
  <a href="https://github.com/qmhc/vite-plugin-dts/graphs/contributors">
357
- <img src="https://contrib.rocks/image?repo=qmhc/vite-plugin-dts" />
374
+ <img src="https://contrib.rocks/image?repo=qmhc/vite-plugin-dts" alt="contributors" />
358
375
  </a>
359
376
 
360
377
  ## Example
package/README.zh-CN.md CHANGED
@@ -59,18 +59,6 @@ export default defineConfig({
59
59
 
60
60
  此处将收录一些常见的问题并提供一些解决方案。
61
61
 
62
- ### 打包后出现类型文件缺失 (`1.7.0` 之前)
63
-
64
- 默认情况下 `skipDiagnostics` 选项的值为 `true`,这意味着打包过程中将跳过类型检查(一些项目通常有 `vue-tsc` 等的类型检查工具),这时如果出现存在类型错误的文件,并且这是错误会中断打包过程,那么这些文件对应的类型文件将不会被生成。
65
-
66
- 如果您的项目没有依赖外部的类型检查工具,这时候可以您可以设置 `skipDiagnostics: false` 和 `logDiagnostics: true` 来打开插件的诊断与输出功能,这将帮助您检查打包过程中出现的类型错误并将错误信息输出至终端。
67
-
68
- ### Vue 组件中同时使用了 `script` 和 `setup-script` 后出现类型错误(`3.0.0` 之前)
69
-
70
- 这通常是由于分别在 `script` 和 `setup-script` 中同时使用了 `defineComponent` 方法导致的。 `vue/compiler-sfc` 为这类文件编译时会将 `script` 中的默认导出结果合并到 `setup-script` 的 `defineComponent` 的参数定义中,而 `defineComponent` 的参数类型与结果类型并不兼容,这一行为将会导致类型错误。
71
-
72
- 这是一个简单的[示例](https://github.com/qmhc/vite-plugin-dts/blob/main/example/components/BothScripts.vue),您应该将位于 `script` 中的 `defineComponent` 方法移除,直接导出一个原始的对象。
73
-
74
62
  ### 打包时出现了无法从 `node_modules` 的包中推断类型的错误
75
63
 
76
64
  这是 TypeScript 通过软链接 (pnpm) 读取 `node_modules` 中过的类型时会出现的一个已知的问题,可以参考这个 [issue](https://github.com/microsoft/TypeScript/issues/42873),目前已有的一个解决方案,在你的 `tsconfig.json` 中添加 `baseUrl` 以及在 `paths` 添加这些包的路径:
@@ -86,6 +74,33 @@ export default defineConfig({
86
74
  }
87
75
  ```
88
76
 
77
+ ### 在 `rollupTypes: true` 时出现 `Internal Error`
78
+
79
+ 参考这个 [issue](https://github.com/microsoft/rushstack/issues/3875),这是由于 `@microsoft/api-extractor` 或者是 TypeScript 解析器的一些限制导致的。
80
+
81
+ 主要原因在于 `tsconfig.json` 中指定了 `baseUrl` 并且在引入时直接使用非标准路径。
82
+
83
+ 例如:指定了 `baseUrl: 'src'` 并且在 `<root>/src/index.ts` 中引入 `<root>/src/components/index.ts` 时使用了 `import 'components'` 而不是 `import './components'`。
84
+
85
+ 目前想要正常打包,需要规避上述情况,或使用别名代替(配合 `paths` 属性)。
86
+
87
+ <details>
88
+ <summary>过时的</summary>
89
+
90
+ ### 打包后出现类型文件缺失 (`1.7.0` 之前)
91
+
92
+ 默认情况下 `skipDiagnostics` 选项的值为 `true`,这意味着打包过程中将跳过类型检查(一些项目通常有 `vue-tsc` 等的类型检查工具),这时如果出现存在类型错误的文件,并且这是错误会中断打包过程,那么这些文件对应的类型文件将不会被生成。
93
+
94
+ 如果您的项目没有依赖外部的类型检查工具,这时候可以您可以设置 `skipDiagnostics: false` 和 `logDiagnostics: true` 来打开插件的诊断与输出功能,这将帮助您检查打包过程中出现的类型错误并将错误信息输出至终端。
95
+
96
+ ### Vue 组件中同时使用了 `script` 和 `setup-script` 后出现类型错误(`3.0.0` 之前)
97
+
98
+ 这通常是由于分别在 `script` 和 `setup-script` 中同时使用了 `defineComponent` 方法导致的。 `vue/compiler-sfc` 为这类文件编译时会将 `script` 中的默认导出结果合并到 `setup-script` 的 `defineComponent` 的参数定义中,而 `defineComponent` 的参数类型与结果类型并不兼容,这一行为将会导致类型错误。
99
+
100
+ 这是一个简单的[示例](https://github.com/qmhc/vite-plugin-dts/blob/main/example/components/BothScripts.vue),您应该将位于 `script` 中的 `defineComponent` 方法移除,直接导出一个原始的对象。
101
+
102
+ </details>
103
+
89
104
  ## 选项
90
105
 
91
106
  ```ts
@@ -343,9 +358,11 @@ export interface PluginOptions {
343
358
  /**
344
359
  * 在所有类型文件被写入后调用的钩子
345
360
  *
361
+ * 它会接收一个记录了那些最终被写入的文件的映射(path -> content)
362
+ *
346
363
  * @default () => {}
347
364
  */
348
- afterBuild?: () => MaybePromise<void>
365
+ afterBuild?: (emittedFiles: Map<string, string>) => MaybePromise<void>
349
366
  }
350
367
  ```
351
368
 
@@ -354,7 +371,7 @@ export interface PluginOptions {
354
371
  感谢他们的所做的一切贡献!
355
372
 
356
373
  <a href="https://github.com/qmhc/vite-plugin-dts/graphs/contributors">
357
- <img src="https://contrib.rocks/image?repo=qmhc/vite-plugin-dts" />
374
+ <img src="https://contrib.rocks/image?repo=qmhc/vite-plugin-dts" alt="contributors" />
358
375
  </a>
359
376
 
360
377
  ## 示例
package/dist/index.cjs CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  const node_path = require('node:path');
4
6
  const node_fs = require('node:fs');
5
7
  const promises = require('node:fs/promises');
@@ -206,6 +208,21 @@ function setModuleResolution(options) {
206
208
  }
207
209
  options.moduleResolution = moduleResolution;
208
210
  }
211
+ function editSourceMapDir(content, fromDir, toDir) {
212
+ const relativeOutDir = node_path.relative(fromDir, toDir);
213
+ if (relativeOutDir) {
214
+ try {
215
+ const sourceMap = JSON.parse(content);
216
+ sourceMap.sources = sourceMap.sources.map((source) => {
217
+ return normalizePath(node_path.relative(relativeOutDir, source));
218
+ });
219
+ return JSON.stringify(sourceMap);
220
+ } catch (e) {
221
+ return false;
222
+ }
223
+ }
224
+ return true;
225
+ }
209
226
 
210
227
  const dtsRE$1 = /\.d\.tsx?$/;
211
228
  function rollupDeclarationFiles({
@@ -429,6 +446,9 @@ function isAliasMatch(alias, importer) {
429
446
  return true;
430
447
  return importer.indexOf(alias.find) === 0 && (alias.find.endsWith("/") || importer.substring(alias.find.length)[0] === "/");
431
448
  }
449
+ function ensureStartWithDot(path) {
450
+ return path.startsWith(".") ? path : `./${path}`;
451
+ }
432
452
  const globalImportRE = /(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g;
433
453
  const staticImportRE = /(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/;
434
454
  const dynamicImportRE = /import\(['"]([^;\n]+?)['"]\)/;
@@ -450,13 +470,17 @@ function transformAliasImport(filePath, content, aliases, exclude = []) {
450
470
  if (exclude.some((e) => isRegExp(e) ? e.test(matchResult[1]) : String(e) === matchResult[1])) {
451
471
  return str;
452
472
  }
453
- const truthPath = node_path.isAbsolute(matchedAlias.replacement) ? normalizePath(node_path.relative(node_path.dirname(filePath), matchedAlias.replacement)) : normalizePath(matchedAlias.replacement);
473
+ const dir = node_path.dirname(filePath);
474
+ const replacement = node_path.isAbsolute(matchedAlias.replacement) ? normalizePath(node_path.relative(dir, matchedAlias.replacement)) : normalizePath(matchedAlias.replacement);
475
+ const endSlash = matchResult[1].match(matchedAlias.find)[0].endsWith("/");
476
+ const truthPath = matchResult[1].replace(
477
+ matchedAlias.find,
478
+ replacement + (endSlash ? "/" : "")
479
+ );
480
+ const normalizedPath = normalizePath(node_path.relative(dir, node_path.resolve(dir, truthPath)));
454
481
  return str.replace(
455
482
  isDynamic ? simpleDynamicImportRE : simpleStaticImportRE,
456
- `$1'${matchResult[1].replace(
457
- matchedAlias.find,
458
- (truthPath.startsWith(".") ? truthPath : `./${truthPath}`) + (typeof matchedAlias.find === "string" && matchedAlias.find.endsWith("/") ? "/" : "")
459
- )}'${isDynamic ? ")" : ""}`
483
+ `$1'${ensureStartWithDot(normalizedPath)}'${isDynamic ? ")" : ""}`
460
484
  );
461
485
  }
462
486
  }
@@ -555,7 +579,7 @@ function dtsPlugin(options = {}) {
555
579
  return { find: key, replacement: value };
556
580
  });
557
581
  } else {
558
- aliases = ensureArray(aliasOptions);
582
+ aliases = ensureArray(aliasOptions).map((alias) => ({ ...alias }));
559
583
  }
560
584
  if (aliasesExclude.length > 0) {
561
585
  aliases = aliases.filter(
@@ -564,6 +588,9 @@ function dtsPlugin(options = {}) {
564
588
  )
565
589
  );
566
590
  }
591
+ for (const alias of aliases) {
592
+ alias.replacement = resolve(alias.replacement);
593
+ }
567
594
  },
568
595
  async configResolved(config) {
569
596
  logger = logLevel ? (await import('vite')).createLogger(logLevel, { allowClearScreen: config.clearScreen }) : config.logger;
@@ -961,17 +988,8 @@ export default ${libName}
961
988
  extraOutDirs.map(async (targetOutDir) => {
962
989
  const path = resolve(targetOutDir, relativePath);
963
990
  if (wroteFile.endsWith(".map")) {
964
- const relativeOutDir = node_path.relative(outDir, targetOutDir);
965
- if (relativeOutDir) {
966
- try {
967
- const sourceMap = JSON.parse(content);
968
- sourceMap.sources = sourceMap.sources.map((source) => {
969
- return normalizePath(node_path.relative(relativeOutDir, source));
970
- });
971
- content = JSON.stringify(sourceMap);
972
- } catch (e) {
973
- logger.warn(`${logPrefix} ${kolorist.yellow("Processing source map fail:")} ${path}`);
974
- }
991
+ if (!editSourceMapDir(content, outDir, targetOutDir)) {
992
+ logger.warn(`${logPrefix} ${kolorist.yellow("Processing source map fail:")} ${path}`);
975
993
  }
976
994
  }
977
995
  await writeOutput(path, content, targetOutDir, false);
@@ -980,7 +998,7 @@ export default ${libName}
980
998
  });
981
999
  }
982
1000
  if (typeof afterBuild === "function") {
983
- await wrapPromise(afterBuild());
1001
+ await wrapPromise(afterBuild(emittedFiles));
984
1002
  }
985
1003
  bundleDebug("finish");
986
1004
  logger.info(
@@ -998,4 +1016,5 @@ export default ${libName}
998
1016
  };
999
1017
  }
1000
1018
 
1001
- module.exports = dtsPlugin;
1019
+ exports.default = dtsPlugin;
1020
+ exports.editSourceMapDir = editSourceMapDir;
package/dist/index.d.cts CHANGED
@@ -216,11 +216,15 @@ interface PluginOptions {
216
216
  /**
217
217
  * Hook called after all declaration files are written
218
218
  *
219
+ * It will be received a map (path -> content) that records those emitted files
220
+ *
219
221
  * @default () => {}
220
222
  */
221
- afterBuild?: () => MaybePromise<void>;
223
+ afterBuild?: (emittedFiles: Map<string, string>) => MaybePromise<void>;
222
224
  }
223
225
 
224
226
  declare function dtsPlugin(options?: PluginOptions): vite.Plugin;
225
227
 
226
- export { type PluginOptions, dtsPlugin as default };
228
+ declare function editSourceMapDir(content: string, fromDir: string, toDir: string): string | boolean;
229
+
230
+ export { type PluginOptions, dtsPlugin as default, editSourceMapDir };
package/dist/index.d.mts CHANGED
@@ -216,11 +216,15 @@ interface PluginOptions {
216
216
  /**
217
217
  * Hook called after all declaration files are written
218
218
  *
219
+ * It will be received a map (path -> content) that records those emitted files
220
+ *
219
221
  * @default () => {}
220
222
  */
221
- afterBuild?: () => MaybePromise<void>;
223
+ afterBuild?: (emittedFiles: Map<string, string>) => MaybePromise<void>;
222
224
  }
223
225
 
224
226
  declare function dtsPlugin(options?: PluginOptions): vite.Plugin;
225
227
 
226
- export { type PluginOptions, dtsPlugin as default };
228
+ declare function editSourceMapDir(content: string, fromDir: string, toDir: string): string | boolean;
229
+
230
+ export { type PluginOptions, dtsPlugin as default, editSourceMapDir };
package/dist/index.d.ts CHANGED
@@ -216,11 +216,15 @@ interface PluginOptions {
216
216
  /**
217
217
  * Hook called after all declaration files are written
218
218
  *
219
+ * It will be received a map (path -> content) that records those emitted files
220
+ *
219
221
  * @default () => {}
220
222
  */
221
- afterBuild?: () => MaybePromise<void>;
223
+ afterBuild?: (emittedFiles: Map<string, string>) => MaybePromise<void>;
222
224
  }
223
225
 
224
226
  declare function dtsPlugin(options?: PluginOptions): vite.Plugin;
225
227
 
226
- export { type PluginOptions, dtsPlugin as default };
228
+ declare function editSourceMapDir(content: string, fromDir: string, toDir: string): string | boolean;
229
+
230
+ export { type PluginOptions, dtsPlugin as default, editSourceMapDir };
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import __cjs_mod__ from 'module';
5
5
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
6
6
  const __dirname = __cjs_path__.dirname(__filename);
7
7
  const require = __cjs_mod__.createRequire(import.meta.url);
8
- import { posix, resolve as resolve$1, isAbsolute, dirname, normalize, sep, relative, basename } from 'node:path';
8
+ import { relative, posix, resolve as resolve$1, isAbsolute, dirname, normalize, sep, basename } from 'node:path';
9
9
  import { existsSync, readdirSync, lstatSync, rmdirSync } from 'node:fs';
10
10
  import { readFile, mkdir, writeFile, unlink } from 'node:fs/promises';
11
11
  import { cpus } from 'node:os';
@@ -206,6 +206,21 @@ function setModuleResolution(options) {
206
206
  }
207
207
  options.moduleResolution = moduleResolution;
208
208
  }
209
+ function editSourceMapDir(content, fromDir, toDir) {
210
+ const relativeOutDir = relative(fromDir, toDir);
211
+ if (relativeOutDir) {
212
+ try {
213
+ const sourceMap = JSON.parse(content);
214
+ sourceMap.sources = sourceMap.sources.map((source) => {
215
+ return normalizePath(relative(relativeOutDir, source));
216
+ });
217
+ return JSON.stringify(sourceMap);
218
+ } catch (e) {
219
+ return false;
220
+ }
221
+ }
222
+ return true;
223
+ }
209
224
 
210
225
  const dtsRE$1 = /\.d\.tsx?$/;
211
226
  function rollupDeclarationFiles({
@@ -429,6 +444,9 @@ function isAliasMatch(alias, importer) {
429
444
  return true;
430
445
  return importer.indexOf(alias.find) === 0 && (alias.find.endsWith("/") || importer.substring(alias.find.length)[0] === "/");
431
446
  }
447
+ function ensureStartWithDot(path) {
448
+ return path.startsWith(".") ? path : `./${path}`;
449
+ }
432
450
  const globalImportRE = /(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g;
433
451
  const staticImportRE = /(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/;
434
452
  const dynamicImportRE = /import\(['"]([^;\n]+?)['"]\)/;
@@ -450,13 +468,17 @@ function transformAliasImport(filePath, content, aliases, exclude = []) {
450
468
  if (exclude.some((e) => isRegExp(e) ? e.test(matchResult[1]) : String(e) === matchResult[1])) {
451
469
  return str;
452
470
  }
453
- const truthPath = isAbsolute(matchedAlias.replacement) ? normalizePath(relative(dirname(filePath), matchedAlias.replacement)) : normalizePath(matchedAlias.replacement);
471
+ const dir = dirname(filePath);
472
+ const replacement = isAbsolute(matchedAlias.replacement) ? normalizePath(relative(dir, matchedAlias.replacement)) : normalizePath(matchedAlias.replacement);
473
+ const endSlash = matchResult[1].match(matchedAlias.find)[0].endsWith("/");
474
+ const truthPath = matchResult[1].replace(
475
+ matchedAlias.find,
476
+ replacement + (endSlash ? "/" : "")
477
+ );
478
+ const normalizedPath = normalizePath(relative(dir, resolve$1(dir, truthPath)));
454
479
  return str.replace(
455
480
  isDynamic ? simpleDynamicImportRE : simpleStaticImportRE,
456
- `$1'${matchResult[1].replace(
457
- matchedAlias.find,
458
- (truthPath.startsWith(".") ? truthPath : `./${truthPath}`) + (typeof matchedAlias.find === "string" && matchedAlias.find.endsWith("/") ? "/" : "")
459
- )}'${isDynamic ? ")" : ""}`
481
+ `$1'${ensureStartWithDot(normalizedPath)}'${isDynamic ? ")" : ""}`
460
482
  );
461
483
  }
462
484
  }
@@ -555,7 +577,7 @@ function dtsPlugin(options = {}) {
555
577
  return { find: key, replacement: value };
556
578
  });
557
579
  } else {
558
- aliases = ensureArray(aliasOptions);
580
+ aliases = ensureArray(aliasOptions).map((alias) => ({ ...alias }));
559
581
  }
560
582
  if (aliasesExclude.length > 0) {
561
583
  aliases = aliases.filter(
@@ -564,6 +586,9 @@ function dtsPlugin(options = {}) {
564
586
  )
565
587
  );
566
588
  }
589
+ for (const alias of aliases) {
590
+ alias.replacement = resolve(alias.replacement);
591
+ }
567
592
  },
568
593
  async configResolved(config) {
569
594
  logger = logLevel ? (await import('vite')).createLogger(logLevel, { allowClearScreen: config.clearScreen }) : config.logger;
@@ -961,17 +986,8 @@ export default ${libName}
961
986
  extraOutDirs.map(async (targetOutDir) => {
962
987
  const path = resolve(targetOutDir, relativePath);
963
988
  if (wroteFile.endsWith(".map")) {
964
- const relativeOutDir = relative(outDir, targetOutDir);
965
- if (relativeOutDir) {
966
- try {
967
- const sourceMap = JSON.parse(content);
968
- sourceMap.sources = sourceMap.sources.map((source) => {
969
- return normalizePath(relative(relativeOutDir, source));
970
- });
971
- content = JSON.stringify(sourceMap);
972
- } catch (e) {
973
- logger.warn(`${logPrefix} ${yellow("Processing source map fail:")} ${path}`);
974
- }
989
+ if (!editSourceMapDir(content, outDir, targetOutDir)) {
990
+ logger.warn(`${logPrefix} ${yellow("Processing source map fail:")} ${path}`);
975
991
  }
976
992
  }
977
993
  await writeOutput(path, content, targetOutDir, false);
@@ -980,7 +996,7 @@ export default ${libName}
980
996
  });
981
997
  }
982
998
  if (typeof afterBuild === "function") {
983
- await wrapPromise(afterBuild());
999
+ await wrapPromise(afterBuild(emittedFiles));
984
1000
  }
985
1001
  bundleDebug("finish");
986
1002
  logger.info(
@@ -998,4 +1014,4 @@ export default ${libName}
998
1014
  };
999
1015
  }
1000
1016
 
1001
- export { dtsPlugin as default };
1017
+ export { dtsPlugin as default, editSourceMapDir };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-dts",
3
- "version": "3.6.4",
3
+ "version": "3.7.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "qmhc",
@@ -17,6 +17,7 @@
17
17
  "prettier": "pretty-quick --staged && pnpm run lint",
18
18
  "release": "tsx scripts/release.ts",
19
19
  "test": "vitest run",
20
+ "test:dev": "vitest",
20
21
  "test:react": "pnpm -C examples/react build",
21
22
  "test:svelte": "pnpm -C examples/svelte build",
22
23
  "test:ts": "pnpm -C examples/ts build",
@@ -57,43 +58,43 @@
57
58
  "volar"
58
59
  ],
59
60
  "dependencies": {
60
- "@microsoft/api-extractor": "^7.38.0",
61
- "@rollup/pluginutils": "^5.0.5",
62
- "@vue/language-core": "^1.8.20",
61
+ "@microsoft/api-extractor": "7.39.0",
62
+ "@rollup/pluginutils": "^5.1.0",
63
+ "@vue/language-core": "^1.8.26",
63
64
  "debug": "^4.3.4",
64
65
  "kolorist": "^1.8.0",
65
- "vue-tsc": "^1.8.20"
66
+ "vue-tsc": "^1.8.26"
66
67
  },
67
68
  "devDependencies": {
68
- "@commitlint/cli": "^18.0.0",
69
- "@types/debug": "^4.1.10",
70
- "@types/minimist": "^1.2.4",
71
- "@types/node": "^20.8.8",
72
- "@types/prompts": "^2.4.7",
73
- "@types/semver": "^7.5.4",
74
- "@vexip-ui/commitlint-config": "^0.2.0",
75
- "@vexip-ui/eslint-config": "^0.8.1",
69
+ "@commitlint/cli": "^18.4.3",
70
+ "@types/debug": "^4.1.12",
71
+ "@types/minimist": "^1.2.5",
72
+ "@types/node": "^20.10.5",
73
+ "@types/prompts": "^2.4.9",
74
+ "@types/semver": "^7.5.6",
75
+ "@vexip-ui/commitlint-config": "^0.3.0",
76
+ "@vexip-ui/eslint-config": "^0.11.0",
76
77
  "@vexip-ui/prettier-config": "^0.2.0",
77
78
  "@vue/eslint-config-standard": "^8.0.1",
78
79
  "@vue/eslint-config-typescript": "^12.0.0",
79
80
  "conventional-changelog-cli": "^4.1.0",
80
- "eslint": "^8.52.0",
81
+ "eslint": "^8.56.0",
81
82
  "execa": "^8.0.1",
82
83
  "husky": "^8.0.3",
83
84
  "is-ci": "^3.0.1",
84
- "lint-staged": "^15.0.2",
85
+ "lint-staged": "^15.2.0",
85
86
  "minimist": "^1.2.8",
86
87
  "pinst": "^3.0.0",
87
- "prettier": "^3.0.3",
88
+ "prettier": "^3.1.1",
88
89
  "pretty-quick": "^3.1.3",
89
90
  "prompts": "^2.4.2",
90
91
  "rimraf": "^5.0.5",
91
92
  "semver": "^7.5.4",
92
- "tsx": "^3.14.0",
93
+ "tsx": "^4.7.0",
93
94
  "typescript": "5.2.2",
94
95
  "unbuild": "^2.0.0",
95
- "vite": "^4.5.0",
96
- "vitest": "^0.34.6"
96
+ "vite": "^5.0.10",
97
+ "vitest": "^1.1.0"
97
98
  },
98
99
  "peerDependencies": {
99
100
  "typescript": "*",
@@ -106,7 +107,7 @@
106
107
  },
107
108
  "pnpm": {
108
109
  "patchedDependencies": {
109
- "@microsoft/api-extractor@7.38.0": "patches/@microsoft__api-extractor@7.38.0.patch"
110
+ "@microsoft/api-extractor@7.39.0": "patches/@microsoft__api-extractor@7.39.0.patch"
110
111
  }
111
112
  }
112
113
  }