rsbuild-plugin-dts 0.6.5 → 0.6.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/utils.d.ts +1 -1
- package/dist/utils.js +27 -10
- package/package.json +5 -5
package/dist/utils.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare function redirectDtsImports(dtsFile: string, dtsExtension: string
|
|
|
19
19
|
export declare function processDtsFiles(bundle: boolean, dir: string, dtsExtension: string, redirect: DtsRedirect, tsconfigPath: string, rootDir: string, banner?: string, footer?: string): Promise<void>;
|
|
20
20
|
export declare function processSourceEntry(bundle: boolean, entryConfig: NonNullable<RsbuildConfig['source']>['entry']): DtsEntry[];
|
|
21
21
|
export declare function calcLongestCommonPath(absPaths: string[]): Promise<string | null>;
|
|
22
|
-
export declare const globDtsFiles: (dir: string) => Promise<string[]>;
|
|
22
|
+
export declare const globDtsFiles: (dir: string, patterns: string[]) => Promise<string[]>;
|
|
23
23
|
export declare function cleanDtsFiles(dir: string): Promise<void>;
|
|
24
24
|
export declare function cleanTsBuildInfoFile(tsconfigPath: string, compilerOptions: ts.CompilerOptions): Promise<void>;
|
|
25
25
|
export declare function getDtsEmitPath(pathFromPlugin: string | undefined, declarationDir: string | undefined, distPath: string): string;
|
package/dist/utils.js
CHANGED
|
@@ -103,7 +103,8 @@ async function addBannerAndFooter(dtsFile, banner, footer) {
|
|
|
103
103
|
async function addExtension(redirect, dtsFile, path, extension) {
|
|
104
104
|
if (!redirect.extension) return path;
|
|
105
105
|
let redirectPath = path;
|
|
106
|
-
if (
|
|
106
|
+
if (!(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(redirectPath) && !redirectPath.startsWith('.')) return redirectPath;
|
|
107
|
+
if (await isDirectory((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(dtsFile), redirectPath))) redirectPath = `${redirectPath.replace(/\/+$/, '')}/index`;
|
|
107
108
|
return `${redirectPath}${extension}`;
|
|
108
109
|
}
|
|
109
110
|
async function redirectDtsImports(dtsFile, dtsExtension, redirect, matchPath, outDir, rootDir) {
|
|
@@ -123,6 +124,19 @@ async function redirectDtsImports(dtsFile, dtsExtension, redirect, matchPath, ou
|
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
},
|
|
127
|
+
{
|
|
128
|
+
kind: 'import_statement',
|
|
129
|
+
has: {
|
|
130
|
+
kind: 'import_require_clause',
|
|
131
|
+
has: {
|
|
132
|
+
field: 'source',
|
|
133
|
+
has: {
|
|
134
|
+
pattern: '$IMP',
|
|
135
|
+
kind: 'string_fragment'
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
126
140
|
{
|
|
127
141
|
kind: 'export_statement',
|
|
128
142
|
has: {
|
|
@@ -179,7 +193,8 @@ async function redirectDtsImports(dtsFile, dtsExtension, redirect, matchPath, ou
|
|
|
179
193
|
]);
|
|
180
194
|
let redirectImportPath = importPath;
|
|
181
195
|
if (absoluteImportPath && redirect.path) {
|
|
182
|
-
const
|
|
196
|
+
const relativeRootDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.normalize)(rootDir), (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.normalize)(absoluteImportPath));
|
|
197
|
+
const isOutsideRootdir = relativeRootDir.startsWith('..') || __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(relativeRootDir);
|
|
183
198
|
if (isOutsideRootdir) {
|
|
184
199
|
const relativePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.relative)((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(dtsFile), absoluteImportPath);
|
|
185
200
|
redirectImportPath = relativePath.startsWith('..') ? relativePath : `./${relativePath}`;
|
|
@@ -216,7 +231,9 @@ async function processDtsFiles(bundle, dir, dtsExtension, redirect, tsconfigPath
|
|
|
216
231
|
const { absoluteBaseUrl, paths, mainFields, addMatchAll } = result;
|
|
217
232
|
matchPath = (0, __WEBPACK_EXTERNAL_MODULE_tsconfig_paths_df62e9eb__.createMatchPath)(absoluteBaseUrl, paths, mainFields, addMatchAll);
|
|
218
233
|
}
|
|
219
|
-
const dtsFiles = await globDtsFiles(dir
|
|
234
|
+
const dtsFiles = await globDtsFiles(dir, [
|
|
235
|
+
`/**/*${dtsExtension}`
|
|
236
|
+
]);
|
|
220
237
|
await Promise.all(dtsFiles.map(async (file)=>{
|
|
221
238
|
try {
|
|
222
239
|
if (banner || footer) await addBannerAndFooter(file, banner, footer);
|
|
@@ -255,19 +272,19 @@ async function calcLongestCommonPath(absPaths) {
|
|
|
255
272
|
if (stats?.isFile()) lca = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(lca);
|
|
256
273
|
return lca;
|
|
257
274
|
}
|
|
258
|
-
const globDtsFiles = async (dir)=>{
|
|
259
|
-
const patterns = [
|
|
260
|
-
'/**/*.d.ts',
|
|
261
|
-
'/**/*.d.cts',
|
|
262
|
-
'/**/*.d.mts'
|
|
263
|
-
];
|
|
275
|
+
const globDtsFiles = async (dir, patterns)=>{
|
|
264
276
|
const dtsFiles = await Promise.all(patterns.map((pattern)=>(0, __WEBPACK_EXTERNAL_MODULE_tinyglobby__.glob)(convertPath((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(dir, pattern)), {
|
|
265
277
|
absolute: true
|
|
266
278
|
})));
|
|
267
279
|
return dtsFiles.flat();
|
|
268
280
|
};
|
|
269
281
|
async function cleanDtsFiles(dir) {
|
|
270
|
-
const
|
|
282
|
+
const patterns = [
|
|
283
|
+
'/**/*.d.ts',
|
|
284
|
+
'/**/*.d.cts',
|
|
285
|
+
'/**/*.d.mts'
|
|
286
|
+
];
|
|
287
|
+
const allFiles = await globDtsFiles(dir, patterns);
|
|
271
288
|
await Promise.all(allFiles.map((file)=>__WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].rm(file, {
|
|
272
289
|
force: true
|
|
273
290
|
})));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsbuild-plugin-dts",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Rsbuild plugin that supports emitting declaration files for TypeScript.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"@ast-grep/napi": "^0.37.0",
|
|
29
29
|
"magic-string": "^0.30.17",
|
|
30
30
|
"picocolors": "1.1.1",
|
|
31
|
-
"tinyglobby": "^0.2.
|
|
31
|
+
"tinyglobby": "^0.2.13",
|
|
32
32
|
"tsconfig-paths": "^4.2.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@microsoft/api-extractor": "^7.52.
|
|
36
|
-
"@rsbuild/core": "1.3.
|
|
35
|
+
"@microsoft/api-extractor": "^7.52.5",
|
|
36
|
+
"@rsbuild/core": "1.3.9",
|
|
37
37
|
"rsbuild-plugin-publint": "^0.3.0",
|
|
38
|
-
"rslib": "npm:@rslib/core@0.6.
|
|
38
|
+
"rslib": "npm:@rslib/core@0.6.5",
|
|
39
39
|
"typescript": "^5.8.3",
|
|
40
40
|
"@rslib/tsconfig": "0.0.1"
|
|
41
41
|
},
|