rolldown-plugin-dts 0.7.7 → 0.7.8

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.
Files changed (2) hide show
  1. package/dist/index.js +9 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { MagicStringAST } from "magic-string-ast";
2
2
  import { parseSync } from "oxc-parser";
3
+ import path from "node:path";
3
4
  import { createResolver } from "dts-resolver";
4
5
  import { getTsconfig, parseTsconfig } from "get-tsconfig";
5
6
  import { isolatedDeclaration } from "oxc-transform";
@@ -182,6 +183,9 @@ function filename_ts_to_dts(id) {
182
183
  function filename_dts_to(id, ext) {
183
184
  return id.replace(RE_DTS, `.$1${ext}`);
184
185
  }
186
+ function isRelative(id) {
187
+ return path.isAbsolute(id) || id[0] === ".";
188
+ }
185
189
 
186
190
  //#endregion
187
191
  //#region src/utils/magic-string.ts
@@ -562,8 +566,8 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
562
566
  const dtsMap = new Map();
563
567
  function resolveOptions(cwd) {
564
568
  if (tsconfig === true || tsconfig == null) {
565
- const { config, path } = getTsconfig(cwd) || {};
566
- tsconfig = path;
569
+ const { config, path: path$1 } = getTsconfig(cwd) || {};
570
+ tsconfig = path$1;
567
571
  compilerOptions = {
568
572
  ...config?.compilerOptions,
569
573
  ...compilerOptions
@@ -671,8 +675,8 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
671
675
  };
672
676
  }
673
677
  let resolution = await this.resolve(id, filename_dts_to(importer, "ts"));
674
- if (!resolution || resolution.external) return resolution;
675
- if (RE_NODE_MODULES.test(resolution.id)) {
678
+ if (!resolution) return;
679
+ if (RE_NODE_MODULES.test(resolution.id) || !isRelative(resolution.id)) {
676
680
  let shouldResolve;
677
681
  if (typeof resolve === "boolean") shouldResolve = resolve;
678
682
  else shouldResolve = resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
@@ -687,7 +691,7 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
687
691
  external: true,
688
692
  meta
689
693
  };
690
- }
694
+ } else if (resolution.external) return resolution;
691
695
  let dtsId;
692
696
  if (RE_JS.test(resolution.id)) {
693
697
  resolution = await this.resolve(filename_js_to_dts(resolution.id), importer, { skipSelf: false });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
- "version": "0.7.7",
3
+ "version": "0.7.8",
4
4
  "description": "A Rolldown plugin to bundle dts files",
5
5
  "type": "module",
6
6
  "license": "MIT",