rolldown-plugin-dts 0.7.9 → 0.7.11
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.js +45 -40
- package/package.json +1 -1
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,58 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
|
|
|
647
649
|
if (emitDtsOnly) return "export { }";
|
|
648
650
|
}
|
|
649
651
|
},
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
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
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
else shouldResolve = resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
|
|
670
|
-
if (shouldResolve) {
|
|
671
|
-
const resolution$1 = resolver(id, importer);
|
|
672
|
-
if (resolution$1) return {
|
|
673
|
-
id: resolution$1,
|
|
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,
|
|
674
665
|
meta
|
|
675
666
|
};
|
|
676
|
-
}
|
|
677
|
-
|
|
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 });
|
|
667
|
+
}
|
|
668
|
+
let resolution = await this.resolve(id, filename_dts_to(importer, "ts"));
|
|
685
669
|
if (!resolution) return;
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
670
|
+
if (RE_NODE_MODULES.test(resolution.id) || !isRelative(resolution.id)) {
|
|
671
|
+
let shouldResolve;
|
|
672
|
+
if (typeof resolve === "boolean") shouldResolve = resolve;
|
|
673
|
+
else shouldResolve = resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
|
|
674
|
+
if (shouldResolve) {
|
|
675
|
+
const resolution$1 = resolver(id, importer);
|
|
676
|
+
if (resolution$1) return {
|
|
677
|
+
id: resolution$1,
|
|
678
|
+
meta
|
|
679
|
+
};
|
|
680
|
+
} else return {
|
|
681
|
+
id,
|
|
682
|
+
external: true,
|
|
683
|
+
meta
|
|
684
|
+
};
|
|
685
|
+
} else if (resolution.external) return resolution;
|
|
686
|
+
let dtsId;
|
|
687
|
+
if (RE_JS.test(resolution.id)) {
|
|
688
|
+
resolution = await this.resolve(filename_js_to_dts(resolution.id), importer, { skipSelf: false });
|
|
689
|
+
if (!resolution) return;
|
|
690
|
+
dtsId = resolution.id;
|
|
691
|
+
} else {
|
|
692
|
+
dtsId = filename_ts_to_dts(resolution.id);
|
|
693
|
+
if (dtsMap.has(dtsId)) return {
|
|
694
|
+
id: dtsId,
|
|
695
|
+
meta
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
await this.load(resolution);
|
|
699
|
+
if (RE_DTS.test(resolution.id) || dtsMap.has(dtsId)) return {
|
|
690
700
|
id: dtsId,
|
|
691
701
|
meta
|
|
692
702
|
};
|
|
693
703
|
}
|
|
694
|
-
await this.load(resolution);
|
|
695
|
-
if (RE_DTS.test(resolution.id) || dtsMap.has(dtsId)) return {
|
|
696
|
-
id: dtsId,
|
|
697
|
-
meta
|
|
698
|
-
};
|
|
699
704
|
},
|
|
700
705
|
load: {
|
|
701
706
|
filter: { id: {
|