vite-plugin-dts 3.6.2 → 3.6.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/dist/index.cjs CHANGED
@@ -185,6 +185,27 @@ function findTypesPath(...pkgs) {
185
185
  return path;
186
186
  }
187
187
  }
188
+ function setModuleResolution(options) {
189
+ if (options.moduleResolution)
190
+ return;
191
+ const module = typeof options.module === "number" ? options.module : options.target ?? ts__default.ScriptTarget.ES5 >= 2 ? ts__default.ModuleKind.ES2015 : ts__default.ModuleKind.CommonJS;
192
+ let moduleResolution;
193
+ switch (module) {
194
+ case ts__default.ModuleKind.CommonJS:
195
+ moduleResolution = ts__default.ModuleResolutionKind.Node10;
196
+ break;
197
+ case ts__default.ModuleKind.Node16:
198
+ moduleResolution = ts__default.ModuleResolutionKind.Node16;
199
+ break;
200
+ case ts__default.ModuleKind.NodeNext:
201
+ moduleResolution = ts__default.ModuleResolutionKind.NodeNext;
202
+ break;
203
+ default:
204
+ moduleResolution = ts__default.version.startsWith("5") ? ts__default.ModuleResolutionKind.Bundler : ts__default.ModuleResolutionKind.Classic;
205
+ break;
206
+ }
207
+ options.moduleResolution = moduleResolution;
208
+ }
188
209
 
189
210
  const dtsRE$1 = /\.d\.tsx?$/;
190
211
  function rollupDeclarationFiles({
@@ -609,9 +630,6 @@ ${logPrefix} ${kolorist.yellow(
609
630
  configPath = tsconfigPath ? ensureAbsolute(tsconfigPath, root) : ts__default.findConfigFile(root, ts__default.sys.fileExists);
610
631
  const content = configPath ? languageCore.createParsedCommandLine(ts__default, ts__default.sys, configPath) : void 0;
611
632
  compilerOptions = {
612
- // (#277) If user don't specify `moduleResolution` in top config file,
613
- // declaration of Vue files will be inferred to `any` type.
614
- moduleResolution: ts__default.ModuleResolutionKind.Node10,
615
633
  ...content?.options || {},
616
634
  ...options.compilerOptions || {},
617
635
  ...fixedCompilerOptions,
@@ -619,6 +637,9 @@ ${logPrefix} ${kolorist.yellow(
619
637
  declarationDir: "."
620
638
  };
621
639
  rawCompilerOptions = content?.raw.compilerOptions || {};
640
+ if (content?.fileNames.find((name) => name.endsWith(".vue"))) {
641
+ setModuleResolution(compilerOptions);
642
+ }
622
643
  if (!outDirs) {
623
644
  outDirs = options.outDir ? ensureArray(options.outDir).map((d) => ensureAbsolute(d, root)) : [ensureAbsolute(content?.raw.compilerOptions?.outDir || "dist", root)];
624
645
  }
package/dist/index.mjs CHANGED
@@ -185,6 +185,27 @@ function findTypesPath(...pkgs) {
185
185
  return path;
186
186
  }
187
187
  }
188
+ function setModuleResolution(options) {
189
+ if (options.moduleResolution)
190
+ return;
191
+ const module = typeof options.module === "number" ? options.module : options.target ?? ts.ScriptTarget.ES5 >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS;
192
+ let moduleResolution;
193
+ switch (module) {
194
+ case ts.ModuleKind.CommonJS:
195
+ moduleResolution = ts.ModuleResolutionKind.Node10;
196
+ break;
197
+ case ts.ModuleKind.Node16:
198
+ moduleResolution = ts.ModuleResolutionKind.Node16;
199
+ break;
200
+ case ts.ModuleKind.NodeNext:
201
+ moduleResolution = ts.ModuleResolutionKind.NodeNext;
202
+ break;
203
+ default:
204
+ moduleResolution = ts.version.startsWith("5") ? ts.ModuleResolutionKind.Bundler : ts.ModuleResolutionKind.Classic;
205
+ break;
206
+ }
207
+ options.moduleResolution = moduleResolution;
208
+ }
188
209
 
189
210
  const dtsRE$1 = /\.d\.tsx?$/;
190
211
  function rollupDeclarationFiles({
@@ -609,9 +630,6 @@ ${logPrefix} ${yellow(
609
630
  configPath = tsconfigPath ? ensureAbsolute(tsconfigPath, root) : ts.findConfigFile(root, ts.sys.fileExists);
610
631
  const content = configPath ? createParsedCommandLine(ts, ts.sys, configPath) : void 0;
611
632
  compilerOptions = {
612
- // (#277) If user don't specify `moduleResolution` in top config file,
613
- // declaration of Vue files will be inferred to `any` type.
614
- moduleResolution: ts.ModuleResolutionKind.Node10,
615
633
  ...content?.options || {},
616
634
  ...options.compilerOptions || {},
617
635
  ...fixedCompilerOptions,
@@ -619,6 +637,9 @@ ${logPrefix} ${yellow(
619
637
  declarationDir: "."
620
638
  };
621
639
  rawCompilerOptions = content?.raw.compilerOptions || {};
640
+ if (content?.fileNames.find((name) => name.endsWith(".vue"))) {
641
+ setModuleResolution(compilerOptions);
642
+ }
622
643
  if (!outDirs) {
623
644
  outDirs = options.outDir ? ensureArray(options.outDir).map((d) => ensureAbsolute(d, root)) : [ensureAbsolute(content?.raw.compilerOptions?.outDir || "dist", root)];
624
645
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-dts",
3
- "version": "3.6.2",
3
+ "version": "3.6.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "qmhc",