rsbuild-plugin-dts 0.11.2 → 0.12.0
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/apiExtractor.js +1 -1
- package/dist/dts.js +7 -3
- package/dist/index.js +1 -1
- package/dist/tsc.js +1 -1
- package/dist/utils.js +4 -4
- package/package.json +4 -4
package/dist/apiExtractor.js
CHANGED
|
@@ -47,7 +47,7 @@ async function bundleDts(options) {
|
|
|
47
47
|
logger.ready(`declaration files bundled successfully: ${picocolors.cyan(relative(cwd, untrimmedFilePath))} in ${getTimeCost(start)} ${picocolors.gray(`(${name})`)}`);
|
|
48
48
|
}));
|
|
49
49
|
} catch (e) {
|
|
50
|
-
const error = new Error(`${logPrefixApiExtractor} ${e}`);
|
|
50
|
+
const error = new Error(`${logPrefixApiExtractor} ${e} ${picocolors.gray(`(${name})`)}`);
|
|
51
51
|
error.stack = '';
|
|
52
52
|
throw error;
|
|
53
53
|
}
|
package/dist/dts.js
CHANGED
|
@@ -69,7 +69,7 @@ async function generateDts(data) {
|
|
|
69
69
|
}
|
|
70
70
|
const declarationDir = bundle ? ensureTempDeclarationDir(cwd, name) : dtsEmitPath;
|
|
71
71
|
let dtsEntries = [];
|
|
72
|
-
if (
|
|
72
|
+
if (bundle) dtsEntries = dtsEntry.map((entryObj)=>{
|
|
73
73
|
const { name: entryName, path: entryPath } = entryObj;
|
|
74
74
|
if (!entryPath) return null;
|
|
75
75
|
const entrySourcePath = isAbsolute(entryPath) ? entryPath : join(cwd, entryPath);
|
|
@@ -81,7 +81,7 @@ async function generateDts(data) {
|
|
|
81
81
|
};
|
|
82
82
|
}).filter(Boolean);
|
|
83
83
|
const bundleDtsIfNeeded = async ()=>{
|
|
84
|
-
if (
|
|
84
|
+
if (bundle) {
|
|
85
85
|
const { bundleDts } = await import("./apiExtractor.js");
|
|
86
86
|
await bundleDts({
|
|
87
87
|
name,
|
|
@@ -102,7 +102,11 @@ async function generateDts(data) {
|
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
104
|
const onComplete = async (isSuccess)=>{
|
|
105
|
-
if (isSuccess)
|
|
105
|
+
if (isSuccess) try {
|
|
106
|
+
await bundleDtsIfNeeded();
|
|
107
|
+
} catch (e) {
|
|
108
|
+
logger.error(e);
|
|
109
|
+
}
|
|
106
110
|
};
|
|
107
111
|
await emitDts({
|
|
108
112
|
name,
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ const pluginDts = (options = {})=>({
|
|
|
30
30
|
const { config } = environment;
|
|
31
31
|
const dtsEntry = processSourceEntry(bundle, config.source?.entry);
|
|
32
32
|
const cwd = api.context.rootPath;
|
|
33
|
-
const tsconfigPath = typescript.findConfigFile(cwd, typescript.sys.fileExists, config.source.tsconfigPath);
|
|
33
|
+
const tsconfigPath = typescript.findConfigFile(cwd, typescript.sys.fileExists.bind(typescript.sys), config.source.tsconfigPath);
|
|
34
34
|
if (!tsconfigPath) {
|
|
35
35
|
const error = new Error(`Failed to resolve tsconfig file ${picocolors.cyan(`"${config.source.tsconfigPath}"`)} from ${picocolors.cyan(cwd)}. Please ensure that the file exists.`);
|
|
36
36
|
error.stack = '';
|
package/dist/tsc.js
CHANGED
|
@@ -5,7 +5,7 @@ import { getTimeCost, processDtsFiles } from "./utils.js";
|
|
|
5
5
|
const logPrefixTsc = picocolors.dim('[tsc]');
|
|
6
6
|
const formatHost = {
|
|
7
7
|
getCanonicalFileName: (path)=>path,
|
|
8
|
-
getCurrentDirectory: typescript.sys.getCurrentDirectory,
|
|
8
|
+
getCurrentDirectory: typescript.sys.getCurrentDirectory.bind(typescript.sys),
|
|
9
9
|
getNewLine: ()=>typescript.sys.newLine
|
|
10
10
|
};
|
|
11
11
|
async function handleDiagnosticsAndProcessFiles(diagnostics, configPath, bundle, declarationDir, dtsExtension, redirect, rootDir, paths, banner, footer, name) {
|
package/dist/utils.js
CHANGED
|
@@ -25,7 +25,7 @@ const JS_EXTENSIONS = [
|
|
|
25
25
|
];
|
|
26
26
|
const JS_EXTENSIONS_PATTERN = new RegExp(`\\.(${JS_EXTENSIONS.join('|')})$`);
|
|
27
27
|
function loadTsconfig(tsconfigPath) {
|
|
28
|
-
const configFile = typescript.readConfigFile(tsconfigPath, typescript.sys.readFile);
|
|
28
|
+
const configFile = typescript.readConfigFile(tsconfigPath, typescript.sys.readFile.bind(typescript.sys));
|
|
29
29
|
const configFileContent = typescript.parseJsonConfigFileContent(configFile.config, typescript.sys, node_path.dirname(tsconfigPath));
|
|
30
30
|
return configFileContent;
|
|
31
31
|
}
|
|
@@ -89,7 +89,7 @@ function getFileLoc(diagnostic, configPath) {
|
|
|
89
89
|
const { line, character } = typescript.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
|
90
90
|
return `${picocolors.cyan(diagnostic.file.fileName)}:${picocolors.yellow(line + 1)}:${picocolors.yellow(character + 1)}`;
|
|
91
91
|
}
|
|
92
|
-
return
|
|
92
|
+
return picocolors.cyan(configPath);
|
|
93
93
|
}
|
|
94
94
|
const prettyTime = (seconds)=>{
|
|
95
95
|
const format = (time)=>picocolors.bold(time);
|
|
@@ -301,7 +301,7 @@ async function calcLongestCommonPath(absPaths) {
|
|
|
301
301
|
return lca;
|
|
302
302
|
}
|
|
303
303
|
const globDtsFiles = async (dir, patterns)=>{
|
|
304
|
-
const dtsFiles = await Promise.all(patterns.map((pattern)=>glob(convertPath(join(dir, pattern)), {
|
|
304
|
+
const dtsFiles = await Promise.all(patterns.map(async (pattern)=>glob(convertPath(join(dir, pattern)), {
|
|
305
305
|
absolute: true
|
|
306
306
|
})));
|
|
307
307
|
return dtsFiles.flat();
|
|
@@ -313,7 +313,7 @@ async function cleanDtsFiles(dir) {
|
|
|
313
313
|
'/**/*.d.mts'
|
|
314
314
|
];
|
|
315
315
|
const allFiles = await globDtsFiles(dir, patterns);
|
|
316
|
-
await Promise.all(allFiles.map((file)=>promises.rm(file, {
|
|
316
|
+
await Promise.all(allFiles.map(async (file)=>promises.rm(file, {
|
|
317
317
|
force: true
|
|
318
318
|
})));
|
|
319
319
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsbuild-plugin-dts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Rsbuild plugin that supports emitting declaration files for TypeScript.",
|
|
5
5
|
"homepage": "https://rslib.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@microsoft/api-extractor": "^7.52.10",
|
|
36
|
-
"@rsbuild/core": "
|
|
36
|
+
"@rsbuild/core": "1.5.0-beta.0",
|
|
37
37
|
"rsbuild-plugin-publint": "^0.3.3",
|
|
38
|
-
"rslib": "npm:@rslib/core@0.11.
|
|
38
|
+
"rslib": "npm:@rslib/core@0.11.2",
|
|
39
39
|
"typescript": "^5.9.2",
|
|
40
40
|
"@rslib/tsconfig": "0.0.1"
|
|
41
41
|
},
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
|
-
"node": ">=
|
|
56
|
+
"node": ">=18.12.0"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public",
|