rolldown-plugin-dts 0.7.5 → 0.7.7
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 +8 -10
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MagicStringAST } from "magic-string-ast";
|
|
2
2
|
import { parseSync } from "oxc-parser";
|
|
3
|
-
import path from "node:path";
|
|
4
3
|
import { createResolver } from "dts-resolver";
|
|
5
4
|
import { getTsconfig, parseTsconfig } from "get-tsconfig";
|
|
6
5
|
import { isolatedDeclaration } from "oxc-transform";
|
|
@@ -173,7 +172,7 @@ function getIdentifierRange(node, offset = 0) {
|
|
|
173
172
|
const RE_JS = /\.([cm]?)jsx?$/;
|
|
174
173
|
const RE_TS = /\.([cm]?)tsx?$/;
|
|
175
174
|
const RE_DTS = /\.d\.([cm]?)ts$/;
|
|
176
|
-
const RE_NODE_MODULES = /node_modules/;
|
|
175
|
+
const RE_NODE_MODULES = /[\\/]node_modules[\\/]/;
|
|
177
176
|
function filename_js_to_dts(id) {
|
|
178
177
|
return id.replace(RE_JS, ".d.$1ts");
|
|
179
178
|
}
|
|
@@ -183,9 +182,6 @@ function filename_ts_to_dts(id) {
|
|
|
183
182
|
function filename_dts_to(id, ext) {
|
|
184
183
|
return id.replace(RE_DTS, `.$1${ext}`);
|
|
185
184
|
}
|
|
186
|
-
function isRelative(id) {
|
|
187
|
-
return path.isAbsolute(id) || id[0] === ".";
|
|
188
|
-
}
|
|
189
185
|
|
|
190
186
|
//#endregion
|
|
191
187
|
//#region src/utils/magic-string.ts
|
|
@@ -566,7 +562,8 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
|
|
|
566
562
|
const dtsMap = new Map();
|
|
567
563
|
function resolveOptions(cwd) {
|
|
568
564
|
if (tsconfig === true || tsconfig == null) {
|
|
569
|
-
const { config } = getTsconfig(cwd) || {};
|
|
565
|
+
const { config, path } = getTsconfig(cwd) || {};
|
|
566
|
+
tsconfig = path;
|
|
570
567
|
compilerOptions = {
|
|
571
568
|
...config?.compilerOptions,
|
|
572
569
|
...compilerOptions
|
|
@@ -592,12 +589,13 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
|
|
|
592
589
|
* ])
|
|
593
590
|
*/
|
|
594
591
|
const inputAliasMap = new Map();
|
|
595
|
-
|
|
592
|
+
let resolver;
|
|
596
593
|
let programs = [];
|
|
597
594
|
return {
|
|
598
595
|
name: "rolldown-plugin-dts:generate",
|
|
599
596
|
async buildStart(options) {
|
|
600
597
|
resolveOptions(options.cwd);
|
|
598
|
+
resolver = createResolver({ tsconfig: tsconfig ? tsconfig : void 0 });
|
|
601
599
|
if (!isolatedDeclaration$1) initTs();
|
|
602
600
|
if (!Array.isArray(options.input)) for (const [name, id] of Object.entries(options.input)) {
|
|
603
601
|
let resolved = await this.resolve(id, void 0, { skipSelf: true });
|
|
@@ -672,7 +670,9 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
|
|
|
672
670
|
meta
|
|
673
671
|
};
|
|
674
672
|
}
|
|
675
|
-
|
|
673
|
+
let resolution = await this.resolve(id, filename_dts_to(importer, "ts"));
|
|
674
|
+
if (!resolution || resolution.external) return resolution;
|
|
675
|
+
if (RE_NODE_MODULES.test(resolution.id)) {
|
|
676
676
|
let shouldResolve;
|
|
677
677
|
if (typeof resolve === "boolean") shouldResolve = resolve;
|
|
678
678
|
else shouldResolve = resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
|
|
@@ -688,8 +688,6 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
|
|
|
688
688
|
meta
|
|
689
689
|
};
|
|
690
690
|
}
|
|
691
|
-
let resolution = await this.resolve(id, filename_dts_to(importer, "ts"));
|
|
692
|
-
if (!resolution || resolution.external) return;
|
|
693
691
|
let dtsId;
|
|
694
692
|
if (RE_JS.test(resolution.id)) {
|
|
695
693
|
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.
|
|
3
|
+
"version": "0.7.7",
|
|
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.
|
|
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",
|