rolldown-plugin-dts 0.7.2 → 0.7.3
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 +37 -23
- 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]?)
|
|
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/;
|
|
@@ -646,41 +646,55 @@ function createGeneratePlugin({ compilerOptions, isolatedDeclaration: isolatedDe
|
|
|
646
646
|
}
|
|
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
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
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
|
-
|
|
672
|
-
|
|
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
|
-
|
|
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: {
|