@rsdoctor/core 1.0.0-beta.2 → 1.0.0-rc.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/utils/parseBundle.js +2 -2
- package/dist/inner-plugins/utils/config.js +1 -1
- package/dist/inner-plugins/utils/loader.js +1 -1
- package/dist/inner-plugins/utils/sdk.d.ts.map +1 -1
- package/dist/inner-plugins/utils/sdk.js +5 -0
- package/dist/rules/rules/loader-performance-optimization/index.js +6 -6
- package/dist/rules/rules/loader-performance-optimization/types.d.ts +3 -3
- package/dist/rules/rules/loader-performance-optimization/types.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -51,8 +51,8 @@ const parseBundle = (bundlePath, modulesData) => {
|
|
|
51
51
|
const tagMatchResult = getStringBetween(
|
|
52
52
|
content,
|
|
53
53
|
0,
|
|
54
|
-
/([a-z|A-Z]+\.[a-z]+)\(\SRSDOCTOR_START::(.*?);/,
|
|
55
|
-
/([a-z|A-Z]+\.[a-z]+)\(\SRSDOCTOR_END::(.*?)\)/
|
|
54
|
+
/([a-z|A-Z|_]+\.[a-z]+)\(\SRSDOCTOR_START::(.*?);/,
|
|
55
|
+
/([a-z|A-Z|_]+\.[a-z]+)\(\SRSDOCTOR_END::(.*?)\)/
|
|
56
56
|
);
|
|
57
57
|
content = tagMatchResult.result?.trim() || content;
|
|
58
58
|
tagCache.set(bundlePath, tagMatchResult.loc);
|
|
@@ -137,7 +137,7 @@ function normalizeUserConfig(config = {}) {
|
|
|
137
137
|
mode,
|
|
138
138
|
brief
|
|
139
139
|
};
|
|
140
|
-
if (
|
|
140
|
+
if (output.compressData === false && (output.reportCodeType && !output.reportCodeType?.noAssetsAndModuleSource || !output.reportCodeType)) {
|
|
141
141
|
import_logger.logger.info(
|
|
142
142
|
import_logger.chalk.yellow(
|
|
143
143
|
`[RSDOCTOR]: When you use compressData: false, it is recommended to set output.reportCodeType to { noAssetsAndModuleSource: true }.`
|
|
@@ -171,7 +171,7 @@ async function reportLoader(ctx, start, startHRTime, isPitch, sync, code, err, r
|
|
|
171
171
|
mappings: data.mappings,
|
|
172
172
|
file: loaderData[0].resource.path
|
|
173
173
|
};
|
|
174
|
-
const sdk = (0, import_sdk.getSDK)();
|
|
174
|
+
const sdk = (0, import_sdk.getSDK)(ctx._compilation?.name);
|
|
175
175
|
if (sdk?.reportLoader && !("parent" in sdk && sdk.parent)) {
|
|
176
176
|
sdk.reportLoader(loaderData);
|
|
177
177
|
sdk.reportSourceMap(sourceMapData);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/inner-plugins/utils/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/inner-plugins/utils/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,eAAe,CAAC;AAKhE,wBAAgB,MAAM,CAAC,CAAC,EAAE,WAAW,QAGpC;AAED,wBAAgB,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,0FAY1C"}
|
|
@@ -22,11 +22,16 @@ __export(sdk_exports, {
|
|
|
22
22
|
setSDK: () => setSDK
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(sdk_exports);
|
|
25
|
+
let sdks = [];
|
|
25
26
|
let sdk;
|
|
26
27
|
function setSDK(t) {
|
|
28
|
+
sdks.push(t);
|
|
27
29
|
sdk = t;
|
|
28
30
|
}
|
|
29
31
|
function getSDK(builderName) {
|
|
32
|
+
if (sdk && sdk.name !== builderName) {
|
|
33
|
+
sdk = builderName ? sdks.find((s) => s.name === builderName) || sdk : sdk;
|
|
34
|
+
}
|
|
30
35
|
if (sdk && builderName && "parent" in sdk) {
|
|
31
36
|
const _sdk = sdk;
|
|
32
37
|
const slaveSDK = _sdk.parent.slaves.find(
|
|
@@ -40,12 +40,14 @@ const rule = (0, import_rule.defineRule)(() => {
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
check({ loader, configs, root, ruleConfig, report }) {
|
|
43
|
-
const { extensions, ignore, threshold } = ruleConfig;
|
|
44
|
-
if (extensions
|
|
43
|
+
const { extensions, ignore = [], threshold = 5e3 } = ruleConfig;
|
|
44
|
+
if (!extensions || extensions?.length === 0)
|
|
45
45
|
return;
|
|
46
46
|
if (loader.length === 0)
|
|
47
47
|
return;
|
|
48
|
-
const { config } = configs.find((e) => e.name === "webpack") || {
|
|
48
|
+
const { config } = configs.find((e) => e.name === "webpack") || {
|
|
49
|
+
config: void 0
|
|
50
|
+
};
|
|
49
51
|
if (!config) {
|
|
50
52
|
return;
|
|
51
53
|
}
|
|
@@ -81,7 +83,7 @@ const rule = (0, import_rule.defineRule)(() => {
|
|
|
81
83
|
null,
|
|
82
84
|
arr.map((e) => e.endAt)
|
|
83
85
|
) - Math.min.apply(arr.map((e) => e.startAt));
|
|
84
|
-
if (v2 >= v1)
|
|
86
|
+
if (v2 >= v1 || v2 === -Infinity)
|
|
85
87
|
return v1;
|
|
86
88
|
return v2;
|
|
87
89
|
};
|
|
@@ -109,8 +111,6 @@ const rule = (0, import_rule.defineRule)(() => {
|
|
|
109
111
|
detail: {
|
|
110
112
|
description: message,
|
|
111
113
|
type: "link"
|
|
112
|
-
// nodeModulesFiles,
|
|
113
|
-
// outofCwdFiles,
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
116
|
}
|
|
@@ -3,18 +3,18 @@ export interface Config {
|
|
|
3
3
|
/**
|
|
4
4
|
* loaders which should be ignore.
|
|
5
5
|
*/
|
|
6
|
-
ignore
|
|
6
|
+
ignore?: (string | RegExp)[];
|
|
7
7
|
/**
|
|
8
8
|
* threshold which the loader total costs.
|
|
9
9
|
* @unit millisecond
|
|
10
10
|
* @default 5000
|
|
11
11
|
*/
|
|
12
|
-
threshold
|
|
12
|
+
threshold?: number;
|
|
13
13
|
/**
|
|
14
14
|
* the file extensions which will be match in rule check.
|
|
15
15
|
* @default ["js", "css", "jpg", "jpeg", "png", "gif", "webp", "svg"]
|
|
16
16
|
*/
|
|
17
|
-
extensions
|
|
17
|
+
extensions?: (string | RegExp)[];
|
|
18
18
|
}
|
|
19
19
|
export interface LoaderMapValue extends SDK.LoaderTransformData {
|
|
20
20
|
__resource__: SDK.ResourceData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/rules/rules/loader-performance-optimization/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/rules/rules/loader-performance-optimization/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC7B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,cAAe,SAAQ,GAAG,CAAC,mBAAmB;IAC7D,YAAY,EAAE,GAAG,CAAC,YAAY,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/core",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -73,15 +73,15 @@
|
|
|
73
73
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
74
74
|
"@rsbuild/plugin-check-syntax": "1.2.2",
|
|
75
75
|
"browserslist-load-config": "^1.0.0",
|
|
76
|
-
"@rsdoctor/graph": "1.0.0-
|
|
77
|
-
"@rsdoctor/
|
|
78
|
-
"@rsdoctor/utils": "1.0.0-
|
|
79
|
-
"@rsdoctor/
|
|
76
|
+
"@rsdoctor/graph": "1.0.0-rc.0",
|
|
77
|
+
"@rsdoctor/sdk": "1.0.0-rc.0",
|
|
78
|
+
"@rsdoctor/utils": "1.0.0-rc.0",
|
|
79
|
+
"@rsdoctor/types": "1.0.0-rc.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@rspack/core": "^1.2.
|
|
82
|
+
"@rspack/core": "^1.2.7",
|
|
83
83
|
"@types/fs-extra": "^11.0.4",
|
|
84
|
-
"@types/lodash": "^4.17.
|
|
84
|
+
"@types/lodash": "^4.17.16",
|
|
85
85
|
"@types/node": "^16",
|
|
86
86
|
"@types/node-fetch": "^2.6.12",
|
|
87
87
|
"@types/path-browserify": "1.0.3",
|