@rsdoctor/core 1.5.7 → 1.5.9
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/webpack/transform.cjs +1 -1
- package/dist/build-utils/build/module-graph/webpack/transform.js +1 -1
- package/dist/build-utils/build/utils/loader.cjs +2 -3
- package/dist/build-utils/build/utils/loader.js +8 -8
- package/dist/index.js +1 -1
- package/dist/inner-plugins/loaders/proxy.cjs +10 -4
- package/dist/inner-plugins/loaders/proxy.js +10 -4
- package/dist/inner-plugins/plugins/bundleTagPlugin.cjs +3 -3
- package/dist/inner-plugins/plugins/bundleTagPlugin.js +3 -3
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +1 -1
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +1 -1
- package/dist/inner-plugins/plugins/sourcemapTool.cjs +2 -2
- package/dist/inner-plugins/plugins/sourcemapTool.js +2 -2
- package/dist/inner-plugins/utils/loader.cjs +3 -9
- package/dist/inner-plugins/utils/loader.js +4 -9
- package/dist/inner-plugins/utils/plugin.cjs +7 -7
- package/dist/inner-plugins/utils/plugin.js +7 -7
- package/dist/rslib-runtime.js +0 -21
- package/dist/rules/rule.cjs +1 -1
- package/dist/rules/rule.js +1 -1
- package/dist/rules/rules/cjs-require/index.cjs +2 -1
- package/dist/rules/rules/cjs-require/index.js +2 -1
- package/dist/rules/rules/cjs-require/types.d.ts +4 -1
- package/dist/rules/rules/duplicate-package/index.js +4 -10
- package/dist/rules/rules/esm-resolved-to-cjs/index.cjs +30 -2
- package/dist/rules/rules/esm-resolved-to-cjs/index.js +30 -2
- package/dist/rules/rules/loader-performance-optimization/index.cjs +3 -3
- package/dist/rules/rules/loader-performance-optimization/index.js +3 -3
- package/package.json +7 -8
- package/compiled/axios/index.d.ts +0 -811
- package/compiled/axios/index.js +0 -9359
- package/compiled/axios/license +0 -7
- package/compiled/axios/package.json +0 -1
|
@@ -155,7 +155,7 @@ async function appendModuleGraphByCompilation(compilation, graph, features, cont
|
|
|
155
155
|
await Promise.all(allModules.map((module)=>appendModuleData(module, webpackGraph, graph, fileSystemInfo, features, context)));
|
|
156
156
|
graph_namespaceObject.ModuleGraphTrans.removeNoImportStyle(graph);
|
|
157
157
|
return graph;
|
|
158
|
-
} catch
|
|
158
|
+
} catch {
|
|
159
159
|
return graph;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -117,7 +117,7 @@ async function appendModuleGraphByCompilation(compilation, graph, features, cont
|
|
|
117
117
|
await Promise.all(allModules.map((module)=>appendModuleData(module, webpackGraph, graph, fileSystemInfo, features, context)));
|
|
118
118
|
ModuleGraphTrans.removeNoImportStyle(graph);
|
|
119
119
|
return graph;
|
|
120
|
-
} catch
|
|
120
|
+
} catch {
|
|
121
121
|
return graph;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -168,7 +168,7 @@ var __webpack_exports__ = {};
|
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
170
|
function isESMLoader(r) {
|
|
171
|
-
|
|
171
|
+
const _loaderName = 'object' == typeof r && 'string' == typeof r?.loader ? r.loader : 'string' == typeof r ? r : '';
|
|
172
172
|
if (!_loaderName) return false;
|
|
173
173
|
const isPath = external_node_path_default().isAbsolute(_loaderName) || _loaderName.startsWith('./') || _loaderName.startsWith('../');
|
|
174
174
|
if (isPath) {
|
|
@@ -302,8 +302,7 @@ var __webpack_exports__ = {};
|
|
|
302
302
|
common_namespaceObject.Loader.LoaderInternalPropertyName
|
|
303
303
|
]) : Reflect.get(target, key, receiver);
|
|
304
304
|
default:
|
|
305
|
-
|
|
306
|
-
return _target[key];
|
|
305
|
+
return target[key];
|
|
307
306
|
}
|
|
308
307
|
},
|
|
309
308
|
set (target, key, value, receiver) {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import __rslib_shim_module__ from "node:module";
|
|
2
2
|
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
-
import * as __rspack_external_module from "module";
|
|
4
|
-
import { __webpack_require__ } from "../../../rslib-runtime.js";
|
|
5
3
|
import node_path from "node:path";
|
|
6
4
|
import { fileURLToPath } from "node:url";
|
|
7
5
|
import fs_extra from "fs-extra";
|
|
@@ -9,9 +7,12 @@ import { omit } from "es-toolkit/compat";
|
|
|
9
7
|
import { Loader } from "@rsdoctor/utils/common";
|
|
10
8
|
import { readPackageJson } from "@rsdoctor/graph";
|
|
11
9
|
import { logger } from "@rsdoctor/utils/logger";
|
|
10
|
+
import { __webpack_require__ } from "../../../rslib-runtime.js";
|
|
11
|
+
import { createRequire as __rspack_createRequire } from "node:module";
|
|
12
|
+
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
12
13
|
__webpack_require__.add({
|
|
13
|
-
"module?
|
|
14
|
-
module.exports =
|
|
14
|
+
"module?2382" (module) {
|
|
15
|
+
module.exports = __rspack_createRequire_require("module");
|
|
15
16
|
}
|
|
16
17
|
});
|
|
17
18
|
const loader_filename = fileURLToPath(import.meta.url);
|
|
@@ -27,7 +28,7 @@ function parsePathQueryFragment(str) {
|
|
|
27
28
|
}
|
|
28
29
|
function loadLoaderModule(loaderPath, cwd = process.cwd()) {
|
|
29
30
|
const cleanLoaderPath = parsePathQueryFragment(loaderPath).path;
|
|
30
|
-
const { createRequire } = __webpack_require__("module?
|
|
31
|
+
const { createRequire } = __webpack_require__("module?2382");
|
|
31
32
|
const requireFn = createRequire(import.meta.url);
|
|
32
33
|
const mod = requireFn(process.env.DOCTOR_TEST ? node_path.resolve(cwd, cleanLoaderPath) : requireFn.resolve(cleanLoaderPath, {
|
|
33
34
|
paths: [
|
|
@@ -112,7 +113,7 @@ function mapEachRules(rules, callback) {
|
|
|
112
113
|
});
|
|
113
114
|
}
|
|
114
115
|
function isESMLoader(r) {
|
|
115
|
-
|
|
116
|
+
const _loaderName = 'object' == typeof r && 'string' == typeof r?.loader ? r.loader : 'string' == typeof r ? r : '';
|
|
116
117
|
if (!_loaderName) return false;
|
|
117
118
|
const isPath = node_path.isAbsolute(_loaderName) || _loaderName.startsWith('./') || _loaderName.startsWith('../');
|
|
118
119
|
if (isPath) {
|
|
@@ -246,8 +247,7 @@ function createLoaderContextTrap(final) {
|
|
|
246
247
|
Loader.LoaderInternalPropertyName
|
|
247
248
|
]) : Reflect.get(target, key, receiver);
|
|
248
249
|
default:
|
|
249
|
-
|
|
250
|
-
return _target[key];
|
|
250
|
+
return target[key];
|
|
251
251
|
}
|
|
252
252
|
},
|
|
253
253
|
set (target, key, value, receiver) {
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import * as __rspack_external__inner_plugins_index_js_1dbd01aa from "./inner-plugins/index.js";
|
|
2
3
|
export * from "./build-utils/index.js";
|
|
3
4
|
export * from "./types/index.js";
|
|
4
|
-
import * as __rspack_external__inner_plugins_index_js_1dbd01aa from "./inner-plugins/index.js";
|
|
5
5
|
export { __rspack_external__inner_plugins_index_js_1dbd01aa as InnerPlugins };
|
|
@@ -36,8 +36,11 @@ const loaderModule = function(...args) {
|
|
|
36
36
|
const mod = (0, external_utils_index_cjs_namespaceObject.getOriginLoaderModule)(this);
|
|
37
37
|
if (mod.default) {
|
|
38
38
|
if (false === mod.raw && Buffer.isBuffer(args[0])) args[0] = args[0].toString();
|
|
39
|
-
let start;
|
|
40
|
-
let startHRTime
|
|
39
|
+
let start = 0;
|
|
40
|
+
let startHRTime = [
|
|
41
|
+
0,
|
|
42
|
+
0
|
|
43
|
+
];
|
|
41
44
|
const trap = index_cjs_namespaceObject.Utils.createLoaderContextTrap.call(this, (err, res, sourceMap)=>{
|
|
42
45
|
(0, external_utils_index_cjs_namespaceObject.reportLoader)(this, start, startHRTime, false, false, args[0].toString(), err, res, sourceMap);
|
|
43
46
|
});
|
|
@@ -61,8 +64,11 @@ const pitch = function() {
|
|
|
61
64
|
this.cacheable(false);
|
|
62
65
|
const mod = (0, external_utils_index_cjs_namespaceObject.getOriginLoaderModule)(this);
|
|
63
66
|
if (mod.pitch && 'function' == typeof mod.pitch) {
|
|
64
|
-
let start;
|
|
65
|
-
let startHRTime
|
|
67
|
+
let start = 0;
|
|
68
|
+
let startHRTime = [
|
|
69
|
+
0,
|
|
70
|
+
0
|
|
71
|
+
];
|
|
66
72
|
const trap = index_cjs_namespaceObject.Utils.createLoaderContextTrap.call(this, (err, res)=>{
|
|
67
73
|
(0, external_utils_index_cjs_namespaceObject.reportLoader)(this, start, startHRTime, true, false, err ? 'Loader Pitch Async Error' : '', err, res);
|
|
68
74
|
});
|
|
@@ -7,8 +7,11 @@ const loaderModule = function(...args) {
|
|
|
7
7
|
const mod = getOriginLoaderModule(this);
|
|
8
8
|
if (mod.default) {
|
|
9
9
|
if (false === mod.raw && Buffer.isBuffer(args[0])) args[0] = args[0].toString();
|
|
10
|
-
let start;
|
|
11
|
-
let startHRTime
|
|
10
|
+
let start = 0;
|
|
11
|
+
let startHRTime = [
|
|
12
|
+
0,
|
|
13
|
+
0
|
|
14
|
+
];
|
|
12
15
|
const trap = Utils.createLoaderContextTrap.call(this, (err, res, sourceMap)=>{
|
|
13
16
|
reportLoader(this, start, startHRTime, false, false, args[0].toString(), err, res, sourceMap);
|
|
14
17
|
});
|
|
@@ -32,8 +35,11 @@ const pitch = function() {
|
|
|
32
35
|
this.cacheable(false);
|
|
33
36
|
const mod = getOriginLoaderModule(this);
|
|
34
37
|
if (mod.pitch && 'function' == typeof mod.pitch) {
|
|
35
|
-
let start;
|
|
36
|
-
let startHRTime
|
|
38
|
+
let start = 0;
|
|
39
|
+
let startHRTime = [
|
|
40
|
+
0,
|
|
41
|
+
0
|
|
42
|
+
];
|
|
37
43
|
const trap = Utils.createLoaderContextTrap.call(this, (err, res)=>{
|
|
38
44
|
reportLoader(this, start, startHRTime, true, false, err ? 'Loader Pitch Async Error' : '', err, res);
|
|
39
45
|
});
|
|
@@ -52,13 +52,13 @@ class InternalBundleTagPlugin extends external_base_cjs_namespaceObject.Internal
|
|
|
52
52
|
if (true === terserDropConsole || true === swcDropConsole) logger_namespaceObject.logger.warn(logger_namespaceObject.chalk.yellow('Warning: BannerPlugin detected in project. Please disable drop_console option in TerserPlugin or SwcJsMinimizerRspackPlugin to enable Rsdoctor analysis for BannerPlugin.'));
|
|
53
53
|
}
|
|
54
54
|
const chunks = compilation.chunks;
|
|
55
|
-
for (
|
|
55
|
+
for (const chunk of chunks)for (const file of chunk.files){
|
|
56
56
|
if (!file || '.js' !== (0, external_path_namespaceObject.extname)(file)) continue;
|
|
57
57
|
const { ConcatSource } = compiler.webpack.sources;
|
|
58
58
|
compilation.updateAsset(file, (old)=>{
|
|
59
59
|
const concatSource = new ConcatSource();
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const header = "\n console.log('RSDOCTOR_START::');\n";
|
|
61
|
+
const footer = "\n console.log('RSDOCTOR_END::');\n";
|
|
62
62
|
concatSource.add(header);
|
|
63
63
|
concatSource.add(old);
|
|
64
64
|
concatSource.add(footer);
|
|
@@ -25,13 +25,13 @@ class InternalBundleTagPlugin extends InternalBasePlugin {
|
|
|
25
25
|
if (true === terserDropConsole || true === swcDropConsole) logger.warn(chalk.yellow('Warning: BannerPlugin detected in project. Please disable drop_console option in TerserPlugin or SwcJsMinimizerRspackPlugin to enable Rsdoctor analysis for BannerPlugin.'));
|
|
26
26
|
}
|
|
27
27
|
const chunks = compilation.chunks;
|
|
28
|
-
for (
|
|
28
|
+
for (const chunk of chunks)for (const file of chunk.files){
|
|
29
29
|
if (!file || '.js' !== extname(file)) continue;
|
|
30
30
|
const { ConcatSource } = compiler.webpack.sources;
|
|
31
31
|
compilation.updateAsset(file, (old)=>{
|
|
32
32
|
const concatSource = new ConcatSource();
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const header = "\n console.log('RSDOCTOR_START::');\n";
|
|
34
|
+
const footer = "\n console.log('RSDOCTOR_END::');\n";
|
|
35
35
|
concatSource.add(header);
|
|
36
36
|
concatSource.add(old);
|
|
37
37
|
concatSource.add(footer);
|
|
@@ -138,7 +138,7 @@ async function getModulesInfos(compiler, moduleGraph, chunkGraph, parseBundle, s
|
|
|
138
138
|
if (!moduleGraph) return;
|
|
139
139
|
try {
|
|
140
140
|
await index_cjs_namespaceObject.Chunks.getAssetsModulesData(moduleGraph, chunkGraph, compiler.outputPath, sourceMapSets, parseBundle, assetsWithoutSourceMap);
|
|
141
|
-
} catch
|
|
141
|
+
} catch {}
|
|
142
142
|
}
|
|
143
143
|
function escapeRegExp(str) {
|
|
144
144
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
@@ -109,7 +109,7 @@ async function getModulesInfos(compiler, moduleGraph, chunkGraph, parseBundle, s
|
|
|
109
109
|
if (!moduleGraph) return;
|
|
110
110
|
try {
|
|
111
111
|
await Chunks.getAssetsModulesData(moduleGraph, chunkGraph, compiler.outputPath, sourceMapSets, parseBundle, assetsWithoutSourceMap);
|
|
112
|
-
} catch
|
|
112
|
+
} catch {}
|
|
113
113
|
}
|
|
114
114
|
function escapeRegExp(str) {
|
|
115
115
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
@@ -137,8 +137,8 @@ async function handleAfterEmitAssets(compilation, _this, sourceMapFilenameRegex,
|
|
|
137
137
|
sourceMapPath = (0, external_path_namespaceObject.resolve)(outputPath, mapFileName);
|
|
138
138
|
}
|
|
139
139
|
} else {
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
const sourceMapFile = asset.info.related?.sourceMap;
|
|
141
|
+
const sourceMapFileAssetName = sourceMapFile?.replace(/(\.[^.]+)(\.[^.]+)?$/, '$1');
|
|
142
142
|
if (sourceMapFile) {
|
|
143
143
|
let sourceMapAsset = assets.find((asset)=>asset.name === sourceMapFile);
|
|
144
144
|
if (!sourceMapAsset && sourceMapFileAssetName) {
|
|
@@ -106,8 +106,8 @@ async function handleAfterEmitAssets(compilation, _this, sourceMapFilenameRegex,
|
|
|
106
106
|
sourceMapPath = resolve(outputPath, mapFileName);
|
|
107
107
|
}
|
|
108
108
|
} else {
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
const sourceMapFile = asset.info.related?.sourceMap;
|
|
110
|
+
const sourceMapFileAssetName = sourceMapFile?.replace(/(\.[^.]+)(\.[^.]+)?$/, '$1');
|
|
111
111
|
if (sourceMapFile) {
|
|
112
112
|
let sourceMapAsset = assets.find((asset)=>asset.name === sourceMapFile);
|
|
113
113
|
if (!sourceMapAsset && sourceMapFileAssetName) {
|
|
@@ -40,8 +40,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
40
40
|
getInternalLoaderOptions: ()=>getInternalLoaderOptions,
|
|
41
41
|
getOriginLoaderModule: ()=>getOriginLoaderModule
|
|
42
42
|
});
|
|
43
|
-
const index_js_namespaceObject = require("../../../compiled/axios/index.js");
|
|
44
|
-
var index_js_default = /*#__PURE__*/ __webpack_require__.n(index_js_namespaceObject);
|
|
45
43
|
const resolver_namespaceObject = require("@rspack/resolver");
|
|
46
44
|
const compat_namespaceObject = require("es-toolkit/compat");
|
|
47
45
|
const external_path_namespaceObject = require("path");
|
|
@@ -114,7 +112,7 @@ function interceptLoader(rules, loaderPath, options, cwd = process.cwd(), resolv
|
|
|
114
112
|
try {
|
|
115
113
|
const result = loaderResolver.sync(cwd, target);
|
|
116
114
|
if (result.path) return result.path;
|
|
117
|
-
} catch
|
|
115
|
+
} catch {}
|
|
118
116
|
return target;
|
|
119
117
|
};
|
|
120
118
|
return index_cjs_namespaceObject.Utils.mapEachRules(rules, (rule)=>{
|
|
@@ -192,14 +190,10 @@ async function reportLoader(ctx, start, startHRTime, isPitch, sync, code, err, r
|
|
|
192
190
|
return loaderData;
|
|
193
191
|
}
|
|
194
192
|
await Promise.all([
|
|
195
|
-
|
|
196
|
-
timeout: 8888
|
|
197
|
-
}).catch((err)=>{
|
|
193
|
+
common_namespaceObject.Fetch.postJSON(`${host}${types_namespaceObject.SDK.ServerAPI.API.ReportLoader}`, loaderData, 8888).catch((err)=>{
|
|
198
194
|
logger_namespaceObject.logger.debug(`${err.message}`, '[WebpackPlugin.ReportLoader][error]');
|
|
199
195
|
}),
|
|
200
|
-
|
|
201
|
-
timeout: 8888
|
|
202
|
-
}).catch((err)=>{
|
|
196
|
+
common_namespaceObject.Fetch.postJSON(`${host}${types_namespaceObject.SDK.ServerAPI.API.ReportSourceMap}`, sourceMapData, 8888).catch((err)=>{
|
|
203
197
|
logger_namespaceObject.logger.debug(`${err.message}`, '[WebpackPlugin.ReportSourceMap][error]');
|
|
204
198
|
})
|
|
205
199
|
]);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import axios from "../../../compiled/axios/index.js";
|
|
3
2
|
import { ResolverFactory } from "@rspack/resolver";
|
|
4
3
|
import { omit } from "es-toolkit/compat";
|
|
5
4
|
import path from "path";
|
|
6
5
|
import { logger } from "@rsdoctor/utils/logger";
|
|
7
|
-
import { Loader, Lodash, Time } from "@rsdoctor/utils/common";
|
|
6
|
+
import { Fetch, Loader, Lodash, Time } from "@rsdoctor/utils/common";
|
|
8
7
|
import { SDK } from "@rsdoctor/types";
|
|
9
8
|
import { DevToolError } from "@rsdoctor/utils/error";
|
|
10
9
|
import { getSDK } from "./sdk.js";
|
|
@@ -71,7 +70,7 @@ function interceptLoader(rules, loaderPath, options, cwd = process.cwd(), resolv
|
|
|
71
70
|
try {
|
|
72
71
|
const result = loaderResolver.sync(cwd, target);
|
|
73
72
|
if (result.path) return result.path;
|
|
74
|
-
} catch
|
|
73
|
+
} catch {}
|
|
75
74
|
return target;
|
|
76
75
|
};
|
|
77
76
|
return Utils.mapEachRules(rules, (rule)=>{
|
|
@@ -149,14 +148,10 @@ async function reportLoader(ctx, start, startHRTime, isPitch, sync, code, err, r
|
|
|
149
148
|
return loaderData;
|
|
150
149
|
}
|
|
151
150
|
await Promise.all([
|
|
152
|
-
|
|
153
|
-
timeout: 8888
|
|
154
|
-
}).catch((err)=>{
|
|
151
|
+
Fetch.postJSON(`${host}${SDK.ServerAPI.API.ReportLoader}`, loaderData, 8888).catch((err)=>{
|
|
155
152
|
logger.debug(`${err.message}`, '[WebpackPlugin.ReportLoader][error]');
|
|
156
153
|
}),
|
|
157
|
-
|
|
158
|
-
timeout: 8888
|
|
159
|
-
}).catch((err)=>{
|
|
154
|
+
Fetch.postJSON(`${host}${SDK.ServerAPI.API.ReportSourceMap}`, sourceMapData, 8888).catch((err)=>{
|
|
160
155
|
logger.debug(`${err.message}`, '[WebpackPlugin.ReportSourceMap][error]');
|
|
161
156
|
})
|
|
162
157
|
]);
|
|
@@ -57,10 +57,10 @@ function interceptPluginHook(sdk, name, hook) {
|
|
|
57
57
|
hook.intercept({
|
|
58
58
|
register (tap) {
|
|
59
59
|
const o = tap.fn;
|
|
60
|
-
if ('sync' === tap.type) tap.fn = function() {
|
|
60
|
+
if ('sync' === tap.type) tap.fn = function(...args) {
|
|
61
61
|
const start = Date.now();
|
|
62
62
|
try {
|
|
63
|
-
const res = o.apply(this,
|
|
63
|
+
const res = o.apply(this, args);
|
|
64
64
|
reportPluginData(sdk, name, tap.name, start, tap.type, res);
|
|
65
65
|
return res;
|
|
66
66
|
} catch (error) {
|
|
@@ -68,10 +68,10 @@ function interceptPluginHook(sdk, name, hook) {
|
|
|
68
68
|
throw error;
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
-
else if ('async' === tap.type) tap.fn = async function() {
|
|
71
|
+
else if ('async' === tap.type) tap.fn = async function(...args) {
|
|
72
72
|
const start = Date.now();
|
|
73
73
|
try {
|
|
74
|
-
const res = await o.apply(this,
|
|
74
|
+
const res = await o.apply(this, args);
|
|
75
75
|
reportPluginData(sdk, name, tap.name, start, tap.type, res);
|
|
76
76
|
return res;
|
|
77
77
|
} catch (error) {
|
|
@@ -79,10 +79,10 @@ function interceptPluginHook(sdk, name, hook) {
|
|
|
79
79
|
throw error;
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
else if ('promise' === tap.type) tap.fn = function() {
|
|
82
|
+
else if ('promise' === tap.type) tap.fn = function(...args) {
|
|
83
83
|
const start = Date.now();
|
|
84
|
-
const isChild =
|
|
85
|
-
return o.apply(this,
|
|
84
|
+
const isChild = args?.[0]?.compiler?.isChild();
|
|
85
|
+
return o.apply(this, args).then((res)=>{
|
|
86
86
|
if (isChild) return res;
|
|
87
87
|
reportPluginData(sdk, name, tap.name, start, tap.type, res);
|
|
88
88
|
return res;
|
|
@@ -29,10 +29,10 @@ function interceptPluginHook(sdk, name, hook) {
|
|
|
29
29
|
hook.intercept({
|
|
30
30
|
register (tap) {
|
|
31
31
|
const o = tap.fn;
|
|
32
|
-
if ('sync' === tap.type) tap.fn = function() {
|
|
32
|
+
if ('sync' === tap.type) tap.fn = function(...args) {
|
|
33
33
|
const start = Date.now();
|
|
34
34
|
try {
|
|
35
|
-
const res = o.apply(this,
|
|
35
|
+
const res = o.apply(this, args);
|
|
36
36
|
reportPluginData(sdk, name, tap.name, start, tap.type, res);
|
|
37
37
|
return res;
|
|
38
38
|
} catch (error) {
|
|
@@ -40,10 +40,10 @@ function interceptPluginHook(sdk, name, hook) {
|
|
|
40
40
|
throw error;
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
else if ('async' === tap.type) tap.fn = async function() {
|
|
43
|
+
else if ('async' === tap.type) tap.fn = async function(...args) {
|
|
44
44
|
const start = Date.now();
|
|
45
45
|
try {
|
|
46
|
-
const res = await o.apply(this,
|
|
46
|
+
const res = await o.apply(this, args);
|
|
47
47
|
reportPluginData(sdk, name, tap.name, start, tap.type, res);
|
|
48
48
|
return res;
|
|
49
49
|
} catch (error) {
|
|
@@ -51,10 +51,10 @@ function interceptPluginHook(sdk, name, hook) {
|
|
|
51
51
|
throw error;
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
else if ('promise' === tap.type) tap.fn = function() {
|
|
54
|
+
else if ('promise' === tap.type) tap.fn = function(...args) {
|
|
55
55
|
const start = Date.now();
|
|
56
|
-
const isChild =
|
|
57
|
-
return o.apply(this,
|
|
56
|
+
const isChild = args?.[0]?.compiler?.isChild();
|
|
57
|
+
return o.apply(this, args).then((res)=>{
|
|
58
58
|
if (isChild) return res;
|
|
59
59
|
reportPluginData(sdk, name, tap.name, start, tap.type, res);
|
|
60
60
|
return res;
|
package/dist/rslib-runtime.js
CHANGED
|
@@ -11,30 +11,9 @@ function __webpack_require__(moduleId) {
|
|
|
11
11
|
return module.exports;
|
|
12
12
|
}
|
|
13
13
|
__webpack_require__.m = __webpack_modules__;
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.d = (exports, definition)=>{
|
|
16
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: definition[key]
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
})();
|
|
22
14
|
(()=>{
|
|
23
15
|
__webpack_require__.add = function(modules) {
|
|
24
16
|
Object.assign(__webpack_require__.m, modules);
|
|
25
17
|
};
|
|
26
18
|
})();
|
|
27
|
-
(()=>{
|
|
28
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
29
|
-
})();
|
|
30
|
-
(()=>{
|
|
31
|
-
__webpack_require__.r = (exports)=>{
|
|
32
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
|
|
33
|
-
value: 'Module'
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(exports, '__esModule', {
|
|
36
|
-
value: true
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
19
|
export { __webpack_require__ };
|
package/dist/rules/rule.cjs
CHANGED
|
@@ -84,7 +84,7 @@ class Rule {
|
|
|
84
84
|
const replace = [];
|
|
85
85
|
const report = (data, remove)=>{
|
|
86
86
|
if (remove) replace.push(remove);
|
|
87
|
-
|
|
87
|
+
const severity = data.severity ? (0, external_utils_cjs_namespaceObject.toSeverity)(data.severity, this.severity) : this.severity;
|
|
88
88
|
const error = {
|
|
89
89
|
...data,
|
|
90
90
|
code: this.code,
|
package/dist/rules/rule.js
CHANGED
|
@@ -56,7 +56,7 @@ class rule_Rule {
|
|
|
56
56
|
const replace = [];
|
|
57
57
|
const report = (data, remove)=>{
|
|
58
58
|
if (remove) replace.push(remove);
|
|
59
|
-
|
|
59
|
+
const severity = data.severity ? toSeverity(data.severity, this.severity) : this.severity;
|
|
60
60
|
const error = {
|
|
61
61
|
...data,
|
|
62
62
|
code: this.code,
|
|
@@ -30,8 +30,9 @@ const types_namespaceObject = require("@rsdoctor/types");
|
|
|
30
30
|
const external_rule_cjs_namespaceObject = require("../../rule.cjs");
|
|
31
31
|
const title = 'cjs-require';
|
|
32
32
|
const CJS_REQUIRE_TYPE = 'cjs require';
|
|
33
|
+
const NODE_MODULES_PATH_REGEXP = /[/\\]node_modules[/\\]/;
|
|
33
34
|
function isNodeModulesPath(modulePath) {
|
|
34
|
-
return
|
|
35
|
+
return NODE_MODULES_PATH_REGEXP.test(modulePath);
|
|
35
36
|
}
|
|
36
37
|
const rule = (0, external_rule_cjs_namespaceObject.defineRule)(()=>({
|
|
37
38
|
meta: {
|
|
@@ -3,8 +3,9 @@ import { Linter } from "@rsdoctor/types";
|
|
|
3
3
|
import { defineRule } from "../../rule.js";
|
|
4
4
|
const title = 'cjs-require';
|
|
5
5
|
const CJS_REQUIRE_TYPE = 'cjs require';
|
|
6
|
+
const NODE_MODULES_PATH_REGEXP = /[/\\]node_modules[/\\]/;
|
|
6
7
|
function isNodeModulesPath(modulePath) {
|
|
7
|
-
return
|
|
8
|
+
return NODE_MODULES_PATH_REGEXP.test(modulePath);
|
|
8
9
|
}
|
|
9
10
|
const rule = defineRule(()=>({
|
|
10
11
|
meta: {
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { __webpack_require__ } from "../../../rslib-runtime.js";
|
|
3
2
|
import { Linter } from "@rsdoctor/types";
|
|
4
3
|
import { diff, gt } from "semver";
|
|
5
|
-
import { CheckVersionMap } from "./types.js";
|
|
6
4
|
import { getErrorDetail, getErrorMsg } from "./utils.js";
|
|
7
5
|
import { defineRule } from "../../rule.js";
|
|
8
|
-
|
|
9
|
-
__webpack_require__.r(external_types_js_namespaceObject);
|
|
10
|
-
__webpack_require__.d(external_types_js_namespaceObject, {
|
|
11
|
-
CheckVersionMap: ()=>CheckVersionMap
|
|
12
|
-
});
|
|
6
|
+
import * as __rspack_external__types_js_7eec16d2 from "./types.js";
|
|
13
7
|
const title = 'duplicate-package';
|
|
14
|
-
const { CheckVersionMap:
|
|
8
|
+
const { CheckVersionMap: CheckVersionMap } = __rspack_external__types_js_7eec16d2;
|
|
15
9
|
const rule = defineRule(()=>({
|
|
16
10
|
meta: {
|
|
17
11
|
code: 'E1001',
|
|
@@ -24,9 +18,9 @@ const rule = defineRule(()=>({
|
|
|
24
18
|
}
|
|
25
19
|
},
|
|
26
20
|
check ({ packageGraph, report, root, ruleConfig }) {
|
|
27
|
-
const checkVersion =
|
|
21
|
+
const checkVersion = CheckVersionMap[ruleConfig.checkVersion];
|
|
28
22
|
const packages = packageGraph.getDuplicatePackages().filter((pkg)=>!ruleConfig.ignore.includes(pkg[0].name)).map((pkgs)=>pkgs.filter((current)=>{
|
|
29
|
-
const check = pkgs.reduce((ans, pkg)=>ans |
|
|
23
|
+
const check = pkgs.reduce((ans, pkg)=>ans | CheckVersionMap[diff(current.version, pkg.version) ?? 'null'], 0);
|
|
30
24
|
return check <= checkVersion;
|
|
31
25
|
}).sort((_packA, _packB)=>gt(_packA.version, _packB.version) ? 1 : -1)).filter((pkgs)=>pkgs.length > 1 && pkgs.filter((pkg)=>pkg.getSize().parsedSize > 0).length > 1);
|
|
32
26
|
for (const pkg of packages){
|
|
@@ -42,6 +42,16 @@ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_na
|
|
|
42
42
|
const types_namespaceObject = require("@rsdoctor/types");
|
|
43
43
|
const external_rule_cjs_namespaceObject = require("../../rule.cjs");
|
|
44
44
|
const title = 'esm-resolved-to-cjs';
|
|
45
|
+
function normalizePathForCompare(filePath) {
|
|
46
|
+
const queryIndex = filePath.indexOf('?');
|
|
47
|
+
const hashIndex = filePath.indexOf('#');
|
|
48
|
+
const splitIndex = [
|
|
49
|
+
queryIndex,
|
|
50
|
+
hashIndex
|
|
51
|
+
].filter((index)=>index >= 0).reduce((min, index)=>Math.min(min, index), 1 / 0);
|
|
52
|
+
const cleanPath = splitIndex === 1 / 0 ? filePath : filePath.slice(0, splitIndex);
|
|
53
|
+
return external_path_default().normalize(cleanPath);
|
|
54
|
+
}
|
|
45
55
|
function extractEsmEntry(pkgJson, pkgRoot) {
|
|
46
56
|
const { exports: exportsField, module: moduleField } = pkgJson;
|
|
47
57
|
if (null !== exportsField && 'object' == typeof exportsField) {
|
|
@@ -78,6 +88,7 @@ const rule = (0, external_rule_cjs_namespaceObject.defineRule)(()=>({
|
|
|
78
88
|
},
|
|
79
89
|
check ({ moduleGraph, packageGraph, report, ruleConfig }) {
|
|
80
90
|
const pkgJsonCache = new Map();
|
|
91
|
+
const realPathCache = new Map();
|
|
81
92
|
const readPkgJson = (pkgRoot)=>{
|
|
82
93
|
if (pkgJsonCache.has(pkgRoot)) return pkgJsonCache.get(pkgRoot);
|
|
83
94
|
try {
|
|
@@ -90,14 +101,31 @@ const rule = (0, external_rule_cjs_namespaceObject.defineRule)(()=>({
|
|
|
90
101
|
return null;
|
|
91
102
|
}
|
|
92
103
|
};
|
|
104
|
+
const toRealPath = (filePath)=>{
|
|
105
|
+
const normalized = normalizePathForCompare(filePath);
|
|
106
|
+
if (realPathCache.has(normalized)) return realPathCache.get(normalized);
|
|
107
|
+
try {
|
|
108
|
+
const realPath = 'function' == typeof external_fs_default().realpathSync.native ? external_fs_default().realpathSync.native(normalized) : external_fs_default().realpathSync(normalized);
|
|
109
|
+
const normalizedRealPath = external_path_default().normalize(realPath);
|
|
110
|
+
realPathCache.set(normalized, normalizedRealPath);
|
|
111
|
+
return normalizedRealPath;
|
|
112
|
+
} catch {
|
|
113
|
+
realPathCache.set(normalized, normalized);
|
|
114
|
+
return normalized;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
93
117
|
const groups = new Map();
|
|
94
118
|
const inNodeModules = /[/\\]node_modules[/\\]/;
|
|
95
119
|
for (const dep of moduleGraph.getDependencies()){
|
|
96
120
|
if (dep.kind !== types_namespaceObject.SDK.DependencyKind.ImportStatement || inNodeModules.test(dep.module.path) || !inNodeModules.test(dep.dependency.path) || dep.dependency.meta.strictHarmonyModule || ruleConfig.ignore.some((p)=>dep.request.includes(p))) continue;
|
|
97
121
|
const pkg = packageGraph.getPackageByModule(dep.dependency);
|
|
98
|
-
|
|
122
|
+
if (!pkg?.root) continue;
|
|
123
|
+
const pkgJson = readPkgJson(pkg.root);
|
|
124
|
+
const esmEntry = !ruleConfig.ignore.some((p)=>pkg.name.includes(p)) && pkgJson && extractEsmEntry(pkgJson, pkg.root);
|
|
99
125
|
if (!esmEntry) continue;
|
|
100
|
-
const
|
|
126
|
+
const resolvedModuleRealPath = toRealPath(dep.dependency.path);
|
|
127
|
+
if (resolvedModuleRealPath === toRealPath(esmEntry)) continue;
|
|
128
|
+
const groupKey = `${pkg.name}::${resolvedModuleRealPath}`;
|
|
101
129
|
const issuer = {
|
|
102
130
|
id: dep.module.id,
|
|
103
131
|
path: dep.module.path,
|
|
@@ -4,6 +4,16 @@ import path from "path";
|
|
|
4
4
|
import { Linter, SDK } from "@rsdoctor/types";
|
|
5
5
|
import { defineRule } from "../../rule.js";
|
|
6
6
|
const title = 'esm-resolved-to-cjs';
|
|
7
|
+
function normalizePathForCompare(filePath) {
|
|
8
|
+
const queryIndex = filePath.indexOf('?');
|
|
9
|
+
const hashIndex = filePath.indexOf('#');
|
|
10
|
+
const splitIndex = [
|
|
11
|
+
queryIndex,
|
|
12
|
+
hashIndex
|
|
13
|
+
].filter((index)=>index >= 0).reduce((min, index)=>Math.min(min, index), 1 / 0);
|
|
14
|
+
const cleanPath = splitIndex === 1 / 0 ? filePath : filePath.slice(0, splitIndex);
|
|
15
|
+
return path.normalize(cleanPath);
|
|
16
|
+
}
|
|
7
17
|
function extractEsmEntry(pkgJson, pkgRoot) {
|
|
8
18
|
const { exports: exportsField, module: moduleField } = pkgJson;
|
|
9
19
|
if (null !== exportsField && 'object' == typeof exportsField) {
|
|
@@ -40,6 +50,7 @@ const rule = defineRule(()=>({
|
|
|
40
50
|
},
|
|
41
51
|
check ({ moduleGraph, packageGraph, report, ruleConfig }) {
|
|
42
52
|
const pkgJsonCache = new Map();
|
|
53
|
+
const realPathCache = new Map();
|
|
43
54
|
const readPkgJson = (pkgRoot)=>{
|
|
44
55
|
if (pkgJsonCache.has(pkgRoot)) return pkgJsonCache.get(pkgRoot);
|
|
45
56
|
try {
|
|
@@ -52,14 +63,31 @@ const rule = defineRule(()=>({
|
|
|
52
63
|
return null;
|
|
53
64
|
}
|
|
54
65
|
};
|
|
66
|
+
const toRealPath = (filePath)=>{
|
|
67
|
+
const normalized = normalizePathForCompare(filePath);
|
|
68
|
+
if (realPathCache.has(normalized)) return realPathCache.get(normalized);
|
|
69
|
+
try {
|
|
70
|
+
const realPath = 'function' == typeof fs.realpathSync.native ? fs.realpathSync.native(normalized) : fs.realpathSync(normalized);
|
|
71
|
+
const normalizedRealPath = path.normalize(realPath);
|
|
72
|
+
realPathCache.set(normalized, normalizedRealPath);
|
|
73
|
+
return normalizedRealPath;
|
|
74
|
+
} catch {
|
|
75
|
+
realPathCache.set(normalized, normalized);
|
|
76
|
+
return normalized;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
55
79
|
const groups = new Map();
|
|
56
80
|
const inNodeModules = /[/\\]node_modules[/\\]/;
|
|
57
81
|
for (const dep of moduleGraph.getDependencies()){
|
|
58
82
|
if (dep.kind !== SDK.DependencyKind.ImportStatement || inNodeModules.test(dep.module.path) || !inNodeModules.test(dep.dependency.path) || dep.dependency.meta.strictHarmonyModule || ruleConfig.ignore.some((p)=>dep.request.includes(p))) continue;
|
|
59
83
|
const pkg = packageGraph.getPackageByModule(dep.dependency);
|
|
60
|
-
|
|
84
|
+
if (!pkg?.root) continue;
|
|
85
|
+
const pkgJson = readPkgJson(pkg.root);
|
|
86
|
+
const esmEntry = !ruleConfig.ignore.some((p)=>pkg.name.includes(p)) && pkgJson && extractEsmEntry(pkgJson, pkg.root);
|
|
61
87
|
if (!esmEntry) continue;
|
|
62
|
-
const
|
|
88
|
+
const resolvedModuleRealPath = toRealPath(dep.dependency.path);
|
|
89
|
+
if (resolvedModuleRealPath === toRealPath(esmEntry)) continue;
|
|
90
|
+
const groupKey = `${pkg.name}::${resolvedModuleRealPath}`;
|
|
63
91
|
const issuer = {
|
|
64
92
|
id: dep.module.id,
|
|
65
93
|
path: dep.module.path,
|