vite-plugin-dts 4.0.3 → 4.1.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 CHANGED
@@ -53,6 +53,14 @@ If you want to merge all declarations into one file, just specify `rollupTypes:
53
53
  }
54
54
  ```
55
55
 
56
+ If you start with official Vite template, you should specify the `tsconfigPath`:
57
+
58
+ ```ts
59
+ {
60
+ plugins: [dts({ tsconfigPath: './tsconfig.app.json' })]
61
+ }
62
+ ```
63
+
56
64
  Starting with `3.0.0`, you can use this plugin with Rollup.
57
65
 
58
66
  ## FAQ
@@ -148,145 +156,146 @@ export interface Resolver {
148
156
  root: string,
149
157
  outDir: string,
150
158
  host: ts.CompilerHost,
151
- program: ts.Program,
152
- service: ts.LanguageService
159
+ program: ts.Program
153
160
  }) => MaybePromise<{ path: string, content: string }[]>
154
161
  }
155
162
 
156
163
  export interface PluginOptions {
157
164
  /**
158
- * Specify root directory
165
+ * Specify root directory.
159
166
  *
160
- * Defaults to the 'root' of the Vite config, or `process.cwd()` if using Rollup
167
+ * Defaults to the 'root' of the Vite config, or `process.cwd()` if using Rollup.
161
168
  */
162
169
  root?: string,
163
170
 
164
171
  /**
165
- * Output directory for declaration files
172
+ * Output directory for declaration files.
166
173
  *
167
- * Can be an array to output to multiple directories
174
+ * Can be an array to output to multiple directories.
168
175
  *
169
- * Defaults to 'build.outDir' of the Vite config, or `outDir` of tsconfig.json if using Rollup
176
+ * Defaults to 'build.outDir' of the Vite config, or `outDir` of tsconfig.json if using Rollup.
170
177
  */
171
178
  outDir?: string | string[],
172
179
 
173
180
  /**
174
- * Override root path of entry files (useful in monorepos)
181
+ * Override root path of entry files (useful in monorepos).
175
182
  *
176
- * The output path of each file will be calculated based on the value provided
183
+ * The output path of each file will be calculated based on the value provided.
177
184
  *
178
- * The default is the smallest public path for all source files
185
+ * The default is the smallest public path for all source files.
179
186
  */
180
187
  entryRoot?: string,
181
188
 
182
189
  /**
183
- * Restrict declaration files output to `outDir`
190
+ * Restrict declaration files output to `outDir`.
184
191
  *
185
- * If true, generated declaration files outside `outDir` will be ignored
192
+ * If true, generated declaration files outside `outDir` will be ignored.
186
193
  *
187
194
  * @default true
188
195
  */
189
196
  strictOutput?: boolean,
190
197
 
191
198
  /**
192
- * Override compilerOptions
199
+ * Override compilerOptions.
193
200
  *
194
201
  * @default null
195
202
  */
196
203
  compilerOptions?: ts.CompilerOptions | null,
197
204
 
198
205
  /**
199
- * Specify tsconfig.json path
206
+ * Specify tsconfig.json path.
200
207
  *
201
- * Plugin resolves `include` and `exclude` globs from tsconfig.json
208
+ * Plugin resolves `include` and `exclude` globs from tsconfig.json.
202
209
  *
203
- * If not specified, plugin will find config file from root
210
+ * If not specified, plugin will find config file from root.
204
211
  */
205
212
  tsconfigPath?: string,
206
213
 
207
214
  /**
208
- * Specify custom resolvers
215
+ * Specify custom resolvers.
209
216
  *
210
217
  * @default []
211
218
  */
212
219
  resolvers?: Resolver[],
213
220
 
214
221
  /**
215
- * Parsing `paths` of tsconfig.json to aliases
222
+ * Parsing `paths` of tsconfig.json to aliases.
216
223
  *
217
- * Note that these aliases only use for declaration files
224
+ * Note that these aliases only use for declaration files.
218
225
  *
219
226
  * @default true
220
- * @remarks Only use first replacement of each path
227
+ * @remarks Only use first replacement of each path.
221
228
  */
222
229
  pathsToAliases?: boolean,
223
230
 
224
231
  /**
225
- * Set which paths should be excluded when transforming aliases
232
+ * Set which paths should be excluded when transforming aliases.
226
233
  *
227
234
  * @default []
228
235
  */
229
236
  aliasesExclude?: (string | RegExp)[],
230
237
 
231
238
  /**
232
- * Whether to transform file names ending in '.vue.d.ts' to '.d.ts'
239
+ * Whether to transform file names ending in '.vue.d.ts' to '.d.ts'.
240
+ *
241
+ * If there is a duplicate name after transform, it will fall back to the original name.
233
242
  *
234
243
  * @default false
235
244
  */
236
245
  cleanVueFileName?: boolean,
237
246
 
238
247
  /**
239
- * Whether to transform dynamic imports to static (eg `import('vue').DefineComponent` to `import { DefineComponent } from 'vue'`)
248
+ * Whether to transform dynamic imports to static (eg `import('vue').DefineComponent` to `import { DefineComponent } from 'vue'`).
240
249
  *
241
- * Value is forced to `true` when `rollupTypes` is `true`
250
+ * Value is forced to `true` when `rollupTypes` is `true`.
242
251
  *
243
252
  * @default false
244
253
  */
245
254
  staticImport?: boolean,
246
255
 
247
256
  /**
248
- * Override `include` glob (relative to root)
257
+ * Override `include` glob (relative to root).
249
258
  *
250
- * Defaults to `include` property of tsconfig.json (relative to tsconfig.json located)
259
+ * Defaults to `include` property of tsconfig.json (relative to tsconfig.json located).
251
260
  */
252
261
  include?: string | string[],
253
262
 
254
263
  /**
255
- * Override `exclude` glob
264
+ * Override `exclude` glob.
256
265
  *
257
266
  * Defaults to `exclude` property of tsconfig.json or `'node_modules/**'` if not supplied.
258
267
  */
259
268
  exclude?: string | string[],
260
269
 
261
270
  /**
262
- * Whether to remove `import 'xxx'`
271
+ * Whether to remove `import 'xxx'`.
263
272
  *
264
273
  * @default true
265
274
  */
266
275
  clearPureImport?: boolean,
267
276
 
268
277
  /**
269
- * Whether to generate types entry file(s)
278
+ * Whether to generate types entry file(s).
270
279
  *
271
- * When `true`, uses package.json `types` property if it exists or `${outDir}/index.d.ts`
280
+ * When `true`, uses package.json `types` property if it exists or `${outDir}/index.d.ts`.
272
281
  *
273
- * Value is forced to `true` when `rollupTypes` is `true`
282
+ * Value is forced to `true` when `rollupTypes` is `true`.
274
283
  *
275
284
  * @default false
276
285
  */
277
286
  insertTypesEntry?: boolean,
278
287
 
279
288
  /**
280
- * Rollup type declaration files after emitting them
289
+ * Rollup type declaration files after emitting them.
281
290
  *
282
- * Powered by `@microsoft/api-extractor` - time-intensive operation
291
+ * Powered by `@microsoft/api-extractor` - time-intensive operation.
283
292
  *
284
293
  * @default false
285
294
  */
286
295
  rollupTypes?: boolean,
287
296
 
288
297
  /**
289
- * Bundled packages for `@microsoft/api-extractor`
298
+ * Bundled packages for `@microsoft/api-extractor`.
290
299
  *
291
300
  * @default []
292
301
  * @see https://api-extractor.com/pages/configs/api-extractor_json/#bundledpackages
@@ -294,7 +303,7 @@ export interface PluginOptions {
294
303
  bundledPackages?: string[],
295
304
 
296
305
  /**
297
- * Override the config of `@microsoft/api-extractor`
306
+ * Override the config of `@microsoft/api-extractor`.
298
307
  *
299
308
  * @default null
300
309
  * @see https://api-extractor.com/pages/setup/configure_api_report/
@@ -302,7 +311,7 @@ export interface PluginOptions {
302
311
  rollupConfig?: RollupConfig,
303
312
 
304
313
  /**
305
- * Override the invoke options of `@microsoft/api-extractor`
314
+ * Override the invoke options of `@microsoft/api-extractor`.
306
315
  *
307
316
  * @default null
308
317
  * @see https://api-extractor.com/pages/setup/invoking/#invoking-from-a-build-script
@@ -310,44 +319,44 @@ export interface PluginOptions {
310
319
  rollupOptions?: IExtractorInvokeOptions,
311
320
 
312
321
  /**
313
- * Whether to copy .d.ts source files to `outDir`
322
+ * Whether to copy .d.ts source files to `outDir`.
314
323
  *
315
324
  * @default false
316
- * @remarks Before 2.0, the default was `true`
325
+ * @remarks Before 2.0, the default was `true`.
317
326
  */
318
327
  copyDtsFiles?: boolean,
319
328
 
320
329
  /**
321
- * Whether to emit declaration files only
330
+ * Whether to emit declaration files only.
322
331
  *
323
- * When `true`, all the original outputs of vite (rollup) will be force removed
332
+ * When `true`, all the original outputs of vite (rollup) will be force removed.
324
333
  *
325
334
  * @default false
326
335
  */
327
336
  declarationOnly?: boolean,
328
337
 
329
338
  /**
330
- * Logging level for this plugin
339
+ * Logging level for this plugin.
331
340
  *
332
- * Defaults to the 'logLevel' property of your Vite config
341
+ * Defaults to the 'logLevel' property of your Vite config.
333
342
  */
334
343
  logLevel?: LogLevel,
335
344
 
336
345
  /**
337
- * Hook called after diagnostic is emitted
346
+ * Hook called after diagnostic is emitted.
338
347
  *
339
- * According to the `diagnostics.length`, you can judge whether there is any type error
348
+ * According to the `diagnostics.length`, you can judge whether there is any type error.
340
349
  *
341
350
  * @default () => {}
342
351
  */
343
352
  afterDiagnostic?: (diagnostics: readonly ts.Diagnostic[]) => MaybePromise<void>,
344
353
 
345
354
  /**
346
- * Hook called prior to writing each declaration file
355
+ * Hook called prior to writing each declaration file.
347
356
  *
348
- * This allows you to transform the path or content
357
+ * This allows you to transform the path or content.
349
358
  *
350
- * The file will be skipped when the return value `false` or `Promise<false>`
359
+ * The file will be skipped when the return value `false` or `Promise<false>`.
351
360
  *
352
361
  * @default () => {}
353
362
  */
@@ -364,20 +373,20 @@ export interface PluginOptions {
364
373
  >,
365
374
 
366
375
  /**
367
- * Hook called after rolling up declaration files
376
+ * Hook called after rolling up declaration files.
368
377
  *
369
378
  * @default () => {}
370
379
  */
371
380
  afterRollup?: (result: ExtractorResult) => MaybePromise<void>,
372
381
 
373
382
  /**
374
- * Hook called after all declaration files are written
383
+ * Hook called after all declaration files are written.
375
384
  *
376
- * It will be received a map (path -> content) that records those emitted files
385
+ * It will be received a map (path -> content) that records those emitted files.
377
386
  *
378
387
  * @default () => {}
379
388
  */
380
- afterBuild?: () => MaybePromise<void>
389
+ afterBuild?: (emittedFiles: Map<string, string>) => MaybePromise<void>
381
390
  }
382
391
  ```
383
392
 
package/README.zh-CN.md CHANGED
@@ -53,6 +53,14 @@ export default defineConfig({
53
53
  }
54
54
  ```
55
55
 
56
+ 如果你从 Vite 官方模板开始,你应该指定 `tsconfigPath`:
57
+
58
+ ```ts
59
+ {
60
+ plugins: [dts({ tsconfigPath: './tsconfig.app.json' })]
61
+ }
62
+ ```
63
+
56
64
  从 `3.0.0` 开始,你可以在 Rollup 中使用该插件。
57
65
 
58
66
  ## 常见问题
@@ -149,7 +157,6 @@ export interface Resolver {
149
157
  outDir: string,
150
158
  host: ts.CompilerHost,
151
159
  program: ts.Program,
152
- service: ts.LanguageService
153
160
  }) => MaybePromise<{ path: string, content: string }[]>
