rolldown-plugin-dts 0.7.2 → 0.7.4

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 +38 -24
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -170,7 +170,7 @@ function getIdentifierRange(node, offset = 0) {
170
170
 
171
171
  //#endregion
172
172
  //#region src/utils/filename.ts
173
- const RE_JS = /\.([cm]?)js$/;
173
+ const RE_JS = /\.([cm]?)jsx?$/;
174
174
  const RE_TS = /\.([cm]?)tsx?$/;
175
175
  const RE_DTS = /\.d\.([cm]?)ts$/;
176
176
  const RE_NODE_MODULES = /node_modules/;
@@ -642,45 +642,59 @@ function createGeneratePlugin({ compilerOptions, isolatedDeclaration: isolatedDe
642
642
  id: dtsId,
643
643
  name: name ? `${name}.d` : void 0
644
644
  });
645
- if (emitDtsOnly) return "//";
646
645
  }
646
+ if (emitDtsOnly) return "export { }";
647
647
  }
648
648
  },
649
- async resolveId(id, importer) {
649
+ async resolveId(id, importer, options) {
650
650
  if (dtsMap.has(id)) return {
651
651
  id,
652
652
  meta
653
653
  };
654
- if (importer && this.getModuleInfo(importer)?.meta.dtsFile) {
655
- if (!isRelative(id)) {
656
- let shouldResolve;
657
- if (typeof resolve === "boolean") shouldResolve = resolve;
658
- else shouldResolve = resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
659
- if (shouldResolve) {
660
- const resolution$1 = resolver(id, importer);
661
- if (resolution$1) return {
662
- id: resolution$1,
663
- meta
664
- };
665
- } else return {
666
- id,
667
- external: true,
654
+ if (!importer || !this.getModuleInfo(importer)?.meta.dtsFile) return;
655
+ if (RE_DTS.test(id)) {
656
+ const resolution$1 = await this.resolve(id, importer, options);
657
+ if (!resolution$1) return;
658
+ return {
659
+ ...resolution$1,
660
+ meta
661
+ };
662
+ }
663
+ if (!isRelative(id)) {
664
+ let shouldResolve;
665
+ if (typeof resolve === "boolean") shouldResolve = resolve;
666
+ else shouldResolve = resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
667
+ if (shouldResolve) {
668
+ const resolution$1 = resolver(id, importer);
669
+ if (resolution$1) return {
670
+ id: resolution$1,
668
671
  meta
669
672
  };
670
- }
671
- const resolution = await this.resolve(id, filename_dts_to(importer, "ts"));
672
- if (!resolution || resolution.external) return;
673
- const dtsId = filename_ts_to_dts(resolution.id);
674
- if (dtsMap.has(dtsId)) return {
675
- id: dtsId,
673
+ } else return {
674
+ id,
675
+ external: true,
676
676
  meta
677
677
  };
678
- await this.load(resolution);
678
+ }
679
+ let resolution = await this.resolve(id, filename_dts_to(importer, "ts"));
680
+ if (!resolution || resolution.external) return;
681
+ let dtsId;
682
+ if (RE_JS.test(resolution.id)) {
683
+ resolution = await this.resolve(filename_js_to_dts(resolution.id), importer, { skipSelf: false });
684
+ if (!resolution) return;
685
+ dtsId = resolution.id;
686
+ } else {
687
+ dtsId = filename_ts_to_dts(resolution.id);
679
688
  if (dtsMap.has(dtsId)) return {
680
689
  id: dtsId,
681
690
  meta
682
691
  };
683
692
  }
693
+ await this.load(resolution);
694
+ if (RE_DTS.test(resolution.id) || dtsMap.has(dtsId)) return {
695
+ id: dtsId,
696
+ meta
697
+ };
684
698
  },
685
699
  load: {
686
700
  filter: { id: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "A Rolldown plugin to bundle dts files",
5
5
  "type": "module",
6
6
  "license": "MIT",