rsbuild-plugin-dts 0.20.0 → 0.20.2
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/350.js +3592 -0
- package/dist/apiExtractor.d.ts +1 -1
- package/dist/apiExtractor.js +7 -8
- package/dist/dts.d.ts +7 -5
- package/dist/dts.js +4 -5
- package/dist/index.js +6 -10
- package/dist/rslib-runtime.js +18 -0
- package/dist/tsc.d.ts +1 -1
- package/dist/tsc.js +7 -8
- package/dist/tsgo.d.ts +1 -1
- package/dist/tsgo.js +6 -7
- package/dist/utils.d.ts +5 -2
- package/package.json +11 -12
- package/compiled/magic-string/index.d.ts +0 -292
- package/compiled/magic-string/index.js +0 -2126
- package/compiled/magic-string/license +0 -7
- package/compiled/magic-string/package.json +0 -1
- package/compiled/picocolors/index.d.ts +0 -55
- package/compiled/picocolors/index.js +0 -132
- package/compiled/picocolors/license +0 -15
- package/compiled/picocolors/package.json +0 -1
- package/compiled/tinyglobby/index.d.ts +0 -46
- package/compiled/tinyglobby/index.js +0 -3061
- package/compiled/tinyglobby/license +0 -21
- package/compiled/tinyglobby/package.json +0 -1
- package/dist/utils.js +0 -367
package/dist/apiExtractor.d.ts
CHANGED
package/dist/apiExtractor.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import node_fs from "node:fs";
|
|
2
2
|
import { join, relative } from "node:path";
|
|
3
3
|
import { logger } from "@rsbuild/core";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
const logPrefixApiExtractor = picocolors.dim('[api-extractor]');
|
|
4
|
+
import { color, addBannerAndFooter, getTimeCost } from "./350.js";
|
|
5
|
+
const logPrefixApiExtractor = color.dim('[api-extractor]');
|
|
7
6
|
async function bundleDts(options) {
|
|
8
7
|
let apiExtractor;
|
|
9
8
|
try {
|
|
10
9
|
apiExtractor = await import("@microsoft/api-extractor");
|
|
11
10
|
} catch {
|
|
12
|
-
const error = new Error(`${
|
|
11
|
+
const error = new Error(`${color.cyan('@microsoft/api-extractor')} is required when ${color.cyan('dts.bundle')} is set to ${color.cyan('true')}, please make sure it is installed. You could check https://rslib.rs/guide/advanced/dts#how-to-generate-declaration-files-in-rslib for more details.`);
|
|
13
12
|
error.stack = '';
|
|
14
13
|
throw error;
|
|
15
14
|
}
|
|
@@ -20,7 +19,7 @@ async function bundleDts(options) {
|
|
|
20
19
|
const start = Date.now();
|
|
21
20
|
const untrimmedFilePath = join(cwd, relative(cwd, distPath), `${entry.name}${dtsExtension}`);
|
|
22
21
|
const mainEntryPointFilePath = entry.path;
|
|
23
|
-
if (!node_fs.existsSync(mainEntryPointFilePath)) throw new Error(`Declaration entry file ${
|
|
22
|
+
if (!node_fs.existsSync(mainEntryPointFilePath)) throw new Error(`Declaration entry file ${color.underline(entry.path)} not found.\nPlease ensure that your tsconfig file ${color.underline(tsconfigPath)} is correctly configured to generate declaration files. If needed, a custom tsconfig can be specified using the ${color.cyan('source.tsconfigPath')} option.`);
|
|
24
23
|
const internalConfig = {
|
|
25
24
|
mainEntryPointFilePath,
|
|
26
25
|
bundledPackages,
|
|
@@ -44,13 +43,13 @@ async function bundleDts(options) {
|
|
|
44
43
|
if ('console-compiler-version-notice' === message.messageId || 'console-preamble' === message.messageId) message.logLevel = ExtractorLogLevel.None;
|
|
45
44
|
}
|
|
46
45
|
});
|
|
47
|
-
if (!extractorResult.succeeded) throw new Error(`API Extractor error. ${
|
|
46
|
+
if (!extractorResult.succeeded) throw new Error(`API Extractor error. ${color.dim(`(${name})`)}`);
|
|
48
47
|
await addBannerAndFooter(untrimmedFilePath, banner, footer);
|
|
49
|
-
logger.ready(`declaration files bundled successfully: ${
|
|
48
|
+
logger.ready(`declaration files bundled successfully: ${color.cyan(relative(cwd, untrimmedFilePath))} in ${getTimeCost(start)} ${color.dim(`(${name})`)}`);
|
|
50
49
|
}));
|
|
51
50
|
} catch (e) {
|
|
52
51
|
const message = e instanceof Error ? e.message : e;
|
|
53
|
-
const error = new Error(`${logPrefixApiExtractor} ${message} ${
|
|
52
|
+
const error = new Error(`${logPrefixApiExtractor} ${message} ${color.dim(`(${name})`)}`);
|
|
54
53
|
error.stack = '';
|
|
55
54
|
throw error;
|
|
56
55
|
}
|
package/dist/dts.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { DtsGenOptions } from './index';
|
|
1
|
+
import type { DtsGenOptions } from './index.js';
|
|
2
2
|
export declare const DEFAULT_EXCLUDED_PACKAGES: string[];
|
|
3
|
-
|
|
3
|
+
type CalculateBundledPackagesOptions = {
|
|
4
4
|
cwd: string;
|
|
5
|
-
autoExternal: DtsGenOptions[
|
|
6
|
-
userExternals?: DtsGenOptions[
|
|
5
|
+
autoExternal: DtsGenOptions['autoExternal'];
|
|
6
|
+
userExternals?: DtsGenOptions['userExternals'];
|
|
7
7
|
overrideBundledPackages?: string[];
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
|
+
export declare const calcBundledPackages: (options: CalculateBundledPackagesOptions) => string[];
|
|
9
10
|
export declare function generateDts(data: DtsGenOptions): Promise<void>;
|
|
11
|
+
export {};
|
package/dist/dts.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import node_fs from "node:fs";
|
|
2
2
|
import { basename, dirname, isAbsolute, join, normalize, relative, resolve } from "node:path";
|
|
3
3
|
import { logger } from "@rsbuild/core";
|
|
4
|
-
import
|
|
5
|
-
import { calcLongestCommonPath, ensureTempDeclarationDir, mergeAliasWithTsConfigPaths } from "./utils.js";
|
|
4
|
+
import { ensureTempDeclarationDir, color, calcLongestCommonPath, mergeAliasWithTsConfigPaths } from "./350.js";
|
|
6
5
|
const isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj);
|
|
7
6
|
const DEFAULT_EXCLUDED_PACKAGES = [
|
|
8
7
|
'@types/react'
|
|
@@ -14,7 +13,7 @@ const calcBundledPackages = (options)=>{
|
|
|
14
13
|
try {
|
|
15
14
|
const content = node_fs.readFileSync(join(cwd, 'package.json'), 'utf-8');
|
|
16
15
|
pkgJson = JSON.parse(content);
|
|
17
|
-
} catch
|
|
16
|
+
} catch {
|
|
18
17
|
logger.warn('The type of third-party packages will not be bundled due to read package.json failed');
|
|
19
18
|
return [];
|
|
20
19
|
}
|
|
@@ -61,7 +60,7 @@ async function generateDts(data) {
|
|
|
61
60
|
extension: false
|
|
62
61
|
}, tsgo, loggerLevel } = data;
|
|
63
62
|
logger.level = loggerLevel;
|
|
64
|
-
if (!isWatch) logger.start(`generating declaration files... ${
|
|
63
|
+
if (!isWatch) logger.start(`generating declaration files... ${color.dim(`(${name})`)}`);
|
|
65
64
|
const paths = mergeAliasWithTsConfigPaths(tsConfigResult.options.paths, alias);
|
|
66
65
|
if (Object.keys(paths).length > 0) tsConfigResult.options.paths = paths;
|
|
67
66
|
const { options: rawCompilerOptions, fileNames } = tsConfigResult;
|
|
@@ -69,7 +68,7 @@ async function generateDts(data) {
|
|
|
69
68
|
const resolvedDtsEmitPath = normalize(resolve(dirname(tsconfigPath), dtsEmitPath));
|
|
70
69
|
if (build) {
|
|
71
70
|
if (bundle) throw Error('Can not set "dts.bundle: true" when "dts.build: true"');
|
|
72
|
-
if ((!rawCompilerOptions.outDir || normalize(rawCompilerOptions.outDir) !== resolvedDtsEmitPath) && (!rawCompilerOptions.declarationDir || normalize(rawCompilerOptions.declarationDir) !== resolvedDtsEmitPath)) throw Error(`Please set "declarationDir": "${dtsEmitPath}" in ${
|
|
71
|
+
if ((!rawCompilerOptions.outDir || normalize(rawCompilerOptions.outDir) !== resolvedDtsEmitPath) && (!rawCompilerOptions.declarationDir || normalize(rawCompilerOptions.declarationDir) !== resolvedDtsEmitPath)) throw Error(`Please set "declarationDir": "${dtsEmitPath}" in ${color.underline(tsconfigPath)} to keep it same as "dts.distPath" or "output.distPath" field in lib config.`);
|
|
73
72
|
}
|
|
74
73
|
const declarationDir = bundle ? ensureTempDeclarationDir(cwd, name) : dtsEmitPath;
|
|
75
74
|
let dtsEntries = [];
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { fork } from "node:child_process";
|
|
2
|
-
import {
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { extname, join } from "node:path";
|
|
4
3
|
import { logger } from "@rsbuild/core";
|
|
5
|
-
import
|
|
6
|
-
import { cleanDtsFiles, cleanTsBuildInfoFile, clearTempDeclarationDir, getDtsEmitPath, loadTsconfig, processSourceEntry, ts, warnIfOutside } from "./utils.js";
|
|
7
|
-
const src_filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const src_dirname = dirname(src_filename);
|
|
4
|
+
import { processSourceEntry, cleanDtsFiles, clearTempDeclarationDir, getDtsEmitPath, cleanTsBuildInfoFile, color, warnIfOutside, ts, loadTsconfig } from "./350.js";
|
|
9
5
|
const PLUGIN_DTS_NAME = 'rsbuild:dts';
|
|
10
6
|
const pluginDts = (options = {})=>({
|
|
11
7
|
name: PLUGIN_DTS_NAME,
|
|
@@ -36,7 +32,7 @@ const pluginDts = (options = {})=>({
|
|
|
36
32
|
const cwd = api.context.rootPath;
|
|
37
33
|
const tsconfigPath = ts.findConfigFile(cwd, ts.sys.fileExists.bind(ts.sys), config.source.tsconfigPath);
|
|
38
34
|
if (!tsconfigPath) {
|
|
39
|
-
const error = new Error(`Failed to resolve tsconfig file ${
|
|
35
|
+
const error = new Error(`Failed to resolve tsconfig file ${color.cyan(`"${config.source.tsconfigPath}"`)} from ${color.cyan(cwd)}. Please ensure that the file exists.`);
|
|
40
36
|
error.stack = '';
|
|
41
37
|
throw error;
|
|
42
38
|
}
|
|
@@ -50,8 +46,8 @@ const pluginDts = (options = {})=>({
|
|
|
50
46
|
if (false !== config.output.cleanDistPath) await cleanDtsFiles(dtsEmitPath);
|
|
51
47
|
if (bundle) await clearTempDeclarationDir(cwd);
|
|
52
48
|
if (composite || incremental || options.build) await cleanTsBuildInfoFile(tsconfigPath, rawCompilerOptions);
|
|
53
|
-
const jsExtension = extname(
|
|
54
|
-
const childProcess = fork(join(
|
|
49
|
+
const jsExtension = extname(import.meta.filename);
|
|
50
|
+
const childProcess = fork(join(import.meta.dirname, `./dts${jsExtension}`), [], {
|
|
55
51
|
stdio: 'inherit'
|
|
56
52
|
});
|
|
57
53
|
childProcesses.push(childProcess);
|
|
@@ -104,7 +100,7 @@ const pluginDts = (options = {})=>({
|
|
|
104
100
|
const killProcesses = ()=>{
|
|
105
101
|
for (const childProcess of childProcesses)if (!childProcess.killed) try {
|
|
106
102
|
childProcess.kill();
|
|
107
|
-
} catch
|
|
103
|
+
} catch {}
|
|
108
104
|
childProcesses = [];
|
|
109
105
|
};
|
|
110
106
|
api.onCloseBuild(killProcesses);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __webpack_modules__ = {};
|
|
2
|
+
var __webpack_module_cache__ = {};
|
|
3
|
+
function __webpack_require__(moduleId) {
|
|
4
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
5
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
6
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
7
|
+
exports: {}
|
|
8
|
+
};
|
|
9
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
10
|
+
return module.exports;
|
|
11
|
+
}
|
|
12
|
+
__webpack_require__.m = __webpack_modules__;
|
|
13
|
+
(()=>{
|
|
14
|
+
__webpack_require__.add = function(modules) {
|
|
15
|
+
Object.assign(__webpack_require__.m, modules);
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
export { __webpack_require__ };
|
package/dist/tsc.d.ts
CHANGED
package/dist/tsc.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { logger } from "@rsbuild/core";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
const logPrefixTsc = picocolors.dim('[tsc]');
|
|
2
|
+
import { updateDeclarationMapContent, processDtsFiles, color, renameDtsFile, ts, getTimeCost } from "./350.js";
|
|
3
|
+
const logPrefixTsc = color.dim('[tsc]');
|
|
5
4
|
const formatHost = {
|
|
6
5
|
getCanonicalFileName: (path)=>path,
|
|
7
6
|
getCurrentDirectory: ts.sys.getCurrentDirectory.bind(ts.sys),
|
|
@@ -18,7 +17,7 @@ async function handleDiagnosticsAndProcessFiles(diagnostics, configPath, bundle,
|
|
|
18
17
|
await processDtsFiles(bundle, declarationDir, dtsExtension, redirect, configPath, rootDir, paths, banner, footer);
|
|
19
18
|
if (diagnosticMessages.length) {
|
|
20
19
|
for (const message of diagnosticMessages)logger.error(logPrefixTsc, message);
|
|
21
|
-
const error = new Error(`Failed to generate declaration files. ${
|
|
20
|
+
const error = new Error(`Failed to generate declaration files. ${color.dim(`(${name})`)}`);
|
|
22
21
|
error.stack = '';
|
|
23
22
|
throw error;
|
|
24
23
|
}
|
|
@@ -42,7 +41,7 @@ async function emitDtsTsc(options, onComplete, bundle = false, isWatch = false,
|
|
|
42
41
|
], formatHost));
|
|
43
42
|
};
|
|
44
43
|
const reportWatchStatusChanged = async (diagnostic, _newLine, _options, errorCount)=>{
|
|
45
|
-
const message = `${ts.flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine())} ${
|
|
44
|
+
const message = `${ts.flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine())} ${color.dim(`(${name})`)}`;
|
|
46
45
|
if (6031 === diagnostic.code || 6032 === diagnostic.code) logger.info(logPrefixTsc, message);
|
|
47
46
|
if (6194 === diagnostic.code) {
|
|
48
47
|
if (0 !== errorCount && errorCount) logger.error(logPrefixTsc, message);
|
|
@@ -114,7 +113,7 @@ async function emitDtsTsc(options, onComplete, bundle = false, isWatch = false,
|
|
|
114
113
|
solutionBuilder.build();
|
|
115
114
|
await processDtsFiles(bundle, declarationDir, dtsExtension, redirect, configPath, rootDir, paths, banner, footer);
|
|
116
115
|
if (errorNumber > 0) {
|
|
117
|
-
const error = new Error(`Failed to generate declaration files. ${
|
|
116
|
+
const error = new Error(`Failed to generate declaration files. ${color.dim(`(${name})`)}`);
|
|
118
117
|
error.stack = '';
|
|
119
118
|
throw error;
|
|
120
119
|
}
|
|
@@ -142,8 +141,8 @@ async function emitDtsTsc(options, onComplete, bundle = false, isWatch = false,
|
|
|
142
141
|
const sortAndDeduplicateDiagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics);
|
|
143
142
|
await handleDiagnosticsAndProcessFiles(sortAndDeduplicateDiagnostics, configPath, bundle, declarationDir, dtsExtension, redirect, rootDir, paths, banner, footer, name);
|
|
144
143
|
}
|
|
145
|
-
if (bundle) logger.info(`declaration files prepared in ${getTimeCost(start)} ${
|
|
146
|
-
else logger.ready(`declaration files generated in ${getTimeCost(start)} ${
|
|
144
|
+
if (bundle) logger.info(`declaration files prepared in ${getTimeCost(start)} ${color.dim(`(${name})`)}`);
|
|
145
|
+
else logger.ready(`declaration files generated in ${getTimeCost(start)} ${color.dim(`(${name})`)}`);
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
148
|
export { emitDtsTsc };
|
package/dist/tsgo.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { EmitDtsOptions } from './tsc';
|
|
1
|
+
import type { EmitDtsOptions } from './tsc.js';
|
|
2
2
|
export declare function emitDtsTsgo(options: EmitDtsOptions, _onComplete: (isSuccess: boolean) => void, bundle?: boolean, isWatch?: boolean, build?: boolean): Promise<boolean>;
|
package/dist/tsgo.js
CHANGED
|
@@ -4,10 +4,9 @@ import { createRequire } from "node:module";
|
|
|
4
4
|
import node_path from "node:path";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
6
|
import { logger } from "@rsbuild/core";
|
|
7
|
-
import
|
|
8
|
-
import { getTimeCost, globDtsFiles, processDtsFiles, renameDtsFile, updateDeclarationMapContent } from "./utils.js";
|
|
7
|
+
import { updateDeclarationMapContent, processDtsFiles, color, renameDtsFile, globDtsFiles, getTimeCost } from "./350.js";
|
|
9
8
|
const tsgo_require = createRequire(import.meta.url);
|
|
10
|
-
const logPrefixTsgo =
|
|
9
|
+
const logPrefixTsgo = color.dim('[tsgo]');
|
|
11
10
|
const getTsgoBinPath = async ()=>{
|
|
12
11
|
const tsgoPkgPath = tsgo_require.resolve("@typescript/native-preview/package.json");
|
|
13
12
|
const libPath = node_path.resolve(node_path.dirname(tsgoPkgPath), './lib/getExePath.js');
|
|
@@ -48,7 +47,7 @@ async function handleDiagnosticsAndProcessFiles(isWatch, hasErrors, tsConfigResu
|
|
|
48
47
|
}
|
|
49
48
|
await processDtsFiles(bundle, declarationDir, dtsExtension, redirect, configPath, rootDir, paths, banner, footer);
|
|
50
49
|
if (hasErrors && !isWatch) {
|
|
51
|
-
const error = new Error(`Failed to generate declaration files. ${
|
|
50
|
+
const error = new Error(`Failed to generate declaration files. ${color.dim(`(${name})`)}`);
|
|
52
51
|
error.stack = '';
|
|
53
52
|
throw error;
|
|
54
53
|
}
|
|
@@ -75,7 +74,7 @@ async function emitDtsTsgo(options, _onComplete, bundle = false, isWatch = false
|
|
|
75
74
|
childProcess.stdout?.on('data', (data)=>{
|
|
76
75
|
const output = data.toString();
|
|
77
76
|
const lines = output.split('\n');
|
|
78
|
-
for (const line of lines)if (line.trim()) logger.log(
|
|
77
|
+
for (const line of lines)if (line.trim()) logger.log(color.reset(`${logPrefixTsgo} ${line}`));
|
|
79
78
|
});
|
|
80
79
|
childProcess.stderr?.on('data', (data)=>{
|
|
81
80
|
const output = data.toString();
|
|
@@ -86,8 +85,8 @@ async function emitDtsTsgo(options, _onComplete, bundle = false, isWatch = false
|
|
|
86
85
|
try {
|
|
87
86
|
if (0 !== code) hasErrors = true;
|
|
88
87
|
await handleDiagnosticsAndProcessFiles(isWatch, hasErrors, tsConfigResult, configPath, bundle, declarationDir, dtsExtension, redirect, rootDir, paths, banner, footer, name);
|
|
89
|
-
if (!hasErrors) if (bundle) logger.info(`declaration files prepared with tsgo in ${getTimeCost(start)} ${
|
|
90
|
-
else logger.ready(`declaration files generated with tsgo in ${getTimeCost(start)} ${
|
|
88
|
+
if (!hasErrors) if (bundle) logger.info(`declaration files prepared with tsgo in ${getTimeCost(start)} ${color.dim(`(${name})`)}`);
|
|
89
|
+
else logger.ready(`declaration files generated with tsgo in ${getTimeCost(start)} ${color.dim(`(${name})`)}`);
|
|
91
90
|
resolve(hasErrors);
|
|
92
91
|
} catch (error) {
|
|
93
92
|
reject(error instanceof Error ? error : new Error(String(error)));
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type RsbuildConfig } from '@rsbuild/core';
|
|
2
|
-
import type
|
|
2
|
+
import { type MatchPath } from '../compiled/tsconfig-paths/index.js';
|
|
3
3
|
import type { CompilerOptions, Diagnostic, ParsedCommandLine } from 'typescript';
|
|
4
|
-
import type { DtsEntry, DtsRedirect } from './index';
|
|
4
|
+
import type { DtsEntry, DtsRedirect } from './index.js';
|
|
5
5
|
/**
|
|
6
6
|
* Currently, typescript only provides a CJS bundle, so we use require to load it
|
|
7
7
|
* for better startup performance. If we use `import ts from 'typescript'`,
|
|
@@ -9,6 +9,9 @@ import type { DtsEntry, DtsRedirect } from './index';
|
|
|
9
9
|
*/
|
|
10
10
|
declare const ts: typeof import("typescript");
|
|
11
11
|
export { ts };
|
|
12
|
+
type ColorFn = (text: string | number) => string;
|
|
13
|
+
type ColorMap = Record<'bold' | 'cyan' | 'dim' | 'reset' | 'underline' | 'yellow', ColorFn>;
|
|
14
|
+
export declare const color: ColorMap;
|
|
12
15
|
export declare const JS_EXTENSIONS_PATTERN: RegExp;
|
|
13
16
|
export declare function loadTsconfig(tsconfigPath: string): ParsedCommandLine;
|
|
14
17
|
export declare function mergeAliasWithTsConfigPaths(paths: Record<string, string[]> | undefined, alias?: Record<string, string>): Record<string, string[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsbuild-plugin-dts",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.2",
|
|
4
4
|
"description": "Rsbuild plugin that supports emitting declaration files for TypeScript.",
|
|
5
5
|
"homepage": "https://rslib.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -29,24 +29,23 @@
|
|
|
29
29
|
"@ast-grep/napi": "0.37.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@microsoft/api-extractor": "^7.57.
|
|
33
|
-
"@rsbuild/core": "2.0.0-beta.
|
|
34
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
32
|
+
"@microsoft/api-extractor": "^7.57.7",
|
|
33
|
+
"@rsbuild/core": "2.0.0-beta.11",
|
|
34
|
+
"@typescript/native-preview": "7.0.0-dev.20260329.1",
|
|
35
35
|
"magic-string": "^0.30.21",
|
|
36
|
-
"
|
|
37
|
-
"prebundle": "1.6.2",
|
|
36
|
+
"prebundle": "1.6.4",
|
|
38
37
|
"rsbuild-plugin-publint": "^0.3.4",
|
|
39
|
-
"rslib": "npm:@rslib/core@0.20.
|
|
40
|
-
"tinyglobby": "0.2.
|
|
38
|
+
"rslib": "npm:@rslib/core@0.20.1",
|
|
39
|
+
"tinyglobby": "^0.2.15",
|
|
41
40
|
"tsconfig-paths": "^4.2.0",
|
|
42
|
-
"typescript": "^
|
|
41
|
+
"typescript": "^6.0.2",
|
|
43
42
|
"@rslib/tsconfig": "0.0.1"
|
|
44
43
|
},
|
|
45
44
|
"peerDependencies": {
|
|
46
45
|
"@microsoft/api-extractor": "^7",
|
|
47
46
|
"@rsbuild/core": "^1.0.0 || ^2.0.0-0",
|
|
48
47
|
"@typescript/native-preview": "7.x",
|
|
49
|
-
"typescript": "^5"
|
|
48
|
+
"typescript": "^5 || ^6"
|
|
50
49
|
},
|
|
51
50
|
"peerDependenciesMeta": {
|
|
52
51
|
"@microsoft/api-extractor": {
|
|
@@ -67,8 +66,8 @@
|
|
|
67
66
|
"registry": "https://registry.npmjs.org/"
|
|
68
67
|
},
|
|
69
68
|
"scripts": {
|
|
70
|
-
"build": "rslib
|
|
71
|
-
"dev": "rslib
|
|
69
|
+
"build": "rslib",
|
|
70
|
+
"dev": "rslib --watch",
|
|
72
71
|
"prebundle": "prebundle",
|
|
73
72
|
"test": "rstest"
|
|
74
73
|
}
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
interface BundleOptions {
|
|
2
|
-
intro?: string;
|
|
3
|
-
separator?: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
interface SourceMapOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Whether the mapping should be high-resolution.
|
|
9
|
-
* Hi-res mappings map every single character, meaning (for example) your devtools will always
|
|
10
|
-
* be able to pinpoint the exact location of function calls and so on.
|
|
11
|
-
* With lo-res mappings, devtools may only be able to identify the correct
|
|
12
|
-
* line - but they're quicker to generate and less bulky.
|
|
13
|
-
* You can also set `"boundary"` to generate a semi-hi-res mappings segmented per word boundary
|
|
14
|
-
* instead of per character, suitable for string semantics that are separated by words.
|
|
15
|
-
* If sourcemap locations have been specified with s.addSourceMapLocation(), they will be used here.
|
|
16
|
-
*/
|
|
17
|
-
hires?: boolean | 'boundary';
|
|
18
|
-
/**
|
|
19
|
-
* The filename where you plan to write the sourcemap.
|
|
20
|
-
*/
|
|
21
|
-
file?: string;
|
|
22
|
-
/**
|
|
23
|
-
* The filename of the file containing the original source.
|
|
24
|
-
*/
|
|
25
|
-
source?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Whether to include the original content in the map's sourcesContent array.
|
|
28
|
-
*/
|
|
29
|
-
includeContent?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
type SourceMapSegment =
|
|
33
|
-
| [number]
|
|
34
|
-
| [number, number, number, number]
|
|
35
|
-
| [number, number, number, number, number];
|
|
36
|
-
|
|
37
|
-
interface DecodedSourceMap {
|
|
38
|
-
file: string;
|
|
39
|
-
sources: string[];
|
|
40
|
-
sourcesContent?: string[];
|
|
41
|
-
names: string[];
|
|
42
|
-
mappings: SourceMapSegment[][];
|
|
43
|
-
x_google_ignoreList?: number[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
declare class SourceMap {
|
|
47
|
-
constructor(properties: DecodedSourceMap);
|
|
48
|
-
|
|
49
|
-
version: number;
|
|
50
|
-
file: string;
|
|
51
|
-
sources: string[];
|
|
52
|
-
sourcesContent?: string[];
|
|
53
|
-
names: string[];
|
|
54
|
-
mappings: string;
|
|
55
|
-
x_google_ignoreList?: number[];
|
|
56
|
-
debugId?: string;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Returns the equivalent of `JSON.stringify(map)`
|
|
60
|
-
*/
|
|
61
|
-
toString(): string;
|
|
62
|
-
/**
|
|
63
|
-
* Returns a DataURI containing the sourcemap. Useful for doing this sort of thing:
|
|
64
|
-
* `generateMap(options?: SourceMapOptions): SourceMap;`
|
|
65
|
-
*/
|
|
66
|
-
toUrl(): string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
declare class Bundle {
|
|
70
|
-
constructor(options?: BundleOptions);
|
|
71
|
-
/**
|
|
72
|
-
* Adds the specified source to the bundle, which can either be a `MagicString` object directly,
|
|
73
|
-
* or an options object that holds a magic string `content` property and optionally provides
|
|
74
|
-
* a `filename` for the source within the bundle, as well as an optional `ignoreList` hint
|
|
75
|
-
* (which defaults to `false`). The `filename` is used when constructing the source map for the
|
|
76
|
-
* bundle, to identify this `source` in the source map's `sources` field. The `ignoreList` hint
|
|
77
|
-
* is used to populate the `x_google_ignoreList` extension field in the source map, which is a
|
|
78
|
-
* mechanism for tools to signal to debuggers that certain sources should be ignored by default
|
|
79
|
-
* (depending on user preferences).
|
|
80
|
-
*/
|
|
81
|
-
addSource(
|
|
82
|
-
source: MagicString | { filename?: string; content: MagicString; ignoreList?: boolean },
|
|
83
|
-
): this;
|
|
84
|
-
append(str: string, options?: BundleOptions): this;
|
|
85
|
-
clone(): this;
|
|
86
|
-
generateMap(
|
|
87
|
-
options?: SourceMapOptions,
|
|
88
|
-
): Omit<SourceMap, 'sourcesContent'> & { sourcesContent: Array<string | null> };
|
|
89
|
-
generateDecodedMap(
|
|
90
|
-
options?: SourceMapOptions,
|
|
91
|
-
): Omit<DecodedSourceMap, 'sourcesContent'> & { sourcesContent: Array<string | null> };
|
|
92
|
-
getIndentString(): string;
|
|
93
|
-
indent(indentStr?: string): this;
|
|
94
|
-
indentExclusionRanges: ExclusionRange | Array<ExclusionRange>;
|
|
95
|
-
prepend(str: string): this;
|
|
96
|
-
toString(): string;
|
|
97
|
-
trimLines(): this;
|
|
98
|
-
trim(charType?: string): this;
|
|
99
|
-
trimStart(charType?: string): this;
|
|
100
|
-
trimEnd(charType?: string): this;
|
|
101
|
-
isEmpty(): boolean;
|
|
102
|
-
length(): number;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
type ExclusionRange = [number, number];
|
|
106
|
-
|
|
107
|
-
interface MagicStringOptions {
|
|
108
|
-
filename?: string;
|
|
109
|
-
indentExclusionRanges?: ExclusionRange | Array<ExclusionRange>;
|
|
110
|
-
offset?: number;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
interface IndentOptions {
|
|
114
|
-
exclude?: ExclusionRange | Array<ExclusionRange>;
|
|
115
|
-
indentStart?: boolean;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
interface OverwriteOptions {
|
|
119
|
-
storeName?: boolean;
|
|
120
|
-
contentOnly?: boolean;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
interface UpdateOptions {
|
|
124
|
-
storeName?: boolean;
|
|
125
|
-
overwrite?: boolean;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
declare class MagicString {
|
|
129
|
-
constructor(str: string, options?: MagicStringOptions);
|
|
130
|
-
/**
|
|
131
|
-
* Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
|
|
132
|
-
*/
|
|
133
|
-
addSourcemapLocation(char: number): void;
|
|
134
|
-
/**
|
|
135
|
-
* Appends the specified content to the end of the string.
|
|
136
|
-
*/
|
|
137
|
-
append(content: string): this;
|
|
138
|
-
/**
|
|
139
|
-
* Appends the specified content at the index in the original string.
|
|
140
|
-
* If a range *ending* with index is subsequently moved, the insert will be moved with it.
|
|
141
|
-
* See also `s.prependLeft(...)`.
|
|
142
|
-
*/
|
|
143
|
-
appendLeft(index: number, content: string): this;
|
|
144
|
-
/**
|
|
145
|
-
* Appends the specified content at the index in the original string.
|
|
146
|
-
* If a range *starting* with index is subsequently moved, the insert will be moved with it.
|
|
147
|
-
* See also `s.prependRight(...)`.
|
|
148
|
-
*/
|
|
149
|
-
appendRight(index: number, content: string): this;
|
|
150
|
-
/**
|
|
151
|
-
* Does what you'd expect.
|
|
152
|
-
*/
|
|
153
|
-
clone(): this;
|
|
154
|
-
/**
|
|
155
|
-
* Generates a version 3 sourcemap.
|
|
156
|
-
*/
|
|
157
|
-
generateMap(options?: SourceMapOptions): SourceMap;
|
|
158
|
-
/**
|
|
159
|
-
* Generates a sourcemap object with raw mappings in array form, rather than encoded as a string.
|
|
160
|
-
* Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead.
|
|
161
|
-
*/
|
|
162
|
-
generateDecodedMap(options?: SourceMapOptions): DecodedSourceMap;
|
|
163
|
-
getIndentString(): string;
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Prefixes each line of the string with prefix.
|
|
167
|
-
* If prefix is not supplied, the indentation will be guessed from the original content, falling back to a single tab character.
|
|
168
|
-
*/
|
|
169
|
-
indent(options?: IndentOptions): this;
|
|
170
|
-
/**
|
|
171
|
-
* Prefixes each line of the string with prefix.
|
|
172
|
-
* If prefix is not supplied, the indentation will be guessed from the original content, falling back to a single tab character.
|
|
173
|
-
*
|
|
174
|
-
* The options argument can have an exclude property, which is an array of [start, end] character ranges.
|
|
175
|
-
* These ranges will be excluded from the indentation - useful for (e.g.) multiline strings.
|
|
176
|
-
*/
|
|
177
|
-
indent(indentStr?: string, options?: IndentOptions): this;
|
|
178
|
-
indentExclusionRanges: ExclusionRange | Array<ExclusionRange>;
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Moves the characters from `start` and `end` to `index`.
|
|
182
|
-
*/
|
|
183
|
-
move(start: number, end: number, index: number): this;
|
|
184
|
-
/**
|
|
185
|
-
* Replaces the characters from `start` to `end` with `content`, along with the appended/prepended content in
|
|
186
|
-
* that range. The same restrictions as `s.remove()` apply.
|
|
187
|
-
*
|
|
188
|
-
* The fourth argument is optional. It can have a storeName property — if true, the original name will be stored
|
|
189
|
-
* for later inclusion in a sourcemap's names array — and a contentOnly property which determines whether only
|
|
190
|
-
* the content is overwritten, or anything that was appended/prepended to the range as well.
|
|
191
|
-
*
|
|
192
|
-
* It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
|
|
193
|
-
*/
|
|
194
|
-
overwrite(
|
|
195
|
-
start: number,
|
|
196
|
-
end: number,
|
|
197
|
-
content: string,
|
|
198
|
-
options?: boolean | OverwriteOptions,
|
|
199
|
-
): this;
|
|
200
|
-
/**
|
|
201
|
-
* Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply.
|
|
202
|
-
*
|
|
203
|
-
* The fourth argument is optional. It can have a storeName property — if true, the original name will be stored
|
|
204
|
-
* for later inclusion in a sourcemap's names array — and an overwrite property which determines whether only
|
|
205
|
-
* the content is overwritten, or anything that was appended/prepended to the range as well.
|
|
206
|
-
*/
|
|
207
|
-
update(start: number, end: number, content: string, options?: boolean | UpdateOptions): this;
|
|
208
|
-
/**
|
|
209
|
-
* Prepends the string with the specified content.
|
|
210
|
-
*/
|
|
211
|
-
prepend(content: string): this;
|
|
212
|
-
/**
|
|
213
|
-
* Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
|
|
214
|
-
*/
|
|
215
|
-
prependLeft(index: number, content: string): this;
|
|
216
|
-
/**
|
|
217
|
-
* Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
|
|
218
|
-
*/
|
|
219
|
-
prependRight(index: number, content: string): this;
|
|
220
|
-
/**
|
|
221
|
-
* Removes the characters from `start` to `end` (of the original string, **not** the generated string).
|
|
222
|
-
* Removing the same content twice, or making removals that partially overlap, will cause an error.
|
|
223
|
-
*/
|
|
224
|
-
remove(start: number, end: number): this;
|
|
225
|
-
/**
|
|
226
|
-
* Reset the modified characters from `start` to `end` (of the original string, **not** the generated string).
|
|
227
|
-
*/
|
|
228
|
-
reset(start: number, end: number): this;
|
|
229
|
-
/**
|
|
230
|
-
* Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string.
|
|
231
|
-
* Throws error if the indices are for characters that were already removed.
|
|
232
|
-
*/
|
|
233
|
-
slice(start: number, end: number): string;
|
|
234
|
-
/**
|
|
235
|
-
* Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed.
|
|
236
|
-
*/
|
|
237
|
-
snip(start: number, end: number): this;
|
|
238
|
-
/**
|
|
239
|
-
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end.
|
|
240
|
-
*/
|
|
241
|
-
trim(charType?: string): this;
|
|
242
|
-
/**
|
|
243
|
-
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
|
|
244
|
-
*/
|
|
245
|
-
trimStart(charType?: string): this;
|
|
246
|
-
/**
|
|
247
|
-
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
|
|
248
|
-
*/
|
|
249
|
-
trimEnd(charType?: string): this;
|
|
250
|
-
/**
|
|
251
|
-
* Removes empty lines from the start and end.
|
|
252
|
-
*/
|
|
253
|
-
trimLines(): this;
|
|
254
|
-
/**
|
|
255
|
-
* String replacement with RegExp or string.
|
|
256
|
-
*/
|
|
257
|
-
replace(
|
|
258
|
-
regex: RegExp | string,
|
|
259
|
-
replacement: string | ((substring: string, ...args: any[]) => string),
|
|
260
|
-
): this;
|
|
261
|
-
/**
|
|
262
|
-
* Same as `s.replace`, but replace all matched strings instead of just one.
|
|
263
|
-
*/
|
|
264
|
-
replaceAll(
|
|
265
|
-
regex: RegExp | string,
|
|
266
|
-
replacement: string | ((substring: string, ...args: any[]) => string),
|
|
267
|
-
): this;
|
|
268
|
-
|
|
269
|
-
lastChar(): string;
|
|
270
|
-
lastLine(): string;
|
|
271
|
-
/**
|
|
272
|
-
* Returns true if the resulting source is empty (disregarding white space).
|
|
273
|
-
*/
|
|
274
|
-
isEmpty(): boolean;
|
|
275
|
-
length(): number;
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Indicates if the string has been changed.
|
|
279
|
-
*/
|
|
280
|
-
hasChanged(): boolean;
|
|
281
|
-
|
|
282
|
-
original: string;
|
|
283
|
-
/**
|
|
284
|
-
* Returns the generated string.
|
|
285
|
-
*/
|
|
286
|
-
toString(): string;
|
|
287
|
-
|
|
288
|
-
offset: number;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
export { Bundle, SourceMap, MagicString as default };
|
|
292
|
-
export type { BundleOptions, DecodedSourceMap, ExclusionRange, IndentOptions, MagicStringOptions, OverwriteOptions, SourceMapOptions, SourceMapSegment, UpdateOptions };
|