154
161
  }
155
162
 
@@ -231,6 +238,8 @@ export interface PluginOptions {
231
238
  /**
232
239
  * 是否将 '.vue.d.ts' 文件名转换为 '.d.ts'
233
240
  *
241
+ * 如果转换后出现重名,将会回退到原来的名字。
242
+ *
234
243
  * @default false
235
244
  */
236
245
  cleanVueFileName?: boolean,
package/dist/index.cjs CHANGED
@@ -10,73 +10,20 @@ const languageCore = require('@vue/language-core');
10
10
  const typescript = require('@volar/typescript');
11
11
  const ts = require('typescript');
12
12
  const vueTsc = require('vue-tsc');
13
+ const localPkg = require('local-pkg');
13
14
  const pluginutils = require('@rollup/pluginutils');
14
15
  const debug = require('debug');
15
16
  const kolorist = require('kolorist');
16
17
  const apiExtractor = require('@microsoft/api-extractor');
17
- const node_module = require('node:module');
18
- const localPkg = require('local-pkg');
19
18
  const compareVersions = require('compare-versions');
20
19
  const MagicString = require('magic-string');
21
20
 
22
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
23
21
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
24
22
 
25
23
  const ts__default = /*#__PURE__*/_interopDefaultCompat(ts);
26
24
  const debug__default = /*#__PURE__*/_interopDefaultCompat(debug);
27
25
  const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
28
26
 
29
- const _createProgram = typescript.proxyCreateProgram(ts__default, ts__default.createProgram, (ts2, options) => {
30
- const { configFilePath } = options.options;
31
- const vueOptions = typeof configFilePath === "string" ? languageCore.createParsedCommandLine(ts2, ts2.sys, configFilePath.replace(/\\/g, "/")).vueOptions : languageCore.resolveVueCompilerOptions({});
32
- if (options.host) {
33
- const writeFile = options.host.writeFile.bind(options.host);
34
- options.host.writeFile = (fileName, contents, ...args) => {
35
- return writeFile(fileName, vueTsc.removeEmitGlobalTypes(contents), ...args);
36
- };
37
- }
38
- const vueLanguagePlugin = languageCore.createVueLanguagePlugin2(
39
- ts2,
40
- (id) => id,
41
- languageCore.createRootFileChecker(
42
- void 0,
43
- () => options.rootNames.map((rootName) => rootName.replace(/\\/g, "/")),
44
- options.host?.useCaseSensitiveFileNames?.() ?? false
45
- ),
46
- options.options,
47
- vueOptions
48
- );
49
- return [vueLanguagePlugin];
50
- });
51
- const createProgram = (options) => {
52
- const program = _createProgram(options);
53
- const emit = program.emit;
54
- program.emit = (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) => {
55
- if (writeFile) {
56
- return emit(
57
- targetSourceFile,
58
- (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
59
- if (fileName.endsWith(".d.ts")) {
60
- data = vueTsc.removeEmitGlobalTypes(data);
61
- }
62
- return writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
63
- },
64
- cancellationToken,
65
- emitOnlyDtsFiles,
66
- customTransformers
67
- );
68
- }
69
- return emit(
70
- targetSourceFile,
71
- writeFile,
72
- cancellationToken,
73
- emitOnlyDtsFiles,
74
- customTransformers
75
- );
76
- };
77
- return program;
78
- };
79
-
80
27
  const windowsSlashRE = /\\+/g;
81
28
  function slash(p) {
82
29
  return p.replace(windowsSlashRE, "/");
@@ -200,25 +147,9 @@ function getTsConfig(tsConfigPath, readFileSync) {
200
147
  Object.assign(tsConfig.compilerOptions, baseConfig.compilerOptions);
201
148
  return tsConfig;
202
149
  }
203
- function getTsLibFolder({ root, entryRoot }) {
204
- let libFolder;
205
- try {
206
- libFolder = normalizePath(node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).resolve("typescript")).replace(
207
- /node_modules\/typescript.*/,
208
- "node_modules/typescript"
209
- );
210
- } catch {
211
- libFolder = resolve(root, "node_modules/typescript");
212
- if (!node_fs.existsSync(libFolder)) {
213
- if (root !== entryRoot) {
214
- libFolder = resolve(entryRoot, "node_modules/typescript");
215
- if (!node_fs.existsSync(libFolder))
216
- libFolder = void 0;
217
- }
218
- libFolder = void 0;
219
- }
220
- }
221
- return libFolder;
150
+ function getTsLibFolder() {
151
+ const libFolder = tryGetPackageInfo("typescript")?.rootPath;
152
+ return libFolder && normalizePath(libFolder);
222
153
  }
223
154
  const BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
224
155
  function base64Encode(number) {
@@ -328,7 +259,7 @@ function parseTsAliases(basePath, paths) {
328
259
  const result = [];
329
260
  for (const [pathWithAsterisk, replacements] of Object.entries(paths)) {
330
261
  const find = new RegExp(
331
- `^${pathWithAsterisk.replace(regexpSymbolRE, "\\$1").replace(asteriskRE, "([^\\/]+)")}$`
262
+ `^${pathWithAsterisk.replace(regexpSymbolRE, "\\$1").replace(asteriskRE, "(.+)")}$`
332
263
  );
333
264
  let index = 1;
334
265
  result.push({
@@ -341,6 +272,64 @@ function parseTsAliases(basePath, paths) {
341
272
  }
342
273
  return result;
343
274
  }
275
+ function tryGetPackageInfo(name) {
276
+ try {
277
+ return localPkg.getPackageInfoSync(name) ?? localPkg.getPackageInfoSync(name, { paths: [localPkg.resolveModule(name) || process.cwd()] });
278
+ } catch (e) {
279
+ }
280
+ }
281
+
282
+ const hasVue = !!tryGetPackageInfo("vue");
283
+ const _createProgram = !hasVue ? ts__default.createProgram : typescript.proxyCreateProgram(ts__default, ts__default.createProgram, (ts2, options) => {
284
+ const { configFilePath } = options.options;
285
+ const vueOptions = typeof configFilePath === "string" ? languageCore.createParsedCommandLine(ts2, ts2.sys, configFilePath.replace(/\\/g, "/")).vueOptions : languageCore.resolveVueCompilerOptions({});
286
+ if (options.host) {
287
+ const writeFile = options.host.writeFile.bind(options.host);
288
+ options.host.writeFile = (fileName, contents, ...args) => {
289
+ return writeFile(fileName, vueTsc.removeEmitGlobalTypes(contents), ...args);
290
+ };
291
+ }
292
+ const vueLanguagePlugin = languageCore.createVueLanguagePlugin2(
293
+ ts2,
294
+ (id) => id,
295
+ languageCore.createRootFileChecker(
296
+ void 0,
297
+ () => options.rootNames.map((rootName) => rootName.replace(/\\/g, "/")),
298
+ options.host?.useCaseSensitiveFileNames?.() ?? false
299
+ ),
300
+ options.options,
301
+ vueOptions
302
+ );
303
+ return [vueLanguagePlugin];
304
+ });
305
+ const createProgram = !hasVue ? ts__default.createProgram : (options) => {
306
+ const program = _createProgram(options);
307
+ const emit = program.emit;
308
+ program.emit = (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) => {
309
+ if (writeFile) {
310
+ return emit(
311
+ targetSourceFile,
312
+ (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
313
+ if (fileName.endsWith(".d.ts")) {
314
+ data = vueTsc.removeEmitGlobalTypes(data);
315
+ }
316
+ return writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
317
+ },
318
+ cancellationToken,
319
+ emitOnlyDtsFiles,
320
+ customTransformers
321
+ );
322
+ }
323
+ return emit(
324
+ targetSourceFile,
325
+ writeFile,
326
+ cancellationToken,
327
+ emitOnlyDtsFiles,
328
+ customTransformers
329
+ );
330
+ };
331
+ return program;
332
+ };
344
333
 
345
334
  const dtsRE$1 = /\.d\.(m|c)?tsx?$/;
346
335
  function rollupDeclarationFiles({
@@ -354,7 +343,7 @@ function rollupDeclarationFiles({
354
343
  rollupConfig = {},
355
344
  rollupOptions = {}
356
345
  }) {
357
- const configObjectFullPath = node_path.resolve(root, "api-extractor.json");
346
+ const configObjectFullPath = resolve(root, "api-extractor.json");
358
347
  if (!dtsRE$1.test(fileName)) {
359
348
  fileName += ".d.ts";
360
349
  }
@@ -384,7 +373,7 @@ function rollupDeclarationFiles({
384
373
  },
385
374
  dtsRollup: {
386
375
  enabled: true,
387
- publicTrimmedFilePath: node_path.resolve(outDir, fileName)
376
+ publicTrimmedFilePath: resolve(outDir, fileName)
388
377
  },
389
378
  tsdocMetadata: {
390
379
  enabled: false,
@@ -411,7 +400,7 @@ function rollupDeclarationFiles({
411
400
  localBuild: false,
412
401
  showVerboseMessages: false,
413
402
  showDiagnostics: false,
414
- typescriptCompilerFolder: libFolder ? node_path.resolve(libFolder) : void 0,
403
+ typescriptCompilerFolder: libFolder,
415
404
  ...rollupOptions
416
405
  });
417
406
  }
@@ -446,9 +435,9 @@ function querySvelteVersion() {
446
435
  if (typeof lowerVersion === "boolean")
447
436
  return;
448
437
  try {
449
- const version = localPkg.getPackageInfoSync("svelte")?.version ?? localPkg.getPackageInfoSync("svelte", { paths: [localPkg.resolveModule("svelte") || process.cwd()] })?.version;
438
+ const version = tryGetPackageInfo("svelte")?.version;
450
439
  lowerVersion = version ? compareVersions.compare(version, "4.0.0", "<") : false;
451
- } catch {
440
+ } catch (e) {
452
441
  lowerVersion = false;
453
442
  }
454
443
  }
@@ -796,8 +785,9 @@ function dtsPlugin(options = {}) {
796
785
  };
797
786
  const rollupConfig = { ...options.rollupConfig || {} };
798
787
  rollupConfig.bundledPackages = rollupConfig.bundledPackages || options.bundledPackages || [];
799
- const cleanPath = (path) => {
800
- return cleanVueFileName ? path.replace(".vue.d.ts", ".d.ts") : path;
788
+ const cleanPath = (path, emittedFiles) => {
789
+ const newPath = path.replace(".vue.d.ts", ".d.ts");
790
+ return !emittedFiles.has(newPath) && cleanVueFileName ? newPath : path;
801
791
  };
802
792
  return {
803
793
  name: pluginName,
@@ -1167,7 +1157,10 @@ ${logPrefix} Start generate declaration files...`));
1167
1157
  const entryNames = Object.keys(entries);
1168
1158
  const types = findTypesPath(pkg.publishConfig, pkg);
1169
1159
  const multiple = entryNames.length > 1;
1170
- let typesPath = cleanPath(types ? resolve(root, types) : resolve(outDir, indexName));
1160
+ let typesPath = cleanPath(
1161
+ types ? resolve(root, types) : resolve(outDir, indexName),
1162
+ emittedFiles
1163
+ );
1171
1164
  if (!multiple && !dtsRE.test(typesPath)) {
1172
1165
  logger.warn(
1173
1166
  `
@@ -1179,11 +1172,11 @@ ${logPrefix} ${kolorist.yellow(
1179
1172
  typesPath = `${typesPath.replace(tjsRE, "")}.d.${extPrefix(typesPath)}ts`;
1180
1173
  }
1181
1174
  for (const name of entryNames) {
1182
- const entryDtsPath = multiple ? cleanPath(resolve(outDir, tsToDts(name))) : typesPath;
1175
+ const entryDtsPath = multiple ? cleanPath(resolve(outDir, tsToDts(name)), emittedFiles) : typesPath;
1183
1176
  if (node_fs.existsSync(entryDtsPath))
1184
1177
  continue;
1185
1178
  const sourceEntry = normalizePath(
1186
- cleanPath(resolve(outDir, node_path.relative(entryRoot, tsToDts(entries[name]))))
1179
+ cleanPath(resolve(outDir, node_path.relative(entryRoot, tsToDts(entries[name]))), emittedFiles)
1187
1180
  );
1188
1181
  let fromPath = normalizePath(node_path.relative(node_path.dirname(entryDtsPath), sourceEntry));
1189
1182
  fromPath = fromPath.replace(dtsRE, "");
@@ -1200,7 +1193,7 @@ export default ${libName}
1200
1193
  ${content}`;
1201
1194
  }
1202
1195
  }
1203
- await writeOutput(cleanPath(entryDtsPath), content, outDir);
1196
+ await writeOutput(cleanPath(entryDtsPath, emittedFiles), content, outDir);
1204
1197
  }
1205
1198
  bundleDebug("insert index");
1206
1199
  if (rollupTypes) {
@@ -1215,7 +1208,7 @@ ${content}`;
1215
1208
  outDir,
1216
1209
  entryPath: path,
1217
1210
  fileName: node_path.basename(path),
1218
- libFolder: getTsLibFolder({ root, entryRoot }),
1211
+ libFolder: getTsLibFolder(),
1219
1212
  rollupConfig,
1220
1213
  rollupOptions
1221
1214
  });
@@ -1227,7 +1220,7 @@ ${content}`;
1227
1220
  };
1228
1221
  if (multiple) {
1229
1222
  await runParallel(node_os.cpus().length, entryNames, async (name) => {
1230
- await rollup(cleanPath(resolve(outDir, tsToDts(name))));
1223
+ await rollup(cleanPath(resolve(outDir, tsToDts(name)), emittedFiles));
1231
1224
  });
1232
1225
  } else {
1233
1226
  await rollup(typesPath);