@rsdoctor/core 1.5.12 → 2.0.0-alpha.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/build-utils/build/module-graph/index.cjs +4 -18
- package/dist/build-utils/build/module-graph/index.d.cts +0 -2
- package/dist/build-utils/build/module-graph/index.d.ts +0 -2
- package/dist/build-utils/build/module-graph/index.js +0 -2
- package/dist/build-utils/build/module-graph/rspack/transform.cjs +1 -1
- package/dist/build-utils/build/module-graph/rspack/transform.js +1 -1
- package/dist/build-utils/build/module-graph/transform.cjs +2 -3
- package/dist/build-utils/build/module-graph/transform.d.cts +1 -2
- package/dist/build-utils/build/module-graph/transform.d.ts +1 -2
- package/dist/build-utils/build/module-graph/transform.js +2 -3
- package/dist/build-utils/build/utils/parseBundle.cjs +1 -1
- package/dist/build-utils/build/utils/parseBundle.js +1 -1
- package/dist/build-utils/build/utils/plugin.cjs +1 -2
- package/dist/build-utils/build/utils/plugin.js +1 -2
- package/dist/inner-plugins/constants.cjs +1 -1
- package/dist/inner-plugins/constants.d.cts +1 -1
- package/dist/inner-plugins/constants.d.ts +1 -1
- package/dist/inner-plugins/constants.js +1 -1
- package/dist/inner-plugins/plugins/bundle.cjs +1 -17
- package/dist/inner-plugins/plugins/bundle.js +1 -17
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +3 -40
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.cts +4 -6
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.ts +4 -6
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +4 -41
- package/dist/inner-plugins/plugins/errors.cjs +3 -3
- package/dist/inner-plugins/plugins/errors.d.cts +1 -1
- package/dist/inner-plugins/plugins/errors.d.ts +1 -1
- package/dist/inner-plugins/plugins/errors.js +3 -3
- package/dist/inner-plugins/plugins/index.cjs +2 -9
- package/dist/inner-plugins/plugins/index.d.cts +0 -1
- package/dist/inner-plugins/plugins/index.d.ts +0 -1
- package/dist/inner-plugins/plugins/index.js +0 -1
- package/dist/inner-plugins/plugins/loader.cjs +1 -1
- package/dist/inner-plugins/plugins/loader.js +1 -1
- package/dist/inner-plugins/plugins/plugins.cjs +1 -1
- package/dist/inner-plugins/plugins/plugins.js +1 -1
- package/dist/inner-plugins/plugins/progress.cjs +14 -16
- package/dist/inner-plugins/plugins/progress.d.cts +1 -1
- package/dist/inner-plugins/plugins/progress.d.ts +1 -1
- package/dist/inner-plugins/plugins/progress.js +14 -16
- package/dist/inner-plugins/plugins/resolver.d.cts +1 -2
- package/dist/inner-plugins/plugins/resolver.d.ts +1 -2
- package/dist/inner-plugins/plugins/rules.cjs +3 -3
- package/dist/inner-plugins/plugins/rules.js +3 -3
- package/dist/inner-plugins/utils/config.cjs +0 -1
- package/dist/inner-plugins/utils/config.d.cts +1 -1
- package/dist/inner-plugins/utils/config.d.ts +1 -1
- package/dist/inner-plugins/utils/config.js +0 -1
- package/dist/inner-plugins/utils/loader.cjs +2 -2
- package/dist/inner-plugins/utils/loader.js +2 -2
- package/dist/inner-plugins/utils/normalize-config.d.cts +3 -6
- package/dist/inner-plugins/utils/normalize-config.d.ts +3 -6
- package/dist/rules/rules/cjs-require/index.cjs +2 -2
- package/dist/rules/rules/cjs-require/index.js +2 -2
- package/dist/rules/rules/esm-resolved-to-cjs/index.cjs +2 -17
- package/dist/rules/rules/esm-resolved-to-cjs/index.js +2 -17
- package/dist/rules/rules/loader-performance-optimization/index.cjs +1 -1
- package/dist/rules/rules/loader-performance-optimization/index.js +1 -1
- package/dist/rules/rules/module-mixed-chunks/index.cjs +1 -1
- package/dist/rules/rules/module-mixed-chunks/index.js +1 -1
- package/dist/rules/rules/side-effects-only-imports/index.cjs +1 -1
- package/dist/rules/rules/side-effects-only-imports/index.js +1 -1
- package/dist/types/plugin.d.cts +2 -2
- package/dist/types/plugin.d.ts +2 -2
- package/dist/types/rules.d.cts +4 -4
- package/dist/types/rules.d.ts +4 -4
- package/package.json +6 -7
- package/dist/build-utils/build/module-graph/treeShaking.cjs +0 -106
- package/dist/build-utils/build/module-graph/treeShaking.d.cts +0 -2
- package/dist/build-utils/build/module-graph/treeShaking.d.ts +0 -2
- package/dist/build-utils/build/module-graph/treeShaking.js +0 -73
- package/dist/build-utils/build/module-graph/webpack/transform.cjs +0 -170
- package/dist/build-utils/build/module-graph/webpack/transform.d.cts +0 -16
- package/dist/build-utils/build/module-graph/webpack/transform.d.ts +0 -16
- package/dist/build-utils/build/module-graph/webpack/transform.js +0 -124
- package/dist/inner-plugins/plugins/bundleTagPlugin.cjs +0 -84
- package/dist/inner-plugins/plugins/bundleTagPlugin.d.cts +0 -6
- package/dist/inner-plugins/plugins/bundleTagPlugin.d.ts +0 -6
- package/dist/inner-plugins/plugins/bundleTagPlugin.js +0 -51
|
@@ -148,7 +148,7 @@ class InternalLoaderPlugin extends external_base_cjs_namespaceObject.InternalBas
|
|
|
148
148
|
if (compiler.isChild()) return;
|
|
149
149
|
compiler.options.module.rules = this.getInterceptRules(compiler, compiler.options.module.rules);
|
|
150
150
|
this.sdk.addClientRoutes([
|
|
151
|
-
types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.
|
|
151
|
+
types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.Loaders
|
|
152
152
|
]);
|
|
153
153
|
} finally{
|
|
154
154
|
(0, logger_namespaceObject.timeEnd)('InternalLoaderPlugin.afterPlugins');
|
|
@@ -109,7 +109,7 @@ class InternalLoaderPlugin extends InternalBasePlugin {
|
|
|
109
109
|
if (compiler.isChild()) return;
|
|
110
110
|
compiler.options.module.rules = this.getInterceptRules(compiler, compiler.options.module.rules);
|
|
111
111
|
this.sdk.addClientRoutes([
|
|
112
|
-
Manifest.RsdoctorManifestClientRoutes.
|
|
112
|
+
Manifest.RsdoctorManifestClientRoutes.Loaders
|
|
113
113
|
]);
|
|
114
114
|
} finally{
|
|
115
115
|
timeEnd('InternalLoaderPlugin.afterPlugins');
|
|
@@ -48,7 +48,7 @@ class InternalPluginsPlugin extends external_base_cjs_namespaceObject.InternalBa
|
|
|
48
48
|
if (compiler.isChild()) return;
|
|
49
49
|
index_cjs_namespaceObject.Utils.interceptCompilerHooks(compiler, (name, hook)=>(0, external_utils_index_cjs_namespaceObject.interceptPluginHook)(this.sdk, name, hook));
|
|
50
50
|
this.sdk.addClientRoutes([
|
|
51
|
-
types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.
|
|
51
|
+
types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.Plugins
|
|
52
52
|
]);
|
|
53
53
|
} finally{
|
|
54
54
|
(0, logger_namespaceObject.timeEnd)('InternalPluginsPlugin.afterPlugins');
|
|
@@ -21,7 +21,7 @@ class InternalPluginsPlugin extends InternalBasePlugin {
|
|
|
21
21
|
if (compiler.isChild()) return;
|
|
22
22
|
Utils.interceptCompilerHooks(compiler, (name, hook)=>interceptPluginHook(this.sdk, name, hook));
|
|
23
23
|
this.sdk.addClientRoutes([
|
|
24
|
-
Manifest.RsdoctorManifestClientRoutes.
|
|
24
|
+
Manifest.RsdoctorManifestClientRoutes.Plugins
|
|
25
25
|
]);
|
|
26
26
|
} finally{
|
|
27
27
|
timeEnd('InternalPluginsPlugin.afterPlugins');
|
|
@@ -33,22 +33,20 @@ class InternalProgressPlugin extends external_base_cjs_namespaceObject.InternalB
|
|
|
33
33
|
apply(compiler) {
|
|
34
34
|
const { sdk, currentProgress } = this;
|
|
35
35
|
if (compiler.webpack && compiler.webpack.ProgressPlugin) {
|
|
36
|
-
const progress = new compiler.webpack.ProgressPlugin({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
logger_namespaceObject.logger.debug(e);
|
|
51
|
-
}
|
|
36
|
+
const progress = new compiler.webpack.ProgressPlugin((percentage, msg)=>{
|
|
37
|
+
currentProgress.percentage = percentage;
|
|
38
|
+
currentProgress.message = msg || '';
|
|
39
|
+
const api = types_namespaceObject.SDK.ServerAPI.APIExtends.GetCompileProgress;
|
|
40
|
+
try {
|
|
41
|
+
sdk.server.sendAPIDataToClient(api, {
|
|
42
|
+
req: {
|
|
43
|
+
api,
|
|
44
|
+
body: void 0
|
|
45
|
+
},
|
|
46
|
+
res: currentProgress
|
|
47
|
+
});
|
|
48
|
+
} catch (e) {
|
|
49
|
+
logger_namespaceObject.logger.debug(e);
|
|
52
50
|
}
|
|
53
51
|
});
|
|
54
52
|
progress.apply(compiler);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import type { Plugin } from '@rsdoctor/types';
|
|
3
3
|
import { InternalBasePlugin } from './base';
|
|
4
|
-
export declare class InternalProgressPlugin<T extends Plugin.BaseCompilerType<'
|
|
4
|
+
export declare class InternalProgressPlugin<T extends Plugin.BaseCompilerType<'rspack'>> extends InternalBasePlugin<T> {
|
|
5
5
|
readonly name = "progress";
|
|
6
6
|
protected currentProgress: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.APIExtends.GetCompileProgress>;
|
|
7
7
|
apply(compiler: T): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import type { Plugin } from '@rsdoctor/types';
|
|
3
3
|
import { InternalBasePlugin } from './base.js';
|
|
4
|
-
export declare class InternalProgressPlugin<T extends Plugin.BaseCompilerType<'
|
|
4
|
+
export declare class InternalProgressPlugin<T extends Plugin.BaseCompilerType<'rspack'>> extends InternalBasePlugin<T> {
|
|
5
5
|
readonly name = "progress";
|
|
6
6
|
protected currentProgress: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.APIExtends.GetCompileProgress>;
|
|
7
7
|
apply(compiler: T): void;
|
|
@@ -6,22 +6,20 @@ class InternalProgressPlugin extends InternalBasePlugin {
|
|
|
6
6
|
apply(compiler) {
|
|
7
7
|
const { sdk, currentProgress } = this;
|
|
8
8
|
if (compiler.webpack && compiler.webpack.ProgressPlugin) {
|
|
9
|
-
const progress = new compiler.webpack.ProgressPlugin({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
logger.debug(e);
|
|
24
|
-
}
|
|
9
|
+
const progress = new compiler.webpack.ProgressPlugin((percentage, msg)=>{
|
|
10
|
+
currentProgress.percentage = percentage;
|
|
11
|
+
currentProgress.message = msg || '';
|
|
12
|
+
const api = SDK.ServerAPI.APIExtends.GetCompileProgress;
|
|
13
|
+
try {
|
|
14
|
+
sdk.server.sendAPIDataToClient(api, {
|
|
15
|
+
req: {
|
|
16
|
+
api,
|
|
17
|
+
body: void 0
|
|
18
|
+
},
|
|
19
|
+
res: currentProgress
|
|
20
|
+
});
|
|
21
|
+
} catch (e) {
|
|
22
|
+
logger.debug(e);
|
|
25
23
|
}
|
|
26
24
|
});
|
|
27
25
|
progress.apply(compiler);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Plugin } from '@rsdoctor/types';
|
|
2
2
|
import { InternalBasePlugin } from './base';
|
|
3
|
-
import type { Compiler as WebpackCompiler } from 'webpack';
|
|
4
3
|
export declare class InternalResolverPlugin<T extends Plugin.BaseCompiler> extends InternalBasePlugin<T> {
|
|
5
4
|
readonly name = "resolver";
|
|
6
5
|
protected resolveDataMap: Map<string, {
|
|
@@ -9,5 +8,5 @@ export declare class InternalResolverPlugin<T extends Plugin.BaseCompiler> exten
|
|
|
9
8
|
request: string;
|
|
10
9
|
}>;
|
|
11
10
|
apply(compiler: T): void;
|
|
12
|
-
protected handleNormalModuleFactory: (normalModuleFactory: Plugin.RspackNormalModuleFactory
|
|
11
|
+
protected handleNormalModuleFactory: (normalModuleFactory: Plugin.RspackNormalModuleFactory) => void;
|
|
13
12
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Plugin } from '@rsdoctor/types';
|
|
2
2
|
import { InternalBasePlugin } from './base.js';
|
|
3
|
-
import type { Compiler as WebpackCompiler } from 'webpack';
|
|
4
3
|
export declare class InternalResolverPlugin<T extends Plugin.BaseCompiler> extends InternalBasePlugin<T> {
|
|
5
4
|
readonly name = "resolver";
|
|
6
5
|
protected resolveDataMap: Map<string, {
|
|
@@ -9,5 +8,5 @@ export declare class InternalResolverPlugin<T extends Plugin.BaseCompiler> exten
|
|
|
9
8
|
request: string;
|
|
10
9
|
}>;
|
|
11
10
|
apply(compiler: T): void;
|
|
12
|
-
protected handleNormalModuleFactory: (normalModuleFactory: Plugin.RspackNormalModuleFactory
|
|
11
|
+
protected handleNormalModuleFactory: (normalModuleFactory: Plugin.RspackNormalModuleFactory) => void;
|
|
13
12
|
}
|
|
@@ -54,16 +54,16 @@ class InternalRulesPlugin extends external_base_cjs_namespaceObject.InternalBase
|
|
|
54
54
|
}));
|
|
55
55
|
const errors = validateErrors.filter((item)=>'Error' === item.level);
|
|
56
56
|
const warnings = validateErrors.filter((item)=>'Warn' === item.level);
|
|
57
|
-
const
|
|
57
|
+
const toRspackError = (err)=>err.toError();
|
|
58
58
|
result.replace.forEach((item)=>{
|
|
59
59
|
if (Array.isArray(compilation.errors) && compilation.errors.includes(item)) (0, compat_namespaceObject.pull)(compilation.errors, item);
|
|
60
60
|
if (Array.isArray(compilation.warnings) && compilation.warnings.includes(item)) (0, compat_namespaceObject.pull)(compilation.warnings, item);
|
|
61
61
|
});
|
|
62
62
|
if (Array.isArray(compilation.errors)) errors.forEach((err)=>{
|
|
63
|
-
compilation.
|
|
63
|
+
compilation.errors.push(toRspackError(err));
|
|
64
64
|
});
|
|
65
65
|
if (Array.isArray(compilation.warnings)) warnings.forEach((err)=>{
|
|
66
|
-
compilation.warnings.push(
|
|
66
|
+
compilation.warnings.push(toRspackError(err));
|
|
67
67
|
});
|
|
68
68
|
this.sdk.reportError(validateErrors);
|
|
69
69
|
await linter.afterValidate({
|
|
@@ -27,16 +27,16 @@ class InternalRulesPlugin extends InternalBasePlugin {
|
|
|
27
27
|
}));
|
|
28
28
|
const errors = validateErrors.filter((item)=>'Error' === item.level);
|
|
29
29
|
const warnings = validateErrors.filter((item)=>'Warn' === item.level);
|
|
30
|
-
const
|
|
30
|
+
const toRspackError = (err)=>err.toError();
|
|
31
31
|
result.replace.forEach((item)=>{
|
|
32
32
|
if (Array.isArray(compilation.errors) && compilation.errors.includes(item)) pull(compilation.errors, item);
|
|
33
33
|
if (Array.isArray(compilation.warnings) && compilation.warnings.includes(item)) pull(compilation.warnings, item);
|
|
34
34
|
});
|
|
35
35
|
if (Array.isArray(compilation.errors)) errors.forEach((err)=>{
|
|
36
|
-
compilation.
|
|
36
|
+
compilation.errors.push(toRspackError(err));
|
|
37
37
|
});
|
|
38
38
|
if (Array.isArray(compilation.warnings)) warnings.forEach((err)=>{
|
|
39
|
-
compilation.warnings.push(
|
|
39
|
+
compilation.warnings.push(toRspackError(err));
|
|
40
40
|
});
|
|
41
41
|
this.sdk.reportError(validateErrors);
|
|
42
42
|
await linter.afterValidate({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RsdoctorRspackPluginOptions, RsdoctorRspackPluginOptionsNormalized } from '../../types';
|
|
2
2
|
import { Linter, Plugin, SDK } from '@rsdoctor/types';
|
|
3
|
-
export declare function normalizeUserConfig<Rules extends Linter.ExtendRuleData[]>(config?: Plugin.
|
|
3
|
+
export declare function normalizeUserConfig<Rules extends Linter.ExtendRuleData[]>(config?: Plugin.RsdoctorRspackPluginOptions<Rules>): Plugin.RsdoctorPluginOptionsNormalized<Rules>;
|
|
4
4
|
export declare const normalizeReportType: (reportCodeType: Plugin.IReportCodeType | Plugin.NewReportCodeType, mode: keyof typeof SDK.IMode) => SDK.ToDataType;
|
|
5
5
|
export declare function normalizeRspackUserOptions<Rules extends Linter.ExtendRuleData[]>(options: RsdoctorRspackPluginOptions<Rules>): RsdoctorRspackPluginOptionsNormalized<Rules>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RsdoctorRspackPluginOptions, RsdoctorRspackPluginOptionsNormalized } from '../../types/index.js';
|
|
2
2
|
import { Linter, Plugin, SDK } from '@rsdoctor/types';
|
|
3
|
-
export declare function normalizeUserConfig<Rules extends Linter.ExtendRuleData[]>(config?: Plugin.
|
|
3
|
+
export declare function normalizeUserConfig<Rules extends Linter.ExtendRuleData[]>(config?: Plugin.RsdoctorRspackPluginOptions<Rules>): Plugin.RsdoctorPluginOptionsNormalized<Rules>;
|
|
4
4
|
export declare const normalizeReportType: (reportCodeType: Plugin.IReportCodeType | Plugin.NewReportCodeType, mode: keyof typeof SDK.IMode) => SDK.ToDataType;
|
|
5
5
|
export declare function normalizeRspackUserOptions<Rules extends Linter.ExtendRuleData[]>(options: RsdoctorRspackPluginOptions<Rules>): RsdoctorRspackPluginOptionsNormalized<Rules>;
|
|
@@ -191,10 +191,10 @@ async function reportLoader(ctx, start, startHRTime, isPitch, sync, code, err, r
|
|
|
191
191
|
}
|
|
192
192
|
await Promise.all([
|
|
193
193
|
common_namespaceObject.Fetch.postJSON(`${host}${types_namespaceObject.SDK.ServerAPI.API.ReportLoader}`, loaderData, 8888).catch((err)=>{
|
|
194
|
-
logger_namespaceObject.logger.debug(`${err.message}`, '[
|
|
194
|
+
logger_namespaceObject.logger.debug(`${err.message}`, '[RspackPlugin.ReportLoader][error]');
|
|
195
195
|
}),
|
|
196
196
|
common_namespaceObject.Fetch.postJSON(`${host}${types_namespaceObject.SDK.ServerAPI.API.ReportSourceMap}`, sourceMapData, 8888).catch((err)=>{
|
|
197
|
-
logger_namespaceObject.logger.debug(`${err.message}`, '[
|
|
197
|
+
logger_namespaceObject.logger.debug(`${err.message}`, '[RspackPlugin.ReportSourceMap][error]');
|
|
198
198
|
})
|
|
199
199
|
]);
|
|
200
200
|
return loaderData;
|
|
@@ -149,10 +149,10 @@ async function reportLoader(ctx, start, startHRTime, isPitch, sync, code, err, r
|
|
|
149
149
|
}
|
|
150
150
|
await Promise.all([
|
|
151
151
|
Fetch.postJSON(`${host}${SDK.ServerAPI.API.ReportLoader}`, loaderData, 8888).catch((err)=>{
|
|
152
|
-
logger.debug(`${err.message}`, '[
|
|
152
|
+
logger.debug(`${err.message}`, '[RspackPlugin.ReportLoader][error]');
|
|
153
153
|
}),
|
|
154
154
|
Fetch.postJSON(`${host}${SDK.ServerAPI.API.ReportSourceMap}`, sourceMapData, 8888).catch((err)=>{
|
|
155
|
-
logger.debug(`${err.message}`, '[
|
|
155
|
+
logger.debug(`${err.message}`, '[RspackPlugin.ReportSourceMap][error]');
|
|
156
156
|
})
|
|
157
157
|
]);
|
|
158
158
|
return loaderData;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Config, Plugin, SDK } from '@rsdoctor/types';
|
|
2
2
|
import type { RuleSetCondition as RspackRuleSetCondition, RuleSetRule as RspackRuleSetRule } from '@rspack/core';
|
|
3
|
-
import { RuleSetCondition as WebpackRuleSetCondition, RuleSetConditionAbsolute as WebpackRuleSetConditionAbsolute, RuleSetRule as WebpackRuleSetRule } from 'webpack';
|
|
4
3
|
/**
|
|
5
4
|
* Process mode-specific configurations with priority logic
|
|
6
5
|
*/
|
|
@@ -22,9 +21,7 @@ export declare function convertReportCodeTypeObject(reportCodeType: any): Config
|
|
|
22
21
|
* properly serialized to JSON.
|
|
23
22
|
*
|
|
24
23
|
* @param item - The rule set condition to make serializable. Can be:
|
|
25
|
-
* - RspackRuleSetCondition: Rspack
|
|
26
|
-
* - WebpackRuleSetConditionAbsolute: Webpack absolute rule conditions
|
|
27
|
-
* - WebpackRuleSetCondition: Webpack rule conditions
|
|
24
|
+
* - RspackRuleSetCondition: Rspack rule conditions
|
|
28
25
|
* - void: Undefined or null values
|
|
29
26
|
*
|
|
30
27
|
* @example
|
|
@@ -36,5 +33,5 @@ export declare function convertReportCodeTypeObject(reportCodeType: any): Config
|
|
|
36
33
|
* JSON.stringify(condition); // '"/\\.js$/"'
|
|
37
34
|
* ```
|
|
38
35
|
*/
|
|
39
|
-
export declare function makeRuleSetSerializable(item: RspackRuleSetCondition |
|
|
40
|
-
export declare function makeRulesSerializable(rules: Plugin.RuleSetRule[] | RspackRuleSetRule['oneOf']
|
|
36
|
+
export declare function makeRuleSetSerializable(item: RspackRuleSetCondition | void): void;
|
|
37
|
+
export declare function makeRulesSerializable(rules: Plugin.RuleSetRule[] | RspackRuleSetRule['oneOf']): void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Config, Plugin, SDK } from '@rsdoctor/types';
|
|
2
2
|
import type { RuleSetCondition as RspackRuleSetCondition, RuleSetRule as RspackRuleSetRule } from '@rspack/core';
|
|
3
|
-
import { RuleSetCondition as WebpackRuleSetCondition, RuleSetConditionAbsolute as WebpackRuleSetConditionAbsolute, RuleSetRule as WebpackRuleSetRule } from 'webpack';
|
|
4
3
|
/**
|
|
5
4
|
* Process mode-specific configurations with priority logic
|
|
6
5
|
*/
|
|
@@ -22,9 +21,7 @@ export declare function convertReportCodeTypeObject(reportCodeType: any): Config
|
|
|
22
21
|
* properly serialized to JSON.
|
|
23
22
|
*
|
|
24
23
|
* @param item - The rule set condition to make serializable. Can be:
|
|
25
|
-
* - RspackRuleSetCondition: Rspack
|
|
26
|
-
* - WebpackRuleSetConditionAbsolute: Webpack absolute rule conditions
|
|
27
|
-
* - WebpackRuleSetCondition: Webpack rule conditions
|
|
24
|
+
* - RspackRuleSetCondition: Rspack rule conditions
|
|
28
25
|
* - void: Undefined or null values
|
|
29
26
|
*
|
|
30
27
|
* @example
|
|
@@ -36,5 +33,5 @@ export declare function convertReportCodeTypeObject(reportCodeType: any): Config
|
|
|
36
33
|
* JSON.stringify(condition); // '"/\\.js$/"'
|
|
37
34
|
* ```
|
|
38
35
|
*/
|
|
39
|
-
export declare function makeRuleSetSerializable(item: RspackRuleSetCondition |
|
|
40
|
-
export declare function makeRulesSerializable(rules: Plugin.RuleSetRule[] | RspackRuleSetRule['oneOf']
|
|
36
|
+
export declare function makeRuleSetSerializable(item: RspackRuleSetCondition | void): void;
|
|
37
|
+
export declare function makeRulesSerializable(rules: Plugin.RuleSetRule[] | RspackRuleSetRule['oneOf']): void;
|
|
@@ -57,12 +57,12 @@ const rule = (0, external_rule_cjs_namespaceObject.defineRule)(()=>({
|
|
|
57
57
|
issuerModule: {
|
|
58
58
|
id: dep.module.id,
|
|
59
59
|
path: dep.module.path,
|
|
60
|
-
|
|
60
|
+
identifier: dep.module.identifier
|
|
61
61
|
},
|
|
62
62
|
requiredModule: {
|
|
63
63
|
id: requiredModule.id,
|
|
64
64
|
path: requiredModule.path,
|
|
65
|
-
|
|
65
|
+
identifier: requiredModule.identifier
|
|
66
66
|
},
|
|
67
67
|
request: dep.request
|
|
68
68
|
};
|
|
@@ -30,12 +30,12 @@ const rule = defineRule(()=>({
|
|
|
30
30
|
issuerModule: {
|
|
31
31
|
id: dep.module.id,
|
|
32
32
|
path: dep.module.path,
|
|
33
|
-
|
|
33
|
+
identifier: dep.module.identifier
|
|
34
34
|
},
|
|
35
35
|
requiredModule: {
|
|
36
36
|
id: requiredModule.id,
|
|
37
37
|
path: requiredModule.path,
|
|
38
|
-
|
|
38
|
+
identifier: requiredModule.identifier
|
|
39
39
|
},
|
|
40
40
|
request: dep.request
|
|
41
41
|
};
|
|
@@ -102,27 +102,12 @@ function matchPatternExportKey(patternKey, exportKey) {
|
|
|
102
102
|
if (!exportKey.startsWith(prefix) || !exportKey.endsWith(suffix)) return null;
|
|
103
103
|
return exportKey.slice(prefix.length, exportKey.length - suffix.length);
|
|
104
104
|
}
|
|
105
|
-
function isPatternExportKey(key) {
|
|
106
|
-
return key.indexOf('*') === key.lastIndexOf('*') && key.includes('*');
|
|
107
|
-
}
|
|
108
|
-
function patternKeyCompare(keyA, keyB) {
|
|
109
|
-
const baseLengthA = keyA.includes('*') ? keyA.indexOf('*') + 1 : keyA.length;
|
|
110
|
-
const baseLengthB = keyB.includes('*') ? keyB.indexOf('*') + 1 : keyB.length;
|
|
111
|
-
if (baseLengthA > baseLengthB) return -1;
|
|
112
|
-
if (baseLengthB > baseLengthA) return 1;
|
|
113
|
-
if (!keyA.includes('*')) return 1;
|
|
114
|
-
if (!keyB.includes('*')) return -1;
|
|
115
|
-
if (keyA.length > keyB.length) return -1;
|
|
116
|
-
if (keyB.length > keyA.length) return 1;
|
|
117
|
-
return 0;
|
|
118
|
-
}
|
|
119
105
|
function resolveExportEntry(exports1, exportKey) {
|
|
120
106
|
if (Object.prototype.hasOwnProperty.call(exports1, exportKey)) return {
|
|
121
107
|
value: exports1[exportKey],
|
|
122
108
|
wildcard: ''
|
|
123
109
|
};
|
|
124
|
-
const
|
|
125
|
-
for (const [key, value] of patternEntries){
|
|
110
|
+
for (const [key, value] of Object.entries(exports1)){
|
|
126
111
|
const wildcard = matchPatternExportKey(key, exportKey);
|
|
127
112
|
if (null !== wildcard) return {
|
|
128
113
|
value,
|
|
@@ -219,7 +204,7 @@ const rule = (0, external_rule_cjs_namespaceObject.defineRule)(()=>({
|
|
|
219
204
|
resolvedModule: {
|
|
220
205
|
id: dep.dependency.id,
|
|
221
206
|
path: dep.dependency.path,
|
|
222
|
-
|
|
207
|
+
identifier: dep.dependency.identifier
|
|
223
208
|
},
|
|
224
209
|
issuers: [
|
|
225
210
|
issuer
|
|
@@ -64,27 +64,12 @@ function matchPatternExportKey(patternKey, exportKey) {
|
|
|
64
64
|
if (!exportKey.startsWith(prefix) || !exportKey.endsWith(suffix)) return null;
|
|
65
65
|
return exportKey.slice(prefix.length, exportKey.length - suffix.length);
|
|
66
66
|
}
|
|
67
|
-
function isPatternExportKey(key) {
|
|
68
|
-
return key.indexOf('*') === key.lastIndexOf('*') && key.includes('*');
|
|
69
|
-
}
|
|
70
|
-
function patternKeyCompare(keyA, keyB) {
|
|
71
|
-
const baseLengthA = keyA.includes('*') ? keyA.indexOf('*') + 1 : keyA.length;
|
|
72
|
-
const baseLengthB = keyB.includes('*') ? keyB.indexOf('*') + 1 : keyB.length;
|
|
73
|
-
if (baseLengthA > baseLengthB) return -1;
|
|
74
|
-
if (baseLengthB > baseLengthA) return 1;
|
|
75
|
-
if (!keyA.includes('*')) return 1;
|
|
76
|
-
if (!keyB.includes('*')) return -1;
|
|
77
|
-
if (keyA.length > keyB.length) return -1;
|
|
78
|
-
if (keyB.length > keyA.length) return 1;
|
|
79
|
-
return 0;
|
|
80
|
-
}
|
|
81
67
|
function resolveExportEntry(exports, exportKey) {
|
|
82
68
|
if (Object.prototype.hasOwnProperty.call(exports, exportKey)) return {
|
|
83
69
|
value: exports[exportKey],
|
|
84
70
|
wildcard: ''
|
|
85
71
|
};
|
|
86
|
-
const
|
|
87
|
-
for (const [key, value] of patternEntries){
|
|
72
|
+
for (const [key, value] of Object.entries(exports)){
|
|
88
73
|
const wildcard = matchPatternExportKey(key, exportKey);
|
|
89
74
|
if (null !== wildcard) return {
|
|
90
75
|
value,
|
|
@@ -181,7 +166,7 @@ const rule = defineRule(()=>({
|
|
|
181
166
|
resolvedModule: {
|
|
182
167
|
id: dep.dependency.id,
|
|
183
168
|
path: dep.dependency.path,
|
|
184
|
-
|
|
169
|
+
identifier: dep.dependency.identifier
|
|
185
170
|
},
|
|
186
171
|
issuers: [
|
|
187
172
|
issuer
|
|
@@ -56,7 +56,7 @@ const rule = (0, external_rule_cjs_namespaceObject.defineRule)(()=>({
|
|
|
56
56
|
const { extensions, ignore = [], threshold = 5000 } = ruleConfig;
|
|
57
57
|
if (!extensions || extensions?.length === 0) return;
|
|
58
58
|
if (0 === loader.length) return;
|
|
59
|
-
const { config } = configs.find((e)=>'
|
|
59
|
+
const { config } = configs.find((e)=>'rspack' === e.name) || {
|
|
60
60
|
config: void 0
|
|
61
61
|
};
|
|
62
62
|
if (!config) return;
|
|
@@ -29,7 +29,7 @@ const rule = defineRule(()=>({
|
|
|
29
29
|
const { extensions, ignore = [], threshold = 5000 } = ruleConfig;
|
|
30
30
|
if (!extensions || extensions?.length === 0) return;
|
|
31
31
|
if (0 === loader.length) return;
|
|
32
|
-
const { config } = configs.find((e)=>'
|
|
32
|
+
const { config } = configs.find((e)=>'rspack' === e.name) || {
|
|
33
33
|
config: void 0
|
|
34
34
|
};
|
|
35
35
|
if (!config) return;
|
|
@@ -88,7 +88,7 @@ const rule = (0, external_rule_cjs_namespaceObject.defineRule)(()=>({
|
|
|
88
88
|
module: {
|
|
89
89
|
id: module.id,
|
|
90
90
|
path: module.path,
|
|
91
|
-
|
|
91
|
+
identifier: module.identifier
|
|
92
92
|
},
|
|
93
93
|
connections: sideEffectConnections.map((c)=>({
|
|
94
94
|
originModule: c.originModule ?? module.id,
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RsdoctorPrimarySDK } from '@rsdoctor/sdk';
|
|
2
2
|
import type { Linter, Linter as LinterType, Plugin, SDK } from '@rsdoctor/types';
|
|
3
|
-
export interface RsdoctorMultiplePluginOptions<Rules extends LinterType.ExtendRuleData[] = LinterType.ExtendRuleData[]> extends Omit<Plugin.
|
|
3
|
+
export interface RsdoctorMultiplePluginOptions<Rules extends LinterType.ExtendRuleData[] = LinterType.ExtendRuleData[]> extends Omit<Plugin.RsdoctorRspackPluginOptions<Rules>, 'sdkInstance'>, Pick<ConstructorParameters<typeof RsdoctorPrimarySDK>[0], 'stage'> {
|
|
4
4
|
/**
|
|
5
5
|
* name of builder
|
|
6
6
|
*/
|
|
@@ -40,7 +40,7 @@ export interface RsdoctorRspackPluginExperiments {
|
|
|
40
40
|
export interface RsdoctorRspackPluginExperimentsNormalized {
|
|
41
41
|
enableNativePlugin?: NativePluginConfig;
|
|
42
42
|
}
|
|
43
|
-
export interface RsdoctorRspackPluginOptions<Rules extends LinterType.ExtendRuleData[]> extends Plugin.
|
|
43
|
+
export interface RsdoctorRspackPluginOptions<Rules extends LinterType.ExtendRuleData[]> extends Plugin.RsdoctorRspackPluginOptions<Rules> {
|
|
44
44
|
/**
|
|
45
45
|
* The experiments of the Rsdoctor Rspack plugin.
|
|
46
46
|
*/
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RsdoctorPrimarySDK } from '@rsdoctor/sdk';
|
|
2
2
|
import type { Linter, Linter as LinterType, Plugin, SDK } from '@rsdoctor/types';
|
|
3
|
-
export interface RsdoctorMultiplePluginOptions<Rules extends LinterType.ExtendRuleData[] = LinterType.ExtendRuleData[]> extends Omit<Plugin.
|
|
3
|
+
export interface RsdoctorMultiplePluginOptions<Rules extends LinterType.ExtendRuleData[] = LinterType.ExtendRuleData[]> extends Omit<Plugin.RsdoctorRspackPluginOptions<Rules>, 'sdkInstance'>, Pick<ConstructorParameters<typeof RsdoctorPrimarySDK>[0], 'stage'> {
|
|
4
4
|
/**
|
|
5
5
|
* name of builder
|
|
6
6
|
*/
|
|
@@ -40,7 +40,7 @@ export interface RsdoctorRspackPluginExperiments {
|
|
|
40
40
|
export interface RsdoctorRspackPluginExperimentsNormalized {
|
|
41
41
|
enableNativePlugin?: NativePluginConfig;
|
|
42
42
|
}
|
|
43
|
-
export interface RsdoctorRspackPluginOptions<Rules extends LinterType.ExtendRuleData[]> extends Plugin.
|
|
43
|
+
export interface RsdoctorRspackPluginOptions<Rules extends LinterType.ExtendRuleData[]> extends Plugin.RsdoctorRspackPluginOptions<Rules> {
|
|
44
44
|
/**
|
|
45
45
|
* The experiments of the Rsdoctor Rspack plugin.
|
|
46
46
|
*/
|
package/dist/types/rules.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RuleSetRule } from '
|
|
2
|
-
export
|
|
1
|
+
import type { RuleSetRule } from '@rspack/core';
|
|
2
|
+
export type Rule = RuleSetRule & {
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* The legacy `loaders` field used by rule normalizers.
|
|
5
5
|
*/
|
|
6
6
|
loaders: RuleSetRule['use'];
|
|
7
|
-
}
|
|
7
|
+
};
|
package/dist/types/rules.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RuleSetRule } from '
|
|
2
|
-
export
|
|
1
|
+
import type { RuleSetRule } from '@rspack/core';
|
|
2
|
+
export type Rule = RuleSetRule & {
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* The legacy `loaders` field used by rule normalizers.
|
|
5
5
|
*/
|
|
6
6
|
loaders: RuleSetRule['use'];
|
|
7
|
-
}
|
|
7
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -94,13 +94,13 @@
|
|
|
94
94
|
"fs-extra": "^11.1.1",
|
|
95
95
|
"semver": "^7.7.4",
|
|
96
96
|
"source-map": "^0.7.6",
|
|
97
|
-
"@rsdoctor/graph": "
|
|
98
|
-
"@rsdoctor/
|
|
99
|
-
"@rsdoctor/
|
|
100
|
-
"@rsdoctor/utils": "
|
|
97
|
+
"@rsdoctor/graph": "2.0.0-alpha.0",
|
|
98
|
+
"@rsdoctor/sdk": "2.0.0-alpha.0",
|
|
99
|
+
"@rsdoctor/types": "2.0.0-alpha.0",
|
|
100
|
+
"@rsdoctor/utils": "2.0.0-alpha.0"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
|
-
"@rspack/core": "2.0.
|
|
103
|
+
"@rspack/core": "2.0.4",
|
|
104
104
|
"@types/fs-extra": "^11.0.4",
|
|
105
105
|
"@types/node": "^24.12.3",
|
|
106
106
|
"@types/node-fetch": "^2.6.13",
|
|
@@ -112,7 +112,6 @@
|
|
|
112
112
|
"ts-loader": "^9.5.7",
|
|
113
113
|
"tslib": "2.8.1",
|
|
114
114
|
"typescript": "^6.0.3",
|
|
115
|
-
"webpack": "^5.105.4",
|
|
116
115
|
"@scripts/test-helper": "0.1.1"
|
|
117
116
|
},
|
|
118
117
|
"publishConfig": {
|