@rsdoctor/types 1.5.9 → 1.5.11

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.
Files changed (65) hide show
  1. package/dist/babel.d.cts +13 -0
  2. package/dist/client.d.cts +164 -0
  3. package/dist/common.d.cts +26 -0
  4. package/dist/config.d.cts +75 -0
  5. package/dist/constants.d.cts +19 -0
  6. package/dist/emo.d.cts +28 -0
  7. package/dist/error.d.cts +137 -0
  8. package/dist/esbuild.d.cts +30 -0
  9. package/dist/index.cjs +9 -9
  10. package/dist/index.d.cts +15 -0
  11. package/dist/linter/diagnostic.d.cts +48 -0
  12. package/dist/linter/index.d.cts +2 -0
  13. package/dist/linter/rule.d.cts +105 -0
  14. package/dist/logger.d.cts +9 -0
  15. package/dist/manifest.d.cts +68 -0
  16. package/dist/modules.d.cts +7 -0
  17. package/dist/plugin/baseCompiler.d.cts +33 -0
  18. package/dist/plugin/baseLoader.d.cts +78 -0
  19. package/dist/plugin/baseStats.d.cts +139 -0
  20. package/dist/plugin/index.d.cts +7 -0
  21. package/dist/plugin/internal-rules.d.cts +4 -0
  22. package/dist/plugin/plugin.d.cts +159 -0
  23. package/dist/plugin/rspack.d.cts +37 -0
  24. package/dist/plugin/webpack.d.cts +13 -0
  25. package/dist/rule/code/E1001.d.cts +3 -0
  26. package/dist/rule/code/E1002.d.cts +3 -0
  27. package/dist/rule/code/E1003.d.cts +3 -0
  28. package/dist/rule/code/E1004.d.cts +3 -0
  29. package/dist/rule/code/E1005.d.cts +3 -0
  30. package/dist/rule/code/E1006.d.cts +3 -0
  31. package/dist/rule/code/E1007.d.cts +3 -0
  32. package/dist/rule/code/E1008.d.cts +3 -0
  33. package/dist/rule/code/E1009.d.cts +3 -0
  34. package/dist/rule/code/index.d.cts +33 -0
  35. package/dist/rule/code/type.d.cts +27 -0
  36. package/dist/rule/data.d.cts +217 -0
  37. package/dist/rule/index.d.cts +2 -0
  38. package/dist/sdk/chunk.d.cts +142 -0
  39. package/dist/sdk/config.d.cts +12 -0
  40. package/dist/sdk/context.d.cts +23 -0
  41. package/dist/sdk/envinfo.d.cts +19 -0
  42. package/dist/sdk/hooks.d.cts +14 -0
  43. package/dist/sdk/index.d.cts +16 -0
  44. package/dist/sdk/instance.d.cts +110 -0
  45. package/dist/sdk/loader.d.cts +70 -0
  46. package/dist/sdk/module.d.cts +405 -0
  47. package/dist/sdk/package.d.cts +124 -0
  48. package/dist/sdk/plugin.d.cts +21 -0
  49. package/dist/sdk/process.d.cts +10 -0
  50. package/dist/sdk/resolver.d.cts +52 -0
  51. package/dist/sdk/result.d.cts +42 -0
  52. package/dist/sdk/server/apis/alerts.d.cts +30 -0
  53. package/dist/sdk/server/apis/graph.d.cts +49 -0
  54. package/dist/sdk/server/apis/index.d.cts +189 -0
  55. package/dist/sdk/server/apis/loader.d.cts +53 -0
  56. package/dist/sdk/server/apis/pagination.d.cts +11 -0
  57. package/dist/sdk/server/apis/plugin.d.cts +19 -0
  58. package/dist/sdk/server/apis/project.d.cts +18 -0
  59. package/dist/sdk/server/apis/resolver.d.cts +18 -0
  60. package/dist/sdk/server/index.d.cts +24 -0
  61. package/dist/sdk/statement.d.cts +178 -0
  62. package/dist/sdk/summary.d.cts +18 -0
  63. package/dist/sdk/treeShaking.d.cts +152 -0
  64. package/dist/thirdparty.d.cts +2 -0
  65. package/package.json +10 -5
