rolldown-plugin-dts 0.7.5 → 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 -7
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -173,7 +173,7 @@ function getIdentifierRange(node, offset = 0) {
173
173
  const RE_JS = /\.([cm]?)jsx?$/;
174
174
  const RE_TS = /\.([cm]?)tsx?$/;
175
175
  const RE_DTS = /\.d\.([cm]?)ts$/;
176
- const RE_NODE_MODULES = /node_modules/;
176
+ const RE_NODE_MODULES = /[\\/]node_modules[\\/]/;
177
177
  function filename_js_to_dts(id) {
178
178
  return id.replace(RE_JS, ".d.$1ts");
179
179
  }
@@ -566,7 +566,8 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
566
566
  const dtsMap = new Map();
567
567
  function resolveOptions(cwd) {
568
568
  if (tsconfig === true || tsconfig == null) {
569
- const { config } = getTsconfig(cwd) || {};
569
+ const { config, path: path$1 } = getTsconfig(cwd) || {};
570
+ tsconfig = path$1;
570
571
  compilerOptions = {
571
572
  ...config?.compilerOptions,
572
573
  ...compilerOptions
@@ -592,12 +593,13 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
592
593
  * ])
593
594
  */
594
595
  const inputAliasMap = new Map();
595
- const resolver = createResolver();
596
+ let resolver;
596
597
  let programs = [];
597
598
  return {
598
599
  name: "rolldown-plugin-dts:generate",
599
600
  async buildStart(options) {
600
601
  resolveOptions(options.cwd);
602
+ resolver = createResolver({ tsconfig: tsconfig ? tsconfig : void 0 });
601
603
  if (!isolatedDeclaration$1) initTs();
602
604
  if (!Array.isArray(options.input)) for (const [name, id] of Object.entries(options.input)) {
603
605
  let resolved = await this.resolve(id, void 0, { skipSelf: true });
@@ -672,7 +674,9 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
672
674
  meta
673
675
  };
674
676
  }
675
- if (!isRelative(id)) {
677
+ let resolution = await this.resolve(id, filename_dts_to(importer, "ts"));
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,9 +691,7 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
687
691
  external: true,
688
692
  meta
689
693
  };
690
- }
691
- let resolution = await this.resolve(id, filename_dts_to(importer, "ts"));
692
- if (!resolution || resolution.external) return;
694
+ } else if (resolution.external) return resolution;
693
695
  let dtsId;
694
696
  if (RE_JS.test(resolution.id)) {
695
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.5",
3
+ "version": "0.7.8",
4
4
  "description": "A Rolldown plugin to bundle dts files",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "debug": "^4.4.0",
41
- "dts-resolver": "^0.1.1",
41
+ "dts-resolver": "^1.0.0",
42
42
  "get-tsconfig": "^4.10.0",
43
43
  "magic-string-ast": "^0.9.1",
44
44
  "oxc-parser": "^0.64.0",