vite-plugin-dts 1.6.6 → 1.7.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.cjs CHANGED
@@ -12,6 +12,7 @@ const require$$1$1 = require('fs');
12
12
  const require$$1 = require('path');
13
13
  const require$$5 = require('buffer');
14
14
  const require$$7 = require('inspector');
15
+ const pluginutils = require('@rollup/pluginutils');
15
16
  const node_fs = require('node:fs');
16
17
  const node_module = require('node:module');
17
18
  const apiExtractor = require('@microsoft/api-extractor');
@@ -21,17 +22,6 @@ const SourceMapper_js = require('@microsoft/api-extractor/lib/collector/SourceMa
21
22
  const DtsRollupGenerator_js = require('@microsoft/api-extractor/lib/generators/DtsRollupGenerator.js');
22
23
  const nodeCoreLibrary = require('@rushstack/node-core-library');
23
24
 
24
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
25
-
26
- const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
27
- const os__default = /*#__PURE__*/_interopDefaultLegacy(os);
28
- const glob__default = /*#__PURE__*/_interopDefaultLegacy(glob);
29
- const debug__default = /*#__PURE__*/_interopDefaultLegacy(debug);
30
- const require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
31
- const require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
32
- const require$$5__default = /*#__PURE__*/_interopDefaultLegacy(require$$5);
33
- const require$$7__default = /*#__PURE__*/_interopDefaultLegacy(require$$7);
34
-
35
25
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
36
26
 
37
27
  function getDefaultExportFromCjs (x) {
@@ -3370,7 +3360,7 @@ function requireSourceMapSupport () {
3370
3360
  hasRequiredSourceMapSupport = 1;
3371
3361
  (function (module, exports) {
3372
3362
  var SourceMapConsumer = requireSourceMap().SourceMapConsumer;
3373
- var path = require$$1__default;
3363
+ var path = require$$1;
3374
3364
 
3375
3365
  var fs;
3376
3366
  try {
@@ -11055,9 +11045,9 @@ and limitations under the License.
11055
11045
  var byteOrderMarkIndicator = "\uFEFF";
11056
11046
  function getNodeSystem() {
11057
11047
  var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/;
11058
- var _fs = require$$1__default$1;
11059
- var _path = require$$1__default;
11060
- var _os = os__default;
11048
+ var _fs = require$$1$1;
11049
+ var _path = require$$1;
11050
+ var _os = os;
11061
11051
  // crypto can be absent on reduced node installations
11062
11052
  var _crypto;
11063
11053
  try {
@@ -11068,7 +11058,7 @@ and limitations under the License.
11068
11058
  }
11069
11059
  var activeSession;
11070
11060
  var profilePath = "./profile.cpuprofile";
11071
- var Buffer = require$$5__default.Buffer;
11061
+ var Buffer = require$$5.Buffer;
11072
11062
  var nodeVersion = getNodeMajorVersion();
11073
11063
  var isNode4OrLater = nodeVersion >= 4;
11074
11064
  var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
@@ -11221,7 +11211,7 @@ and limitations under the License.
11221
11211
  cb();
11222
11212
  return false;
11223
11213
  }
11224
- var inspector = require$$7__default;
11214
+ var inspector = require$$7;
11225
11215
  if (!inspector || !inspector.Session) {
11226
11216
  cb();
11227
11217
  return false;
@@ -176693,6 +176683,10 @@ function requireCompiler() {
176693
176683
  try {
176694
176684
  compiler = _require(_require.resolve("vue/compiler-sfc", { paths: [compileRoot] }));
176695
176685
  } catch (e) {
176686
+ try {
176687
+ compiler = _require(_require.resolve("@vue/compiler-sfc", { paths: [compileRoot] }));
176688
+ } catch (e2) {
176689
+ }
176696
176690
  }
176697
176691
  }
176698
176692
  if (!compiler) {
@@ -176776,7 +176770,7 @@ const _sfc_main = ${classMatch[1]}`;
176776
176770
  content = rewriteDefault(
176777
176771
  script.content,
176778
176772
  "_sfc_main",
176779
- script.lang === "ts" ? ["typescript"] : void 0
176773
+ script.lang === "ts" ? ["typescript", "decorators-legacy"] : void 0
176780
176774
  );
176781
176775
  content += "\nexport default _sfc_main\n";
176782
176776
  ext = script.lang || "js";
@@ -176871,19 +176865,18 @@ function rollupDeclarationFiles({
176871
176865
  }
176872
176866
 
176873
176867
  const noneExport = "export {};\n";
176874
- const virtualPrefix = "\0";
176875
176868
  const vueRE = /\.vue$/;
176876
- const tsRE = /\.tsx?$/;
176877
- const jsRE = /\.jsx?$/;
176869
+ const tsRE = /\.(m|c)?tsx?$/;
176870
+ const jsRE = /\.(m|c)?jsx?$/;
176878
176871
  const dtsRE = /\.d\.tsx?$/;
176879
- const tjsRE = /\.(t|j)sx?$/;
176880
- const watchExtensionRE = /\.(vue|(t|j)sx?)$/;
176872
+ const tjsRE = /\.(m|c)?(t|j)sx?$/;
176873
+ const watchExtensionRE = /\.(vue|(m|c)?(t|j)sx?)$/;
176881
176874
  const fullRelativeRE = /^\.\.?\//;
176882
176875
  const defaultIndex = "index.d.ts";
176883
176876
  const noop = () => {
176884
176877
  };
176885
176878
  const logPrefix = kolorist.cyan("[vite:dts]");
176886
- const bundleDebug = debug__default("vite-plugin-dts:bundle");
176879
+ const bundleDebug = debug("vite-plugin-dts:bundle");
176887
176880
  function dtsPlugin(options = {}) {
176888
176881
  const {
176889
176882
  tsConfigFilePath = "tsconfig.json",
@@ -176894,9 +176887,10 @@ function dtsPlugin(options = {}) {
176894
176887
  insertTypesEntry = false,
176895
176888
  rollupTypes = false,
176896
176889
  noEmitOnError = false,
176897
- skipDiagnostics = true,
176898
- logDiagnostics = false,
176890
+ skipDiagnostics = false,
176891
+ logDiagnostics = void 0,
176899
176892
  copyDtsFiles = true,
176893
+ libFolderPath = void 0,
176900
176894
  afterDiagnostic = noop,
176901
176895
  beforeWriteFile = noop,
176902
176896
  afterBuild = noop
@@ -176913,6 +176907,9 @@ function dtsPlugin(options = {}) {
176913
176907
  let tsConfigPath;
176914
176908
  let outputDirs;
176915
176909
  let isBundle = false;
176910
+ let include;
176911
+ let exclude;
176912
+ let filter;
176916
176913
  const sourceDtsFiles = /* @__PURE__ */ new Set();
176917
176914
  let hasJsVue = false;
176918
176915
  let allowJs = false;
@@ -176943,6 +176940,17 @@ function dtsPlugin(options = {}) {
176943
176940
  if (isBundle)
176944
176941
  return;
176945
176942
  logger = config.logger;
176943
+ if (logDiagnostics != null) {
176944
+ logger.warn(
176945
+ kolorist.yellow(
176946
+ `
176947
+ ${kolorist.cyan(
176948
+ "[vite:dts]"
176949
+ )} 'logDiagnostics' has been deprecated, the original feature now following 'skipDiagnostics'.
176950
+ `
176951
+ )
176952
+ );
176953
+ }
176946
176954
  if (!config.build.lib) {
176947
176955
  logger.warn(
176948
176956
  kolorist.yellow(
@@ -176957,8 +176965,9 @@ ${kolorist.cyan(
176957
176965
  indexName = defaultIndex;
176958
176966
  } else {
176959
176967
  const filename = config.build.lib.fileName ?? defaultIndex;
176968
+ const entry = typeof config.build.lib.entry === "string" ? config.build.lib.entry : Object.values(config.build.lib.entry)[0];
176960
176969
  libName = config.build.lib.name || "_default";
176961
- indexName = typeof filename === "string" ? filename : filename("es");
176970
+ indexName = typeof filename === "string" ? filename : filename("es", entry);
176962
176971
  if (!dtsRE.test(indexName)) {
176963
176972
  indexName = `${tjsRE.test(indexName) ? indexName.replace(tjsRE, "") : indexName}.d.ts`;
176964
176973
  }
@@ -176991,17 +177000,33 @@ ${kolorist.cyan(
176991
177000
  emitDeclarationOnly: true
176992
177001
  }),
176993
177002
  tsConfigFilePath: tsConfigPath,
176994
- skipAddingFilesFromTsConfig: true
177003
+ skipAddingFilesFromTsConfig: true,
177004
+ libFolderPath: libFolderPath ? ensureAbsolute(libFolderPath, root) : void 0
176995
177005
  });
176996
177006
  allowJs = project.getCompilerOptions().allowJs ?? false;
177007
+ const tsConfig = typescript.readConfigFile(tsConfigPath, project.getFileSystem().readFileSync).config ?? {};
177008
+ const parentTsConfigPath = tsConfig.extends && ensureAbsolute(tsConfig.extends, root);
177009
+ const parentTsConfig = parentTsConfigPath ? typescript.readConfigFile(parentTsConfigPath, project.getFileSystem().readFileSync).config : {};
177010
+ include = ensureArray(
177011
+ options.include ?? tsConfig.include ?? parentTsConfig.include ?? "**/*"
177012
+ ).map(normalizeGlob);
177013
+ exclude = ensureArray(
177014
+ options.exclude ?? tsConfig.exclude ?? parentTsConfig.exclude ?? "node_modules/**"
177015
+ ).map(normalizeGlob);
177016
+ filter = pluginutils.createFilter(include, exclude, { resolve: root });
176997
177017
  },
176998
177018
  buildStart(inputOptions) {
176999
- if (!isBundle && (insertTypesEntry || rollupTypes)) {
177000
- entries = Array.isArray(inputOptions.input) ? inputOptions.input : Object.values(inputOptions.input);
177019
+ if (Array.isArray(inputOptions.input)) {
177020
+ entries = inputOptions.input.reduce((prev, current) => {
177021
+ prev[node_path.basename(current)] = current;
177022
+ return prev;
177023
+ }, {});
177024
+ } else {
177025
+ entries = { ...inputOptions.input };
177001
177026
  }
177002
177027
  },
177003
177028
  transform(code, id) {
177004
- if (id.startsWith(virtualPrefix)) {
177029
+ if (!filter(id)) {
177005
177030
  return null;
177006
177031
  }
177007
177032
  if (vueRE.test(id)) {
@@ -177012,7 +177037,7 @@ ${kolorist.cyan(
177012
177037
  project.createSourceFile(`${id}.${ext || "js"}`, content, { overwrite: true });
177013
177038
  }
177014
177039
  } else if (!id.includes(".vue?vue") && (tsRE.test(id) || allowJs && jsRE.test(id))) {
177015
- project.addSourceFileAtPath(id);
177040
+ project.createSourceFile(id, code, { overwrite: true });
177016
177041
  }
177017
177042
  return null;
177018
177043
  },
@@ -177034,18 +177059,12 @@ ${logPrefix} Start generate declaration files...`));
177034
177059
  isBundle = true;
177035
177060
  sourceDtsFiles.clear();
177036
177061
  const startTime = Date.now();
177037
- const tsConfig = typescript.readConfigFile(tsConfigPath, project.getFileSystem().readFileSync).config ?? {};
177038
- const parentTsConfigPath = tsConfig.extends && ensureAbsolute(tsConfig.extends, root);
177039
- const parentTsConfig = parentTsConfigPath ? typescript.readConfigFile(parentTsConfigPath, project.getFileSystem().readFileSync).config : {};
177040
- const include = options.include ?? tsConfig.include ?? parentTsConfig.include ?? "**/*";
177041
- const exclude = options.exclude ?? tsConfig.exclude ?? parentTsConfig.exclude ?? "node_modules/**";
177042
- bundleDebug("read config");
177043
177062
  const includedFileSet = /* @__PURE__ */ new Set();
177044
177063
  if (include && include.length) {
177045
- const files = await glob__default(ensureArray(include).map(normalizeGlob), {
177064
+ const files = await glob(include, {
177046
177065
  cwd: root,
177047
177066
  absolute: true,
177048
- ignore: ensureArray(exclude).map(normalizeGlob)
177067
+ ignore: exclude
177049
177068
  });
177050
177069
  files.forEach((file) => {
177051
177070
  if (dtsRE.test(file)) {
@@ -177076,7 +177095,7 @@ ${logPrefix} Start generate declaration files...`));
177076
177095
  bundleDebug("resolve");
177077
177096
  if (!skipDiagnostics) {
177078
177097
  const diagnostics = project.getPreEmitDiagnostics();
177079
- if (diagnostics?.length && logDiagnostics) {
177098
+ if (diagnostics?.length) {
177080
177099
  logger.warn(project.formatDiagnosticsWithColorAndContext(diagnostics));
177081
177100
  }
177082
177101
  if (typeof afterDiagnostic === "function") {
@@ -177103,7 +177122,7 @@ ${logPrefix} Start generate declaration files...`));
177103
177122
  entryRoot = ensureAbsolute(entryRoot, root);
177104
177123
  const wroteFiles = /* @__PURE__ */ new Set();
177105
177124
  const outputDir = outputDirs[0];
177106
- await runParallel(os__default.cpus().length, outputFiles, async (outputFile) => {
177125
+ await runParallel(os.cpus().length, outputFiles, async (outputFile) => {
177107
177126
  let filePath = outputFile.path;
177108
177127
  let content = outputFile.content;
177109
177128
  const isMapFile = filePath.endsWith(".map");
@@ -177128,8 +177147,8 @@ ${logPrefix} Start generate declaration files...`));
177128
177147
  content = result.content ?? content;
177129
177148
  }
177130
177149
  }
177131
- await fs__default.mkdir(node_path.dirname(filePath), { recursive: true });
177132
- await fs__default.writeFile(
177150
+ await fs.mkdir(node_path.dirname(filePath), { recursive: true });
177151
+ await fs.writeFile(
177133
177152
  filePath,
177134
177153
  cleanVueFileName ? content.replace(/['"](.+)\.vue['"]/g, '"$1"') : content,
177135
177154
  "utf-8"
@@ -177139,59 +177158,87 @@ ${logPrefix} Start generate declaration files...`));
177139
177158
  bundleDebug("output");
177140
177159
  if (insertTypesEntry || rollupTypes) {
177141
177160
  const pkgPath = node_path.resolve(root, "package.json");
177142
- const pkg = fs__default.existsSync(pkgPath) ? JSON.parse(await fs__default.readFile(pkgPath, "utf-8")) : {};
177161
+ const pkg = fs.existsSync(pkgPath) ? JSON.parse(await fs.readFile(pkgPath, "utf-8")) : {};
177162
+ const entryNames = Object.keys(entries);
177143
177163
  const types = pkg.types || pkg.typings;
177144
- let typesPath = types ? node_path.resolve(root, types) : node_path.resolve(outputDir, indexName);
177145
- if (!fs__default.existsSync(typesPath)) {
177146
- const entry = entries[0];
177147
- const outputIndex = node_path.resolve(outputDir, node_path.relative(entryRoot, entry.replace(tsRE, ".d.ts")));
177148
- let filePath = vite.normalizePath(node_path.relative(node_path.dirname(typesPath), outputIndex));
177149
- filePath = filePath.replace(dtsRE, "");
177150
- filePath = fullRelativeRE.test(filePath) ? filePath : `./${filePath}`;
177151
- let content = `export * from '${filePath}'
177164
+ const multiple = entryNames.length > 1;
177165
+ const typesPath = types ? node_path.resolve(root, types) : node_path.resolve(outputDir, indexName);
177166
+ for (const name of entryNames) {
177167
+ let filePath = multiple ? node_path.resolve(outputDir, name.replace(tsRE, ".d.ts")) : typesPath;
177168
+ if (fs.existsSync(filePath))
177169
+ continue;
177170
+ const index = node_path.resolve(
177171
+ outputDir,
177172
+ node_path.relative(entryRoot, entries[name].replace(tsRE, ".d.ts"))
177173
+ );
177174
+ let fromPath = vite.normalizePath(node_path.relative(node_path.dirname(filePath), index));
177175
+ fromPath = fromPath.replace(dtsRE, "");
177176
+ fromPath = fullRelativeRE.test(fromPath) ? fromPath : `./${fromPath}`;
177177
+ let content = `export * from '${fromPath}'
177152
177178
  `;
177153
- if (fs__default.existsSync(outputIndex)) {
177154
- const entryCodes = await fs__default.readFile(outputIndex, "utf-8");
177179
+ if (fs.existsSync(index)) {
177180
+ const entryCodes = await fs.readFile(index, "utf-8");
177155
177181
  if (entryCodes.includes("export default")) {
177156
- content += `import ${libName} from '${filePath}'
177182
+ content += `import ${libName} from '${fromPath}'
177157
177183
  export default ${libName}
177158
177184
  `;
177159
177185
  }
177160
177186
  }
177161
177187
  let result;
177162
177188
  if (typeof beforeWriteFile === "function") {
177163
- result = beforeWriteFile(typesPath, content);
177189
+ result = beforeWriteFile(filePath, content);
177164
177190
  if (result && isNativeObj(result)) {
177165
- typesPath = result.filePath ?? typesPath;
177191
+ filePath = result.filePath ?? filePath;
177166
177192
  content = result.content ?? content;
177167
177193
  }
177168
177194
  }
177169
177195
  if (result !== false) {
177170
- await fs__default.writeFile(typesPath, content, "utf-8");
177171
- wroteFiles.add(vite.normalizePath(typesPath));
177196
+ await fs.writeFile(filePath, content, "utf-8");
177197
+ wroteFiles.add(vite.normalizePath(filePath));
177172
177198
  }
177173
177199
  }
177174
177200
  bundleDebug("insert index");
177175
177201
  if (rollupTypes) {
177176
177202
  logger.info(kolorist.green(`${logPrefix} Start rollup declaration files...`));
177177
- rollupDeclarationFiles({
177178
- root,
177179
- tsConfigPath,
177180
- compilerOptions,
177181
- outputDir,
177182
- entryPath: typesPath,
177183
- fileName: node_path.basename(typesPath)
177184
- });
177185
- const wroteFile = vite.normalizePath(typesPath);
177186
- wroteFiles.delete(wroteFile);
177187
- await runParallel(os__default.cpus().length, Array.from(wroteFiles), (f) => fs__default.unlink(f));
177203
+ const rollupFiles = /* @__PURE__ */ new Set();
177204
+ if (multiple) {
177205
+ for (const name of entryNames) {
177206
+ const path = node_path.resolve(outputDir, name.replace(tsRE, ".d.ts"));
177207
+ rollupDeclarationFiles({
177208
+ root,
177209
+ tsConfigPath,
177210
+ compilerOptions,
177211
+ outputDir,
177212
+ entryPath: path,
177213
+ fileName: node_path.basename(path)
177214
+ });
177215
+ const wroteFile = vite.normalizePath(path);
177216
+ wroteFiles.delete(wroteFile);
177217
+ rollupFiles.add(wroteFile);
177218
+ }
177219
+ } else {
177220
+ rollupDeclarationFiles({
177221
+ root,
177222
+ tsConfigPath,
177223
+ compilerOptions,
177224
+ outputDir,
177225
+ entryPath: typesPath,
177226
+ fileName: node_path.basename(typesPath)
177227
+ });
177228
+ const wroteFile = vite.normalizePath(typesPath);
177229
+ wroteFiles.delete(wroteFile);
177230
+ rollupFiles.add(wroteFile);
177231
+ }
177232
+ await runParallel(os.cpus().length, Array.from(wroteFiles), (f) => fs.unlink(f));
177188
177233
  removeDirIfEmpty(outputDir);
177189
177234
  wroteFiles.clear();
177190
- wroteFiles.add(wroteFile);
177235
+ for (const file of rollupFiles) {
177236
+ wroteFiles.add(file);
177237
+ }
177191
177238
  if (copyDtsFiles) {
177192
- await runParallel(os__default.cpus().length, dtsOutputFiles, async ({ path, content }) => {
177239
+ await runParallel(os.cpus().length, dtsOutputFiles, async ({ path, content }) => {
177193
177240
  const filePath = node_path.resolve(outputDir, node_path.basename(path));
177194
- await fs__default.writeFile(filePath, content, "utf-8");
177241
+ await fs.writeFile(filePath, content, "utf-8");
177195
177242
  wroteFiles.add(vite.normalizePath(filePath));
177196
177243
  });
177197
177244
  }
@@ -177200,14 +177247,14 @@ export default ${libName}
177200
177247
  }
177201
177248
  if (outputDirs.length > 1) {
177202
177249
  const dirs = outputDirs.slice(1);
177203
- await runParallel(os__default.cpus().length, Array.from(wroteFiles), async (wroteFile) => {
177250
+ await runParallel(os.cpus().length, Array.from(wroteFiles), async (wroteFile) => {
177204
177251
  const relativePath = node_path.relative(outputDir, wroteFile);
177205
- const content = await fs__default.readFile(wroteFile, "utf-8");
177252
+ const content = await fs.readFile(wroteFile, "utf-8");
177206
177253
  await Promise.all(
177207
177254
  dirs.map(async (dir) => {
177208
177255
  const filePath = node_path.resolve(dir, relativePath);
177209
- await fs__default.mkdir(node_path.dirname(filePath), { recursive: true });
177210
- await fs__default.writeFile(filePath, content, "utf-8");
177256
+ await fs.mkdir(node_path.dirname(filePath), { recursive: true });
177257
+ await fs.writeFile(filePath, content, "utf-8");
177211
177258
  })
177212
177259
  );
177213
177260
  });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin } from 'vite';
1
+ import * as vite from 'vite';
2
2
  import { ts, Diagnostic } from 'ts-morph';
3
3
 
4
4
  interface TransformWriteFile {
@@ -6,27 +6,169 @@ interface TransformWriteFile {
6
6
  content?: string;
7
7
  }
8
8
  interface PluginOptions {
9
- include?: string | string[];
10
- exclude?: string | string[];
9
+ /**
10
+ * Depends on the root directory
11
+ *
12
+ * Defaults base on your vite config root options
13
+ */
11
14
  root?: string;
15
+ /**
16
+ * Declaration files output directory
17
+ *
18
+ * Can be specified a array to output to multiple directories
19
+ *
20
+ * Defaults base on your vite config output options
21
+ */
12
22
  outputDir?: string | string[];
23
+ /**
24
+ * Manually set the root path of the entry files
25
+ *
26
+ * The output path of each file will be caculated base on it
27
+ *
28
+ * Defaults is the smallest public path for all files
29
+ */
13
30
  entryRoot?: string;
31
+ /**
32
+ * Project init compilerOptions using by ts-morph
33
+ *
34
+ * @default null
35
+ */
14
36
  compilerOptions?: ts.CompilerOptions | null;
37
+ /**
38
+ * Project init tsconfig.json file path by ts-morph
39
+ *
40
+ * Plugin also resolve incldue and exclude files from tsconfig.json
41
+ *
42
+ * @default 'tsconfig.json'
43
+ */
15
44
  tsConfigFilePath?: string;
45
+ /**
46
+ * Set which paths should exclude when transform aliases
47
+ *
48
+ * If it's regexp, it will test the original import path directly
49
+ *
50
+ * @default []
51
+ */
16
52
  aliasesExclude?: (string | RegExp)[];
53
+ /**
54
+ * Whether transform file name '.vue.d.ts' to '.d.ts'
55
+ *
56
+ * @default false
57
+ */
17
58
  cleanVueFileName?: boolean;
59
+ /**
60
+ * Whether transform dynamic import to static
61
+ *
62
+ * Force true when `rollupTypes` is effective
63
+ *
64
+ * eg. 'import('vue').DefineComponent' to 'import { DefineComponent } from "vue"'
65
+ *
66
+ * @default false
67
+ */
18
68
  staticImport?: boolean;
69
+ /**
70
+ * Manual set include glob
71
+ *
72
+ * Defaults base on your tsconfig.json include option
73
+ */
74
+ include?: string | string[];
75
+ /**
76
+ * Manual set exclude glob
77
+ *
78
+ * Defaults base on your tsconfig.json exclude option, be 'node_module/**' when empty
79
+ */
80
+ exclude?: string | string[];
81
+ /**
82
+ * Do not emit if content of file only includes 'export {}'
83
+ *
84
+ * @default true
85
+ */
19
86
  clearPureImport?: boolean;
87
+ /**
88
+ * Whether generate types entry file
89
+ *
90
+ * When true will from package.json types field if exists or `${outputDir}/index.d.ts`
91
+ *
92
+ * Force true when `rollupTypes` is effective
93
+ *
94
+ * @default false
95
+ */
20
96
  insertTypesEntry?: boolean;
97
+ /**
98
+ * Set to rollup declaration files after emit
99
+ *
100
+ * Power by `@microsoft/api-extractor`, it will start a new program which takes some time
101
+ *
102
+ * @default false
103
+ */
21
104
  rollupTypes?: boolean;
105
+ /**
106
+ * Whether copy .d.ts source files into outputDir
107
+ *
108
+ * @default true
109
+ */
22
110
  copyDtsFiles?: boolean;
111
+ /**
112
+ * Whether emit nothing when has any diagnostic
113
+ *
114
+ * @default false
115
+ */
23
116
  noEmitOnError?: boolean;
117
+ /**
118
+ * Whether skip typescript diagnostics
119
+ *
120
+ * Skip type diagnostics means that type errors will not interrupt the build process
121
+ *
122
+ * But for the source files with type errors will not be emitted
123
+ *
124
+ * @default false
125
+ */
24
126
  skipDiagnostics?: boolean;
127
+ /**
128
+ * Whether log diagnostic informations
129
+ *
130
+ * Not effective when `skipDiagnostics` is true
131
+ *
132
+ * @deprecated
133
+ * @default false
134
+ */
25
135
  logDiagnostics?: boolean;
136
+ /**
137
+ * Customize typescript lib folder path
138
+ *
139
+ * Should pass a relative path to root or a absolute path
140
+ *
141
+ * @default undefined
142
+ */
143
+ libFolderPath?: string;
144
+ /**
145
+ * After emit diagnostic hook
146
+ *
147
+ * According to the length to judge whether there is any type error
148
+ *
149
+ * @default () => {}
150
+ */
26
151
  afterDiagnostic?: (diagnostics: Diagnostic[]) => void | Promise<void>;
152
+ /**
153
+ * Before declaration file be writed hook
154
+ *
155
+ * You can transform declaration file-path and content through it
156
+ *
157
+ * The file will be skipped when return exact false
158
+ *
159
+ * @default () => {}
160
+ */
27
161
  beforeWriteFile?: (filePath: string, content: string) => void | false | TransformWriteFile;
162
+ /**
163
+ * After build hook
164
+ *
165
+ * It wil be called after all declaration files are written
166
+ *
167
+ * @default () => {}
168
+ */
28
169
  afterBuild?: () => void | Promise<void>;
29
- }
30
- declare function dtsPlugin(options?: PluginOptions): Plugin;
170
+ }
171
+
172
+ declare function dtsPlugin(options?: PluginOptions): vite.Plugin;
31
173
 
32
- export { dtsPlugin as default };
174
+ export { PluginOptions, dtsPlugin as default };