@@ -0,0 +1,105 @@
1
+ import type { ArrayToUnion, UnionToTuple } from '../common';
2
+ import type { ErrorLevel as Severity } from '../error';
3
+ import type { Hooks, RuntimeContext } from '../sdk';
4
+ import type { ReportData, Diagnostic } from './diagnostic';
5
+ import type { RuleMessage } from '../rule';
6
+ /** Error level */
7
+ export type SeverityString = keyof typeof Severity;
8
+ /** Error level */
9
+ export type SeverityInput = SeverityString | 'off' | 'on';
10
+ /** Rule configuration */
11
+ export type DefaultRuleConfig = any;
12
+ export type DefaultRuleTitle = string;
13
+ /** Rule check context */
14
+ export interface RuleCheckerContext<Config = DefaultRuleConfig> extends RuntimeContext {
15
+ ruleConfig: Config;
16
+ /**
17
+ * Report an error
18
+ * @param {any} error - error data
19
+ * @param {any} replacer - replace the original error
20
+ */
21
+ report(error: ReportData, replacer?: any): void;
22
+ }
23
+ /**
24
+ * we shouldn't report any errors when the rule check end, so remove the report function on the context.
25
+ */
26
+ export interface RuleCheckerContextForCheckEnd<Config = DefaultRuleConfig> {
27
+ /**
28
+ * data of the rule.
29
+ */
30
+ data: Omit<RuleCheckerContext<Config>, 'report'>;
31
+ /**
32
+ * the validate result for `all` rules.
33
+ */
34
+ validateResult: ValidateResult;
35
+ /**
36
+ * sdk hooks for rule context when check end.
37
+ *
38
+ * rules checking always run after builder compile done, so it must be a part of SDK.Hooks.
39
+ */
40
+ hooks: Pick<Hooks, 'afterSaveManifest'>;
41
+ }
42
+ export interface InternalRuleCheckerContextForCheckEnd<Config = DefaultRuleConfig> extends Omit<RuleCheckerContextForCheckEnd<Config>, 'data'> {
43
+ data: Omit<RuleCheckerContext<Config>, 'report' | 'ruleConfig'>;
44
+ }
45
+ export type CheckCallback<Config = DefaultRuleConfig> = (context: RuleCheckerContext<Config>) => void | Promise<void>;
46
+ export type OnCheckEndCallback<Config = DefaultRuleConfig> = (context: RuleCheckerContextForCheckEnd<Config>) => void | Promise<void>;
47
+ /** Rule Metadata */
48
+ export interface RuleMeta<Config = DefaultRuleConfig, Title extends DefaultRuleTitle = DefaultRuleTitle> extends Pick<RuleMessage, 'code' | 'category'> {
49
+ title: Title;
50
+ severity: Severity;
51
+ /** Detailed document link */
52
+ referenceUrl?: string;
53
+ /** Default configuration */
54
+ defaultConfig?: Config;
55
+ }
56
+ export interface BaseRuleData<Config> {
57
+ check: CheckCallback<Config>;
58
+ /**
59
+ * execute when all rules check end.
60
+ */
61
+ onCheckEnd?: OnCheckEndCallback<Config>;
62
+ }
63
+ /** Rule Data */
64
+ export interface RuleData<Config = DefaultRuleConfig, Title extends DefaultRuleTitle = DefaultRuleTitle> extends BaseRuleData<Config> {
65
+ meta: RuleMeta<Config, Title>;
66
+ }
67
+ /** External Rule Metadata */
68
+ export interface ExtendRuleMeta<Config = DefaultRuleConfig, Title extends DefaultRuleTitle = DefaultRuleTitle> extends Omit<RuleMeta<Config, Title>, 'severity' | 'code'> {
69
+ severity: SeverityString;
70
+ }
71
+ /** External rule data */
72
+ export interface ExtendRuleData<Config = DefaultRuleConfig, Title extends DefaultRuleTitle = DefaultRuleTitle> extends BaseRuleData<Config> {
73
+ meta: ExtendRuleMeta<Config, Title>;
74
+ }
75
+ /** rule constructor */
76
+ export type RuleConstructor<Title extends DefaultRuleTitle, Config = DefaultRuleConfig> = () => RuleData<Config, Title>;
77
+ /** External rule constructor */
78
+ export type ExtendRuleConstructor<Title extends DefaultRuleTitle, Config = DefaultRuleConfig> = () => ExtendRuleData<Config, Title>;
79
+ /** Rule configuration */
80
+ export type RulesMap = Record<string, RuleConfigItem>;
81
+ /** Single rule configuration */
82
+ export type RuleConfigItem<T = unknown> = SeverityInput | [SeverityInput, T];
83
+ /** Verification result */
84
+ export interface ValidateResult {
85
+ errors: Diagnostic[];
86
+ replace: any[];
87
+ }
88
+ /** Verifier options */
89
+ export interface Options<Extends extends ExtendRuleData[] = [], InternalRules extends RuleData[] = [], _Extends = UnionToTuple<ArrayToUnion<[...Extends]>>> {
90
+ rules?: InferRulesConfig<_Extends extends ExtendRuleData[] ? _Extends : Extends> & InferRulesConfig<InternalRules>;
91
+ level?: SeverityString;
92
+ extends?: Extends;
93
+ }
94
+ type InferRuleTitle<T extends ExtendRuleData | RuleData> = T['meta']['title'] extends `${infer R}` ? R : string;
95
+ type InferRulesTitles<T extends (ExtendRuleData | RuleData)[]> = ArrayToUnion<{
96
+ [K in keyof T]: InferRuleTitle<T[K]>;
97
+ }>;
98
+ type InferRuleConfigByTitle<T extends (ExtendRuleData | RuleData)[], Title extends string> = {
99
+ [K in keyof T]: InferRuleTitle<T[K]> extends Title ? InferRuleConfig<T[K]> : never;
100
+ }[number];
101
+ export type InferRuleConfig<T> = T extends ExtendRuleData<infer P1> ? P1 : T extends RuleData<infer P2> ? P2 : any;
102
+ export type InferRulesConfig<T extends (ExtendRuleData | RuleData)[]> = {
103
+ [K in InferRulesTitles<T>]?: RuleConfigItem<InferRuleConfigByTitle<T, K>>;
104
+ } & Record<string, RuleConfigItem | undefined>;
105
+ export {};
@@ -0,0 +1,9 @@
1
+ export declare enum LogLevel {
2
+ Silent = 0,
3
+ Error = 1,
4
+ Warning = 2,
5
+ Info = 3,
6
+ Debug = 4,
7
+ Verbose = 5
8
+ }
9
+ export type LogLevelName = keyof typeof LogLevel;
@@ -0,0 +1,68 @@
1
+ import { PlainObject, ObjectPropertyNames } from './common';
2
+ import { StoreData } from './sdk';
3
+ export interface RsdoctorManifest {
4
+ client: RsdoctorManifestClient;
5
+ /**
6
+ * manifest url in tos, used by inner-rsdoctor.
7
+ */
8
+ cloudManifestUrl?: string;
9
+ /**
10
+ * manifest data shareding file urls in tos, used by inner-rsdoctor.
11
+ */
12
+ cloudData?: Record<keyof RsdoctorManifestData, string[] | string>;
13
+ data: RsdoctorManifestData;
14
+ /** current build name */
15
+ name?: string;
16
+ /**
17
+ * multiple build info
18
+ */
19
+ series?: RsdoctorManifestSeriesData[];
20
+ }
21
+ export interface RsdoctorManifestSeriesData {
22
+ name: string;
23
+ path: string;
24
+ stage: number;
25
+ origin?: string;
26
+ }
27
+ export interface RsdoctorManifestWithShardingFiles extends Omit<RsdoctorManifest, 'data'> {
28
+ data: Record<keyof RsdoctorManifestData, string[] | string>;
29
+ /**
30
+ * manifest data shareding file urls in tos, used by inner-rsdoctor.
31
+ */
32
+ cloudData?: Record<keyof RsdoctorManifestData, string[] | string>;
33
+ /**
34
+ * local server will proxy the manifest content and inject `__LOCAL__SERVER__: true`
35
+ */
36
+ __LOCAL__SERVER__?: boolean;
37
+ __SOCKET__PORT__?: string;
38
+ __SOCKET__URL__?: string;
39
+ }
40
+ export interface RsdoctorManifestClient {
41
+ enableRoutes: RsdoctorManifestClientRoutes[];
42
+ }
43
+ export interface RsdoctorManifestData extends StoreData {
44
+ }
45
+ export declare enum RsdoctorManifestClientRoutes {
46
+ Overall = "Overall",
47
+ WebpackLoaders = "Compile.WebpackLoaders",
48
+ ModuleResolve = "Compile.ModuleResolve",
49
+ WebpackPlugins = "Compile.WebpackPlugins",
50
+ BundleSize = "Bundle.BundleSize",
51
+ ModuleGraph = "Bundle.ModuleGraph",
52
+ TreeShaking = "Bundle.TreeShaking"
53
+ }
54
+ export declare enum RsdoctorManifestClientConstant {
55
+ WindowPropertyForManifestUrl = "__DEVTOOLS_MANIFEST_URL__"
56
+ }
57
+ export type RsdoctorManifestObjectKeys = NonNullable<ObjectPropertyNames<RsdoctorManifestData>>;
58
+ export type RsdoctorManifestRootKeys = keyof RsdoctorManifestData;
59
+ export type RsdoctorManifestMappingKeys = {
60
+ [K in RsdoctorManifestObjectKeys]: RsdoctorManifestData[K] extends PlainObject ? RsdoctorManifestData[K] extends Array<unknown> ? never : string extends keyof RsdoctorManifestData[K] ? never : keyof RsdoctorManifestData[K] extends string ? `${K}.${keyof RsdoctorManifestData[K]}` : never : never;
61
+ }[RsdoctorManifestObjectKeys] | RsdoctorManifestRootKeys;
62
+ export type InferManifestDataValue<T> = T extends `${infer Scope}.${infer Child}` ? Scope extends RsdoctorManifestObjectKeys ? Child extends keyof RsdoctorManifestData[Scope] ? RsdoctorManifestData[Scope][Child] : never : never : T extends RsdoctorManifestRootKeys ? RsdoctorManifestData[T] : never;
63
+ export interface ManifestDataLoader {
64
+ loadManifest(): Promise<RsdoctorManifest | RsdoctorManifestWithShardingFiles>;
65
+ loadData: {
66
+ <T extends RsdoctorManifestMappingKeys>(key: T): Promise<void | InferManifestDataValue<T>>;
67
+ };
68
+ }
@@ -0,0 +1,7 @@
1
+ import { StatsModule } from './plugin/baseStats';
2
+ export type ChunkModuleMap = {
3
+ isAsset: boolean;
4
+ label: string;
5
+ modules: StatsModule[];
6
+ };
7
+ export type Modules = Record<string | number, ChunkModuleMap>;
@@ -0,0 +1,33 @@
1
+ import type { Compiler, Compilation, Stats, StatsError, RuleSetRule } from 'webpack';
2
+ import type { Compiler as RspackCompiler, Compilation as RspackCompilation, Stats as RspackStats, RuleSetRule as RspackRuleSetRule, MultiCompiler } from '@rspack/core';
3
+ type RspackCompilerWrapper = RspackCompiler & Pick<MultiCompiler, keyof Omit<MultiCompiler, 'hooks' | 'options' | 'isChild'>>;
4
+ type RspackStatsWrapper = any extends RspackStats ? never : RspackStats;
5
+ type RspackRuleSetRuleWrapper = any extends RspackRuleSetRule ? never : RspackRuleSetRule;
6
+ export type BaseCompilerType<T extends 'rspack' | 'webpack' = 'webpack'> = T extends 'rspack' ? RspackCompilerWrapper : Compiler;
7
+ export type BaseCompiler = BaseCompilerType | BaseCompilerType<'rspack'>;
8
+ export type BaseCompilationType<T extends 'rspack' | 'webpack' = 'webpack'> = T extends 'rspack' ? Compilation : RspackCompilation;
9
+ export type BaseCompilation = BaseCompilationType | BaseCompilationType<'rspack'>;
10
+ export type BaseStats = Stats | RspackStatsWrapper;
11
+ export interface JsStatsError {
12
+ message: string;
13
+ formatted?: string;
14
+ title?: string;
15
+ }
16
+ export interface JsStatsWarning extends JsRspackError {
17
+ message: string;
18
+ formatted?: string;
19
+ }
20
+ export interface JsRspackError {
21
+ name?: string;
22
+ message: string;
23
+ moduleIdentifier?: string;
24
+ loc?: string;
25
+ file?: string;
26
+ stack?: string;
27
+ hideStack?: boolean;
28
+ }
29
+ export type BuildError = JsStatsError | StatsError;
30
+ export type BuildWarning = JsStatsWarning | StatsError;
31
+ export type BuildRuleSetRules = (false | '' | 0 | RuleSetRule | '...' | null | undefined)[];
32
+ export type BuildRuleSetRule = RuleSetRule | RspackRuleSetRuleWrapper;
33
+ export {};
@@ -0,0 +1,78 @@
1
+ import type { RuleSetRule as WebpackRuleSetRule, Configuration as WebpackConfiguration } from 'webpack';
2
+ import type { Configuration as RspackConfiguration, RuleSetRule as RspackRuleSetRule } from '@rspack/core';
3
+ export interface SourceMap {
4
+ version: number;
5
+ sources: string[];
6
+ mappings: string;
7
+ file?: string;
8
+ sourceRoot?: string;
9
+ sourcesContent?: string[];
10
+ names?: string[];
11
+ }
12
+ type RspackConfigurationWrapper = any extends RspackConfiguration ? never : RspackConfiguration;
13
+ type RspackRuleSetRuleWrapper = any extends RspackRuleSetRule ? never : RspackRuleSetRule;
14
+ export type RuleSetRule = RspackRuleSetRuleWrapper | WebpackRuleSetRule;
15
+ export type Configuration = WebpackConfiguration | RspackConfigurationWrapper;
16
+ declare interface AdditionalData {
17
+ [index: string]: any;
18
+ webpackAST: object;
19
+ }
20
+ export interface LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> {
21
+ (this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | SourceMap): string | void | Buffer | Promise<string | Buffer>;
22
+ }
23
+ export interface LoaderContext<OptionsType = {}> {
24
+ _module?: {
25
+ layer: string;
26
+ };
27
+ _compilation?: {
28
+ name: string;
29
+ };
30
+ getOptions(schema?: any): OptionsType;
31
+ /**
32
+ * Make this loader result cacheable. By default it's cacheable.
33
+ * A cacheable loader must have a deterministic result, when inputs and dependencies haven't changed.
34
+ * This means the loader shouldn't have other dependencies than specified with this.addDependency.
35
+ * Most loaders are deterministic and cacheable.
36
+ */
37
+ cacheable(flag?: boolean): void;
38
+ callback: (err?: null | Error, content?: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => void;
39
+ /**
40
+ * The resource path.
41
+ * In the example: "/abc/resource.js"
42
+ */
43
+ resourcePath: string;
44
+ query: string | OptionsType;
45
+ /**
46
+ * The resource query string.
47
+ * Example: "?query"
48
+ */
49
+ resourceQuery: string;
50
+ /**
51
+ * The resource fragment.
52
+ * Example: "#frag"
53
+ */
54
+ resourceFragment: string;
55
+ /**
56
+ * The resource inclusive query and fragment.
57
+ * Example: "/abc/resource.js?query#frag"
58
+ */
59
+ resource: string;
60
+ async(): (err?: Error | null, content?: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => void;
61
+ /**
62
+ * Target of compilation.
63
+ * Example: "web"
64
+ */
65
+ target: string;
66
+ loaderIndex: number;
67
+ }
68
+ export declare interface PitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> {
69
+ (this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object): string | void | Buffer | Promise<string | Buffer>;
70
+ }
71
+ export interface RspackPitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> {
72
+ (this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object): string | void | Buffer | Promise<string | Buffer>;
73
+ }
74
+ export type LoaderDefinition<T, R> = LoaderDefinitionFunction<T, R> & {
75
+ raw?: false;
76
+ pitch?: PitchLoaderDefinitionFunction<T> | RspackPitchLoaderDefinitionFunction<T>;
77
+ };
78
+ export {};
@@ -0,0 +1,139 @@
1
+ import { BaseCompilation } from './baseCompiler';
2
+ interface StatsOptionsObj {
3
+ all?: boolean;
4
+ preset?: 'normal' | 'none' | 'verbose' | 'errors-only' | 'errors-warnings';
5
+ assets?: boolean;
6
+ chunks?: boolean;
7
+ modules?: boolean;
8
+ entrypoints?: boolean;
9
+ warnings?: boolean;
10
+ warningsCount?: boolean;
11
+ errors?: boolean;
12
+ errorsCount?: boolean;
13
+ colors?: boolean;
14
+ chunkModules?: boolean;
15
+ hash?: boolean;
16
+ ids?: boolean;
17
+ orphanModules?: boolean;
18
+ runtimeModules?: boolean;
19
+ cachedModules?: boolean;
20
+ nestedModules?: boolean;
21
+ optimizationBailout?: boolean;
22
+ /** Rspack not support below opts */
23
+ cachedAssets?: boolean;
24
+ groupAssetsByInfo?: boolean;
25
+ groupAssetsByPath?: boolean;
26
+ groupAssetsByChunk?: boolean;
27
+ groupAssetsByExtension?: boolean;
28
+ groupAssetsByEmitStatus?: boolean;
29
+ }
30
+ /** webpack not support boolean or string */
31
+ type StatsOptions = StatsOptionsObj;
32
+ interface StatsAssetInfo {
33
+ development?: boolean;
34
+ }
35
+ export interface StatsAsset {
36
+ type: string;
37
+ name: string;
38
+ size: number;
39
+ chunks?: (string | number)[];
40
+ chunkNames?: Array<string | number>;
41
+ info: StatsAssetInfo;
42
+ }
43
+ interface StatsError {
44
+ message: string;
45
+ formatted?: string;
46
+ }
47
+ type KnownStatsModuleIssuer = {
48
+ identifier?: string;
49
+ name?: string;
50
+ id?: string | number | null;
51
+ moduleId?: string | number | null;
52
+ };
53
+ export interface StatsModule {
54
+ type?: string;
55
+ moduleType?: string;
56
+ identifier?: string;
57
+ moduleIdentifier?: string;
58
+ name?: string;
59
+ moduleName?: string;
60
+ id?: string | number;
61
+ chunks?: Array<string | number>;
62
+ size?: number;
63
+ issuer?: string;
64
+ issuerName?: string;
65
+ assets?: Array<string | number>;
66
+ reasons?: Array<StatsModuleReason>;
67
+ source?: string | Buffer;
68
+ orphanModules?: Array<StatsModule>;
69
+ runtimeModules?: Array<StatsModule>;
70
+ cachedModules?: Array<StatsModule>;
71
+ nestedModules?: Array<StatsModule>;
72
+ nameForCondition?: string;
73
+ depth?: number | string;
74
+ loc?: string;
75
+ modules?: StatsModule[];
76
+ layer?: string;
77
+ issuerPath?: Record<string, any>[] | KnownStatsModuleIssuer[];
78
+ optimizationBailout?: string[];
79
+ }
80
+ export interface StatsModuleReason {
81
+ moduleIdentifier?: string;
82
+ moduleName?: string;
83
+ moduleId?: string | number;
84
+ type?: string;
85
+ userRequest?: string;
86
+ children?: StatsModuleReason[];
87
+ loc?: string;
88
+ }
89
+ export interface JSStatsChunkGroup {
90
+ name?: string;
91
+ assets?: {
92
+ name: string;
93
+ size?: number;
94
+ }[];
95
+ chunks?: (string | number)[];
96
+ assetsSize?: number;
97
+ }
98
+ export type StatsChunkGroup = JSStatsChunkGroup;
99
+ export interface StatsCompilation {
100
+ version?: string;
101
+ /** rspack version */
102
+ rspackVersion?: string;
103
+ name?: string;
104
+ hash?: string;
105
+ time?: number;
106
+ builtAt?: number;
107
+ publicPath?: string;
108
+ assetsByChunkName?: Record<string, string[]>;
109
+ filteredModules?: number;
110
+ assets?: Array<StatsAsset>;
111
+ modules?: Array<StatsModule>;
112
+ chunks?: Array<StatsChunk>;
113
+ entrypoints?: Record<string, StatsChunkGroup>;
114
+ children?: StatsCompilation[];
115
+ errors?: Array<StatsError>;
116
+ errorsCount?: number;
117
+ warnings?: Array<StatsError>;
118
+ warningsCount?: number;
119
+ outputPath?: string;
120
+ }
121
+ interface StatsChunk {
122
+ type?: string;
123
+ files?: Array<string>;
124
+ id?: string | number;
125
+ entry: boolean;
126
+ initial: boolean;
127
+ names?: Array<string>;
128
+ size: number;
129
+ modules?: Array<StatsModule>;
130
+ }
131
+ export declare class Stats {
132
+ constructor(statsJson: any);
133
+ compilation: BaseCompilation;
134
+ hasErrors(): boolean;
135
+ hasWarnings(): boolean;
136
+ toJson(opts?: StatsOptions): StatsCompilation;
137
+ toString(opts?: StatsOptions): string;
138
+ }
139
+ export {};
@@ -0,0 +1,7 @@
1
+ export * from './baseCompiler';
2
+ export * from './baseStats';
3
+ export * from './plugin';
4
+ export * from './baseLoader';
5
+ export * from './rspack';
6
+ export * from './internal-rules';
7
+ export * from './webpack';
@@ -0,0 +1,4 @@
1
+ import { Linter } from '../index';
2
+ export type InternalRules = Linter.RuleData[];
3
+ export type InternalRuleId = 'E1001' | 'E1002' | 'E1003' | 'E1004' | 'E1005' | 'E1006' | 'E1007';
4
+ export type InternalRuleName = 'duplicate-package' | 'cross-chunks-package' | 'default-import-check' | 'ecma-version-check' | 'loader-performance-optimization' | 'module-mixed-chunks' | 'tree-shaking-side-effects-only';
@@ -0,0 +1,159 @@
1
+ import { Common, Config, Linter as LinterType, SDK } from '..';
2
+ import { InternalRules } from './internal-rules';
3
+ export interface RsdoctorWebpackPluginFeatures {
4
+ /**
5
+ * turn off it if you need not to analyze the executions of webpack loaders.
6
+ * @default true
7
+ */
8
+ loader?: boolean;
9
+ /**
10
+ * turn off it if you need not to analyze the executions of webpack plugins.
11
+ * @default true
12
+ */
13
+ plugins?: boolean;
14
+ /**
15
+ * turn off it if you need not to analyze the executions of resolver.
16
+ * @default false
17
+ */
18
+ resolver?: boolean;
19
+ /**
20
+ * turn off it if you need not to analyze the output bundle.
21
+ * @default true
22
+ */
23
+ bundle?: boolean;
24
+ /**
25
+ * turn off it if you need not to analyze the result of tree shaking.
26
+ * @default false
27
+ */
28
+ treeShaking?: boolean;
29
+ /**
30
+ * turn on it if you just use lite mode. This mode do not have source codes.
31
+ * @default false
32
+ */
33
+ lite?: boolean;
34
+ }
35
+ export interface RsdoctorPluginOptionsNormalized<Rules extends LinterType.ExtendRuleData[] = []> extends Common.DeepRequired<Omit<RsdoctorWebpackPluginOptions<Rules>, 'sdkInstance' | 'linter' | 'output' | 'supports' | 'port' | 'brief' | 'mode'>> {
36
+ features: Common.DeepRequired<RsdoctorWebpackPluginFeatures>;
37
+ linter: Required<LinterType.Options<Rules, InternalRules>>;
38
+ sdkInstance?: SDK.RsdoctorBuilderSDKInstance;
39
+ output: {
40
+ mode: keyof typeof SDK.IMode;
41
+ reportCodeType: SDK.ToDataType;
42
+ reportDir: string;
43
+ options: Config.BriefModeOptions | Config.NormalModeOptions;
44
+ };
45
+ port?: number;
46
+ supports: ISupport;
47
+ }
48
+ interface ISupport {
49
+ banner?: boolean;
50
+ parseBundle?: boolean;
51
+ generateTileGraph?: boolean;
52
+ gzip?: boolean;
53
+ }
54
+ interface OutputBaseConfig {
55
+ /**
56
+ * The directory where the report files will be output.
57
+ */
58
+ reportDir?: string;
59
+ /**
60
+ * Control the Rsdoctor reporter codes records.
61
+ */
62
+ reportCodeType?: IReportCodeType | undefined | NewReportCodeType;
63
+ /**
64
+ * @deprecated
65
+ * Configure whether to compress data.
66
+ * @default false
67
+ *
68
+ */
69
+ compressData?: boolean;
70
+ }
71
+ export type IReportCodeType = {
72
+ noModuleSource?: boolean;
73
+ noAssetsAndModuleSource?: boolean;
74
+ noCode?: boolean;
75
+ };
76
+ export type NewReportCodeType = 'noModuleSource' | 'noAssetsAndModuleSource' | 'noCode';
77
+ export interface RsdoctorWebpackPluginOptions<Rules extends LinterType.ExtendRuleData[]> {
78
+ /** Checker configuration */
79
+ linter?: LinterType.Options<Rules, InternalRules>;
80
+ /**
81
+ * the switch for the Rsdoctor features.
82
+ */
83
+ features?: RsdoctorWebpackPluginFeatures | Array<keyof RsdoctorWebpackPluginFeatures>;
84
+ /**
85
+ * @deprecated Use `output.mode` instead, if you're using `lite` mode, please use `output.reportCodeType: 'noCode' or 'noAssetsAndModuleSource'` instead.
86
+ * Rsdoctor mode option:
87
+ * - normal: Refers to the normal mode.
88
+ * - brief: Refers to the brief mode, which only displays the results of the duration analysis and build artifact analysis
89
+ * and does not display any part of the code.
90
+ */
91
+ mode?: 'brief' | 'normal' | 'lite';
92
+ /**
93
+ * configuration of the interceptor for webpack loaders. TODO: delete this options.
94
+ * @description worked when the `features.loader === true`.
95
+ */
96
+ loaderInterceptorOptions?: {
97
+ /**
98
+ * loaders which you want to skip it (will not report the target loader data when webpack compile).
99
+ */
100
+ skipLoaders?: string[];
101
+ };
102
+ /**
103
+ * turn on it if you don't need to see profile in browser.
104
+ * @default false
105
+ */
106
+ disableClientServer?: boolean;
107
+ /**
108
+ * sdk instance of outside.
109
+ */
110
+ sdkInstance?: SDK.RsdoctorBuilderSDKInstance;
111
+ /**
112
+ * Whether to turn on some characteristic analysis capabilities, such as: the support for the BannerPlugin.
113
+ */
114
+ supports?: ISupport;
115
+ /**
116
+ * The port of the Rsdoctor server.
117
+ */
118
+ port?: number;
119
+ /**
120
+ * Options to control the log printing.
121
+ */
122
+ printLog?: SDK.IPrintLog;
123
+ /**
124
+ * @deprecated Use `output.options.htmlOptions` instead.
125
+ * Please use the output.options to set the brief options, BriefModeOptions.
126
+ * Options to control brief mode reports.
127
+ */
128
+ brief?: Config.BriefConfig;
129
+ /**
130
+ * The name of inner rsdoctor's client package, used by inner-rsdoctor.
131
+ * @default false
132
+ */
133
+ innerClientPath?: string;
134
+ output?: Config.IOutput<'brief' | 'normal'>;
135
+ }
136
+ type ReportCodeTypeByMode<T extends 'brief' | 'normal'> = T extends 'brief' ? undefined | 'noCode' | {
137
+ noCode?: boolean;
138
+ } : T extends 'normal' ? IReportCodeType | undefined | NewReportCodeType : IReportCodeType | undefined | NewReportCodeType;
139
+ export interface NormalModeOptions {
140
+ type?: never;
141
+ }
142
+ interface NormalModeConfig extends Omit<OutputBaseConfig, 'reportCodeType' | 'mode'> {
143
+ mode?: 'normal';
144
+ reportCodeType?: ReportCodeTypeByMode<'normal'>;
145
+ options?: NormalModeOptions;
146
+ }
147
+ export interface BriefModeOptions {
148
+ /** Output type, supports HTML and JSON */
149
+ type?: Array<'html'>;
150
+ /** HTML output related configuration */
151
+ htmlOptions?: Config.BriefConfig;
152
+ }
153
+ export interface BriefModeConfig extends Omit<OutputBaseConfig, 'reportCodeType' | 'mode'> {
154
+ mode?: 'brief';
155
+ reportCodeType?: ReportCodeTypeByMode<'brief'>;
156
+ options?: BriefModeOptions;
157
+ }
158
+ export type IOutput<T extends 'brief' | 'normal' | undefined = undefined> = T extends 'brief' ? BriefModeConfig : T extends 'normal' ? NormalModeConfig : BriefModeConfig | NormalModeConfig | OutputBaseConfig;
159
+ export {};
@@ -0,0 +1,37 @@
1
+ import type { RsdoctorPluginData, NormalModuleFactory, LoaderDefinitionFunction, ModuleGraph, Dependency } from '@rspack/core';
2
+ export type RspackNormalModuleFactory = NormalModuleFactory;
3
+ export type RspackNativeAsset = RsdoctorPluginData.RsdoctorAsset;
4
+ export type RspackNativeChunkGraph = RsdoctorPluginData.RsdoctorChunkGraph;
5
+ export type RspackNativeModuleGraph = RsdoctorPluginData.RsdoctorModuleGraph;
6
+ export type RspackNativeChunk = RsdoctorPluginData.RsdoctorChunk;
7
+ export type RspackNativeModule = RsdoctorPluginData.RsdoctorModule;
8
+ export type RspackNativeSideEffect = RsdoctorPluginData.RsdoctorSideEffect;
9
+ export type RspackNativeExportInfo = RsdoctorPluginData.RsdoctorExportInfo;
10
+ export type RspackNativeVariable = RsdoctorPluginData.RsdoctorVariable;
11
+ export type RspackNativeDependency = RsdoctorPluginData.RsdoctorDependency;
12
+ export type RspackNativeEntrypoint = RsdoctorPluginData.RsdoctorEntrypoint;
13
+ export type RspackNativeStatement = RsdoctorPluginData.RsdoctorStatement;
14
+ export type RspackNativeSourceRange = RsdoctorPluginData.RsdoctorSourceRange;
15
+ export type RspackNativeSourcePosition = RsdoctorPluginData.RsdoctorSourcePosition;
16
+ export type RspackNativeModuleGraphModule = RsdoctorPluginData.RsdoctorModuleGraphModule;
17
+ export type RspackNativeAssetPatch = RsdoctorPluginData.RsdoctorAssetPatch;
18
+ export type RspackNativeModuleIdsPatch = RsdoctorPluginData.RsdoctorModuleIdsPatch;
19
+ export type RspackNativeChunkModules = RsdoctorPluginData.RsdoctorChunkModules;
20
+ export type RspackNativeModuleOriginalSource = RsdoctorPluginData.RsdoctorModuleOriginalSource;
21
+ export type RspackNativeModuleSourcePatch = RsdoctorPluginData.RsdoctorModuleSourcesPatch;
22
+ import rspack from '@rspack/core';
23
+ export type RspackExportsExperiments = typeof rspack.experiments;
24
+ export type RspackSourceMapInput = Parameters<LoaderDefinitionFunction>[1];
25
+ export type RspackEntryPoint = boolean | 'auto';
26
+ export interface RspackExportInfo {
27
+ used: boolean;
28
+ provideInfo: boolean | null | undefined;
29
+ useInfo: boolean | null | undefined;
30
+ canMangle: boolean;
31
+ }
32
+ export type RspackExportsInfo = ReturnType<ModuleGraph['getExportsInfo']>;
33
+ export interface RspackHarmonyImportSpecifierDependency extends Dependency {
34
+ getIds(graph: ModuleGraph): string[];
35
+ name: string;
36
+ userRequest: string;
37
+ }
@@ -0,0 +1,13 @@
1
+ import { Compiler, Compilation, LoaderDefinitionFunction, ModuleGraph, Dependency } from 'webpack';
2
+ type GetMapValue<M extends Map<any, any>> = M extends Map<string, infer V> ? V : never;
3
+ export type NormalModuleFactory = ReturnType<Compiler['createNormalModuleFactory']>;
4
+ export type SourceMapInput = Parameters<LoaderDefinitionFunction>[1];
5
+ export type EntryPoint = GetMapValue<Compilation['entrypoints']>;
6
+ export type ExportInfo = ReturnType<ModuleGraph['getExportInfo']>;
7
+ export type ExportsInfo = ReturnType<ModuleGraph['getExportsInfo']>;
8
+ export interface HarmonyImportSpecifierDependency extends Dependency {
9
+ getIds(graph: ModuleGraph): string[];
10
+ name: string;
11
+ userRequest: string;
12
+ }
13
+ export {};
@@ -0,0 +1,3 @@
1
+ import { RuleMessage } from './type';
2
+ export declare const code = "E1001";
3
+ export declare const message: RuleMessage;