rolldown-plugin-dts 0.7.10 → 0.7.12

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 +50 -38
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -523,11 +523,13 @@ function createTsProgram(compilerOptions, dtsMap, id) {
523
523
  host.fileExists = (fileName) => {
524
524
  const module = getTsModule(dtsMap, fileName);
525
525
  if (module) return true;
526
+ if (debug.enabled && !RE_NODE_MODULES.test(fileName)) debug(`file exists from fs: ${fileName}`);
526
527
  return _fileExists(fileName);
527
528
  };
528
529
  host.readFile = (fileName) => {
529
530
  const module = getTsModule(dtsMap, fileName);
530
531
  if (module) return module.code;
532
+ if (debug.enabled && !RE_NODE_MODULES.test(fileName)) debug(`read file from fs: ${fileName}`);
531
533
  return _readFile(fileName);
532
534
  };
533
535
  const entries = Array.from(dtsMap.values()).filter((v) => v.isEntry).map((v) => v.id);
@@ -647,55 +649,65 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
647
649
  if (emitDtsOnly) return "export { }";
648
650
  }
649
651
  },
650
- async resolveId(id, importer, options) {
651
- if (dtsMap.has(id)) return {
652
- id,
653
- meta
654
- };
655
- if (!importer || !this.getModuleInfo(importer)?.meta.dtsFile) return;
656
- if (RE_DTS.test(id)) {
657
- const resolution$1 = await this.resolve(id, importer, options);
658
- if (!resolution$1) return;
659
- return {
660
- ...resolution$1,
652
+ resolveId: {
653
+ order: "pre",
654
+ async handler(id, importer, options) {
655
+ if (dtsMap.has(id)) return {
656
+ id,
661
657
  meta
662
658
  };
663
- }
664
- let resolution = await this.resolve(id, filename_dts_to(importer, "ts"));
665
- if (!resolution) return;
666
- if (RE_NODE_MODULES.test(resolution.id) || !isRelative(resolution.id)) {
667
- let shouldResolve;
668
- if (typeof resolve === "boolean") shouldResolve = resolve;
669
- else shouldResolve = resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
670
- if (shouldResolve) {
659
+ if (!importer || !this.getModuleInfo(importer)?.meta.dtsFile) return;
660
+ if (RE_DTS.test(id)) {
661
+ const resolution$1 = await this.resolve(id, importer, options);
662
+ if (!resolution$1) return;
663
+ return {
664
+ ...resolution$1,
665
+ meta
666
+ };
667
+ }
668
+ if (RE_NODE_MODULES.test(importer)) {
671
669
  const resolution$1 = resolver(id, importer);
672
670
  if (resolution$1) return {
673
671
  id: resolution$1,
674
672
  meta
675
673
  };
676
- } else return {
677
- id,
678
- external: true,
679
- meta
680
- };
681
- } else if (resolution.external) return resolution;
682
- let dtsId;
683
- if (RE_JS.test(resolution.id)) {
684
- resolution = await this.resolve(filename_js_to_dts(resolution.id), importer, { skipSelf: false });
685
- if (!resolution) return;
686
- dtsId = resolution.id;
687
- } else {
688
- dtsId = filename_ts_to_dts(resolution.id);
689
- if (dtsMap.has(dtsId)) return {
674
+ }
675
+ let resolution = await this.resolve(id, filename_dts_to(importer, "ts"));
676
+ if (RE_NODE_MODULES.test(resolution?.id || id) || !isRelative(resolution?.id || id)) {
677
+ let shouldResolve;
678
+ if (typeof resolve === "boolean") shouldResolve = resolve;
679
+ else shouldResolve = resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
680
+ if (shouldResolve) {
681
+ const resolution$1 = resolver(id, importer);
682
+ if (resolution$1) return {
683
+ id: resolution$1,
684
+ meta
685
+ };
686
+ } else return {
687
+ id,
688
+ external: true,
689
+ meta
690
+ };
691
+ }
692
+ if (!resolution || resolution.external) return resolution;
693
+ let dtsId;
694
+ if (RE_JS.test(resolution.id)) {
695
+ resolution = await this.resolve(filename_js_to_dts(resolution.id), importer, { skipSelf: false });
696
+ if (!resolution) return;
697
+ dtsId = resolution.id;
698
+ } else {
699
+ dtsId = filename_ts_to_dts(resolution.id);
700
+ if (dtsMap.has(dtsId)) return {
701
+ id: dtsId,
702
+ meta
703
+ };
704
+ }
705
+ await this.load(resolution);
706
+ if (RE_DTS.test(resolution.id) || dtsMap.has(dtsId)) return {
690
707
  id: dtsId,
691
708
  meta
692
709
  };
693
710
  }
694
- await this.load(resolution);
695
- if (RE_DTS.test(resolution.id) || dtsMap.has(dtsId)) return {
696
- id: dtsId,
697
- meta
698
- };
699
711
  },
700
712
  load: {
701
713
  filter: { id: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
- "version": "0.7.10",
3
+ "version": "0.7.12",
4
4
  "description": "A Rolldown plugin to bundle dts files",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -53,12 +53,12 @@
53
53
  "@types/node": "^22.14.1",
54
54
  "bumpp": "^10.1.0",
55
55
  "diff": "^7.0.0",
56
- "eslint": "^9.24.0",
56
+ "eslint": "^9.25.0",
57
57
  "estree-walker": "^3.0.3",
58
58
  "prettier": "^3.5.3",
59
59
  "rolldown": "^1.0.0-beta.7",
60
60
  "rollup-plugin-dts": "^6.2.1",
61
- "tsdown": "^0.8.0",
61
+ "tsdown": "^0.8.1",
62
62
  "tsx": "^4.19.3",
63
63
  "typescript": "^5.8.3",
64
64
  "vitest": "^3.1.1"