@rsdoctor/core 1.3.4 → 1.3.5
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/loader/probeLoader.cjs +3 -4
- package/dist/build-utils/build/loader/probeLoader.js +3 -4
- package/dist/build-utils/build/module-graph/treeShaking.cjs +1 -2
- package/dist/build-utils/build/module-graph/treeShaking.js +1 -2
- package/dist/build-utils/build/module-graph/utils.cjs +5 -7
- package/dist/build-utils/build/module-graph/utils.js +5 -7
- package/dist/build-utils/build/module-graph/webpack/transform.cjs +7 -9
- package/dist/build-utils/build/module-graph/webpack/transform.js +7 -9
- package/dist/build-utils/build/utils/loader.cjs +10 -11
- package/dist/build-utils/build/utils/loader.js +10 -11
- package/dist/build-utils/build/utils/parseBundle.cjs +10 -15
- package/dist/build-utils/build/utils/parseBundle.js +10 -15
- package/dist/build-utils/build/utils/plugin.cjs +2 -2
- package/dist/build-utils/build/utils/plugin.js +2 -2
- package/dist/inner-plugins/plugins/bundle.cjs +1 -4
- package/dist/inner-plugins/plugins/bundle.js +1 -4
- package/dist/inner-plugins/plugins/bundleTagPlugin.cjs +6 -15
- package/dist/inner-plugins/plugins/bundleTagPlugin.js +6 -15
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +3 -6
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +3 -6
- package/dist/inner-plugins/plugins/loader.cjs +1 -1
- package/dist/inner-plugins/plugins/loader.js +1 -1
- package/dist/inner-plugins/plugins/sourcemapTool.cjs +10 -17
- package/dist/inner-plugins/plugins/sourcemapTool.js +10 -17
- package/dist/inner-plugins/utils/config.cjs +1 -2
- package/dist/inner-plugins/utils/config.js +1 -2
- package/dist/inner-plugins/utils/loader.cjs +6 -8
- package/dist/inner-plugins/utils/loader.js +6 -8
- package/dist/inner-plugins/utils/normalize-config.cjs +7 -8
- package/dist/inner-plugins/utils/normalize-config.js +7 -8
- package/dist/inner-plugins/utils/plugin-common.cjs +4 -5
- package/dist/inner-plugins/utils/plugin-common.js +4 -5
- package/dist/inner-plugins/utils/plugin.cjs +2 -3
- package/dist/inner-plugins/utils/plugin.js +2 -3
- package/dist/rules/rules/default-import-check/index.cjs +1 -1
- package/dist/rules/rules/default-import-check/index.js +1 -1
- package/dist/rules/rules/default-import-check/utils.cjs +1 -2
- package/dist/rules/rules/default-import-check/utils.js +1 -2
- package/dist/rules/rules/ecma-version-check/index.cjs +3 -4
- package/dist/rules/rules/ecma-version-check/index.js +3 -4
- package/dist/rules/rules/ecma-version-check/utils.cjs +1 -1
- package/dist/rules/rules/ecma-version-check/utils.js +1 -1
- package/dist/rules/rules/loader-performance-optimization/index.cjs +1 -1
- package/dist/rules/rules/loader-performance-optimization/index.js +1 -1
- package/package.json +7 -7
|
@@ -42,18 +42,17 @@ const compat_namespaceObject = require("es-toolkit/compat");
|
|
|
42
42
|
const external_path_namespaceObject = require("path");
|
|
43
43
|
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
44
44
|
const loaderModule = function(...args) {
|
|
45
|
-
var _this__module, _this__module1;
|
|
46
45
|
const time = Date.now();
|
|
47
46
|
const code = args[0];
|
|
48
47
|
const _options = this.getOptions();
|
|
49
48
|
const sdk = (0, index_cjs_namespaceObject.getSDK)(_options.builderName);
|
|
50
49
|
const loaderData = {
|
|
51
50
|
resource: {
|
|
52
|
-
path:
|
|
51
|
+
path: this._module?.layer ? `${this.resourcePath}[${this._module.layer}]` : this.resourcePath,
|
|
53
52
|
query: external_index_cjs_namespaceObject.Build.Utils.parseQuery(this.resourceQuery),
|
|
54
53
|
queryRaw: this.resourceQuery,
|
|
55
54
|
ext: external_path_default().extname(this.resourcePath).slice(1),
|
|
56
|
-
...
|
|
55
|
+
...this._module?.layer ? {
|
|
57
56
|
layer: this._module.layer
|
|
58
57
|
} : {}
|
|
59
58
|
},
|
|
@@ -75,7 +74,7 @@ const loaderModule = function(...args) {
|
|
|
75
74
|
}
|
|
76
75
|
]
|
|
77
76
|
};
|
|
78
|
-
|
|
77
|
+
sdk?.reportLoaderStartOrEnd(loaderData);
|
|
79
78
|
this.callback(null, ...args);
|
|
80
79
|
};
|
|
81
80
|
const probeLoader = loaderModule;
|
|
@@ -5,18 +5,17 @@ import { getSDK } from "../../../inner-plugins/index.js";
|
|
|
5
5
|
import { omit } from "es-toolkit/compat";
|
|
6
6
|
import path from "path";
|
|
7
7
|
const loaderModule = function(...args) {
|
|
8
|
-
var _this__module, _this__module1;
|
|
9
8
|
const time = Date.now();
|
|
10
9
|
const code = args[0];
|
|
11
10
|
const _options = this.getOptions();
|
|
12
11
|
const sdk = getSDK(_options.builderName);
|
|
13
12
|
const loaderData = {
|
|
14
13
|
resource: {
|
|
15
|
-
path:
|
|
14
|
+
path: this._module?.layer ? `${this.resourcePath}[${this._module.layer}]` : this.resourcePath,
|
|
16
15
|
query: Build.Utils.parseQuery(this.resourceQuery),
|
|
17
16
|
queryRaw: this.resourceQuery,
|
|
18
17
|
ext: path.extname(this.resourcePath).slice(1),
|
|
19
|
-
...
|
|
18
|
+
...this._module?.layer ? {
|
|
20
19
|
layer: this._module.layer
|
|
21
20
|
} : {}
|
|
22
21
|
},
|
|
@@ -38,7 +37,7 @@ const loaderModule = function(...args) {
|
|
|
38
37
|
}
|
|
39
38
|
]
|
|
40
39
|
};
|
|
41
|
-
|
|
40
|
+
sdk?.reportLoaderStartOrEnd(loaderData);
|
|
42
41
|
this.callback(null, ...args);
|
|
43
42
|
};
|
|
44
43
|
const probeLoader = loaderModule;
|
|
@@ -76,9 +76,8 @@ function appendImportConnection(origin, graph) {
|
|
|
76
76
|
const mgm = graph.getModuleGraphModule(module);
|
|
77
77
|
if (!mgm || !module) return;
|
|
78
78
|
for (const info of mgm.getSideEffects()){
|
|
79
|
-
var _info_fromDependency;
|
|
80
79
|
const exportName = info.originName ?? info.name;
|
|
81
|
-
const resolveModule =
|
|
80
|
+
const resolveModule = info.fromDependency?.dependency;
|
|
82
81
|
if (!resolveModule) continue;
|
|
83
82
|
const resolveExport = graph.getModuleGraphModule(resolveModule).getExport(exportName);
|
|
84
83
|
if (resolveExport) info.setExportInfo(resolveExport);
|
|
@@ -50,9 +50,8 @@ function appendImportConnection(origin, graph) {
|
|
|
50
50
|
const mgm = graph.getModuleGraphModule(module);
|
|
51
51
|
if (!mgm || !module) return;
|
|
52
52
|
for (const info of mgm.getSideEffects()){
|
|
53
|
-
var _info_fromDependency;
|
|
54
53
|
const exportName = info.originName ?? info.name;
|
|
55
|
-
const resolveModule =
|
|
54
|
+
const resolveModule = info.fromDependency?.dependency;
|
|
56
55
|
if (!resolveModule) continue;
|
|
57
56
|
const resolveExport = graph.getModuleGraphModule(resolveModule).getExport(exportName);
|
|
58
57
|
if (resolveExport) info.setExportInfo(resolveExport);
|
|
@@ -30,7 +30,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
30
30
|
const compat_namespaceObject = require("es-toolkit/compat");
|
|
31
31
|
const ruleUtils_namespaceObject = require("@rsdoctor/utils/ruleUtils");
|
|
32
32
|
function getDefaultExportIdentifier(node, module, searchId) {
|
|
33
|
-
var _node_declaration_loc;
|
|
34
33
|
const { declaration } = node;
|
|
35
34
|
if (ruleUtils_namespaceObject.parser.asserts.isLiteral(declaration) && declaration.loc) return module.getStatement(declaration.loc);
|
|
36
35
|
if (ruleUtils_namespaceObject.parser.asserts.isIdentifier(declaration)) {
|
|
@@ -40,10 +39,9 @@ function getDefaultExportIdentifier(node, module, searchId) {
|
|
|
40
39
|
} else if (declaration.loc) return module.getStatement(declaration.loc);
|
|
41
40
|
}
|
|
42
41
|
if (ruleUtils_namespaceObject.parser.asserts.isClassDeclaration(declaration) || ruleUtils_namespaceObject.parser.asserts.isFunctionDeclaration(declaration)) {
|
|
43
|
-
|
|
44
|
-
if (null == (_declaration_id = declaration.id) ? void 0 : _declaration_id.loc) return module.getStatement(declaration.id.loc);
|
|
42
|
+
if (declaration.id?.loc) return module.getStatement(declaration.id.loc);
|
|
45
43
|
}
|
|
46
|
-
const startLine =
|
|
44
|
+
const startLine = node.declaration.loc?.start.line;
|
|
47
45
|
if (!(0, compat_namespaceObject.isNumber)(startLine)) return;
|
|
48
46
|
const { transformed } = module.getSource();
|
|
49
47
|
const endColumn = transformed.split('\n')[startLine - 1].length - 1;
|
|
@@ -67,7 +65,7 @@ function getExportIdentifierStatement(name, module) {
|
|
|
67
65
|
if (result) return result;
|
|
68
66
|
}
|
|
69
67
|
const id = ruleUtils_namespaceObject.parser.utils.getIdentifierInExport(name, node);
|
|
70
|
-
if (
|
|
68
|
+
if (id?.loc) return module.getStatement(id.loc);
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
71
|
function getDeclarationIdentifier(name, module) {
|
|
@@ -75,10 +73,10 @@ function getDeclarationIdentifier(name, module) {
|
|
|
75
73
|
if (!ast) return;
|
|
76
74
|
for (const node of ast.body){
|
|
77
75
|
const id = ruleUtils_namespaceObject.parser.utils.getIdentifierInDeclaration(name, node);
|
|
78
|
-
if (
|
|
76
|
+
if (id?.loc) return module.getStatement(id.loc);
|
|
79
77
|
if (ruleUtils_namespaceObject.parser.asserts.isExportNamedDeclaration(node) && node.declaration) {
|
|
80
78
|
const id = ruleUtils_namespaceObject.parser.utils.getIdentifierInDeclaration(name, node.declaration);
|
|
81
|
-
if (
|
|
79
|
+
if (id?.loc) return module.getStatement(id.loc);
|
|
82
80
|
}
|
|
83
81
|
if ('default' === name && ruleUtils_namespaceObject.parser.asserts.isExportDefaultDeclaration(node)) {
|
|
84
82
|
const result = getDefaultExportIdentifier(node, module, true);
|
|
@@ -3,7 +3,6 @@ import 'module';
|
|
|
3
3
|
import { isNumber } from "es-toolkit/compat";
|
|
4
4
|
import { parser } from "@rsdoctor/utils/ruleUtils";
|
|
5
5
|
function getDefaultExportIdentifier(node, module, searchId) {
|
|
6
|
-
var _node_declaration_loc;
|
|
7
6
|
const { declaration } = node;
|
|
8
7
|
if (parser.asserts.isLiteral(declaration) && declaration.loc) return module.getStatement(declaration.loc);
|
|
9
8
|
if (parser.asserts.isIdentifier(declaration)) {
|
|
@@ -13,10 +12,9 @@ function getDefaultExportIdentifier(node, module, searchId) {
|
|
|
13
12
|
} else if (declaration.loc) return module.getStatement(declaration.loc);
|
|
14
13
|
}
|
|
15
14
|
if (parser.asserts.isClassDeclaration(declaration) || parser.asserts.isFunctionDeclaration(declaration)) {
|
|
16
|
-
|
|
17
|
-
if (null == (_declaration_id = declaration.id) ? void 0 : _declaration_id.loc) return module.getStatement(declaration.id.loc);
|
|
15
|
+
if (declaration.id?.loc) return module.getStatement(declaration.id.loc);
|
|
18
16
|
}
|
|
19
|
-
const startLine =
|
|
17
|
+
const startLine = node.declaration.loc?.start.line;
|
|
20
18
|
if (!isNumber(startLine)) return;
|
|
21
19
|
const { transformed } = module.getSource();
|
|
22
20
|
const endColumn = transformed.split('\n')[startLine - 1].length - 1;
|
|
@@ -40,7 +38,7 @@ function getExportIdentifierStatement(name, module) {
|
|
|
40
38
|
if (result) return result;
|
|
41
39
|
}
|
|
42
40
|
const id = parser.utils.getIdentifierInExport(name, node);
|
|
43
|
-
if (
|
|
41
|
+
if (id?.loc) return module.getStatement(id.loc);
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
function getDeclarationIdentifier(name, module) {
|
|
@@ -48,10 +46,10 @@ function getDeclarationIdentifier(name, module) {
|
|
|
48
46
|
if (!ast) return;
|
|
49
47
|
for (const node of ast.body){
|
|
50
48
|
const id = parser.utils.getIdentifierInDeclaration(name, node);
|
|
51
|
-
if (
|
|
49
|
+
if (id?.loc) return module.getStatement(id.loc);
|
|
52
50
|
if (parser.asserts.isExportNamedDeclaration(node) && node.declaration) {
|
|
53
51
|
const id = parser.utils.getIdentifierInDeclaration(name, node.declaration);
|
|
54
|
-
if (
|
|
52
|
+
if (id?.loc) return module.getStatement(id.loc);
|
|
55
53
|
}
|
|
56
54
|
if ('default' === name && parser.asserts.isExportDefaultDeclaration(node)) {
|
|
57
55
|
const result = getDefaultExportIdentifier(node, module, true);
|
|
@@ -43,8 +43,7 @@ const external_parser_cjs_namespaceObject = require("../parser.cjs");
|
|
|
43
43
|
const compat_namespaceObject = require("es-toolkit/compat");
|
|
44
44
|
const logger_namespaceObject = require("@rsdoctor/utils/logger");
|
|
45
45
|
async function readFile(target, wbFs) {
|
|
46
|
-
|
|
47
|
-
if (null == wbFs ? void 0 : null == (_wbFs_fs = wbFs.fs) ? void 0 : _wbFs_fs.readFile) {
|
|
46
|
+
if (wbFs?.fs?.readFile) {
|
|
48
47
|
const result = new Promise((resolve, reject)=>{
|
|
49
48
|
wbFs.fs.readFile(target, (err, content)=>{
|
|
50
49
|
if (err) return void reject(err);
|
|
@@ -65,7 +64,7 @@ function getModuleExportsType(module, moduleGraph, strict = false) {
|
|
|
65
64
|
return strict ? 'default-with-named' : 'dynamic';
|
|
66
65
|
}
|
|
67
66
|
function appendDependency(webpackDep, module, webpackGraph, graph) {
|
|
68
|
-
const resolvedWebpackModule =
|
|
67
|
+
const resolvedWebpackModule = webpackGraph?.getResolvedModule ? webpackGraph.getResolvedModule(webpackDep) : void 0;
|
|
69
68
|
if (!resolvedWebpackModule) return;
|
|
70
69
|
const rawRequest = graph_namespaceObject.Webpack.getWebpackDependencyRequest(webpackDep, resolvedWebpackModule);
|
|
71
70
|
const resolveRequest = graph_namespaceObject.Webpack.getWebpackModulePath(resolvedWebpackModule);
|
|
@@ -103,16 +102,15 @@ async function appendModuleData(origin, webpackGraph, graph, wbFs, features, con
|
|
|
103
102
|
if (!origin || !module) return;
|
|
104
103
|
const { getSourceMap, astCache, packagePathMap } = context ?? {};
|
|
105
104
|
try {
|
|
106
|
-
|
|
107
|
-
const sourceMap = await (null == getSourceMap ? void 0 : getSourceMap(module.path));
|
|
105
|
+
const sourceMap = await getSourceMap?.(module.path);
|
|
108
106
|
const source = await getModuleSource(module.path, wbFs, sourceMap) ?? Buffer.from('');
|
|
109
107
|
if (sourceMap) module.setSourceMap(sourceMap);
|
|
110
|
-
if (
|
|
108
|
+
if (astCache?.has(origin)) {
|
|
111
109
|
const program = astCache.get(origin);
|
|
112
110
|
module.setProgram(program);
|
|
113
111
|
module.meta.hasSetEsModuleStatement = (0, external_parser_cjs_namespaceObject.hasSetEsModuleStatement)(program);
|
|
114
112
|
}
|
|
115
|
-
const transformed = graph_namespaceObject.Webpack.isExternalModule(origin) ? '' : module.getSource().transformed.length > 0 ? module.getSource().transformed : (0, compat_namespaceObject.isFunction)(
|
|
113
|
+
const transformed = graph_namespaceObject.Webpack.isExternalModule(origin) ? '' : module.getSource().transformed.length > 0 ? module.getSource().transformed : (0, compat_namespaceObject.isFunction)(origin?.originalSource) ? origin.originalSource()?.source()?.toString() ?? '' : '';
|
|
116
114
|
const transformedSize = graph_namespaceObject.Webpack.isExternalModule(origin) ? 0 : module.getSize().transformedSize > 0 ? module.getSize().transformedSize : Buffer.from(transformed).byteLength;
|
|
117
115
|
module.setSource({
|
|
118
116
|
transformed,
|
|
@@ -141,9 +139,9 @@ async function appendModuleData(origin, webpackGraph, graph, wbFs, features, con
|
|
|
141
139
|
};
|
|
142
140
|
}
|
|
143
141
|
}
|
|
144
|
-
module.meta.strictHarmonyModule =
|
|
142
|
+
module.meta.strictHarmonyModule = origin.buildMeta?.strictHarmonyModule ?? false;
|
|
145
143
|
module.meta.packageData = packageData;
|
|
146
|
-
if (!
|
|
144
|
+
if (!features?.lite && origin?.dependencies) Array.from(origin.dependencies).filter((item)=>graph_namespaceObject.ModuleGraphTrans.isImportDependency(item)).concat(origin.blocks.reduce((ans, item)=>ans.concat(item.dependencies), [])).forEach((dep)=>appendDependency(dep, module, webpackGraph, graph));
|
|
147
145
|
} catch (e) {
|
|
148
146
|
console.error(`module ${module.path} transform has error:`, e);
|
|
149
147
|
}
|
|
@@ -6,8 +6,7 @@ import { hasSetEsModuleStatement } from "../parser.js";
|
|
|
6
6
|
import { isFunction } from "es-toolkit/compat";
|
|
7
7
|
import { logger } from "@rsdoctor/utils/logger";
|
|
8
8
|
async function readFile(target, wbFs) {
|
|
9
|
-
|
|
10
|
-
if (null == wbFs ? void 0 : null == (_wbFs_fs = wbFs.fs) ? void 0 : _wbFs_fs.readFile) {
|
|
9
|
+
if (wbFs?.fs?.readFile) {
|
|
11
10
|
const result = new Promise((resolve, reject)=>{
|
|
12
11
|
wbFs.fs.readFile(target, (err, content)=>{
|
|
13
12
|
if (err) return void reject(err);
|
|
@@ -28,7 +27,7 @@ function getModuleExportsType(module, moduleGraph, strict = false) {
|
|
|
28
27
|
return strict ? 'default-with-named' : 'dynamic';
|
|
29
28
|
}
|
|
30
29
|
function appendDependency(webpackDep, module, webpackGraph, graph) {
|
|
31
|
-
const resolvedWebpackModule =
|
|
30
|
+
const resolvedWebpackModule = webpackGraph?.getResolvedModule ? webpackGraph.getResolvedModule(webpackDep) : void 0;
|
|
32
31
|
if (!resolvedWebpackModule) return;
|
|
33
32
|
const rawRequest = Webpack.getWebpackDependencyRequest(webpackDep, resolvedWebpackModule);
|
|
34
33
|
const resolveRequest = Webpack.getWebpackModulePath(resolvedWebpackModule);
|
|
@@ -66,16 +65,15 @@ async function appendModuleData(origin, webpackGraph, graph, wbFs, features, con
|
|
|
66
65
|
if (!origin || !module) return;
|
|
67
66
|
const { getSourceMap, astCache, packagePathMap } = context ?? {};
|
|
68
67
|
try {
|
|
69
|
-
|
|
70
|
-
const sourceMap = await (null == getSourceMap ? void 0 : getSourceMap(module.path));
|
|
68
|
+
const sourceMap = await getSourceMap?.(module.path);
|
|
71
69
|
const source = await getModuleSource(module.path, wbFs, sourceMap) ?? Buffer.from('');
|
|
72
70
|
if (sourceMap) module.setSourceMap(sourceMap);
|
|
73
|
-
if (
|
|
71
|
+
if (astCache?.has(origin)) {
|
|
74
72
|
const program = astCache.get(origin);
|
|
75
73
|
module.setProgram(program);
|
|
76
74
|
module.meta.hasSetEsModuleStatement = hasSetEsModuleStatement(program);
|
|
77
75
|
}
|
|
78
|
-
const transformed = Webpack.isExternalModule(origin) ? '' : module.getSource().transformed.length > 0 ? module.getSource().transformed : isFunction(
|
|
76
|
+
const transformed = Webpack.isExternalModule(origin) ? '' : module.getSource().transformed.length > 0 ? module.getSource().transformed : isFunction(origin?.originalSource) ? origin.originalSource()?.source()?.toString() ?? '' : '';
|
|
79
77
|
const transformedSize = Webpack.isExternalModule(origin) ? 0 : module.getSize().transformedSize > 0 ? module.getSize().transformedSize : Buffer.from(transformed).byteLength;
|
|
80
78
|
module.setSource({
|
|
81
79
|
transformed,
|
|
@@ -104,9 +102,9 @@ async function appendModuleData(origin, webpackGraph, graph, wbFs, features, con
|
|
|
104
102
|
};
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
|
-
module.meta.strictHarmonyModule =
|
|
105
|
+
module.meta.strictHarmonyModule = origin.buildMeta?.strictHarmonyModule ?? false;
|
|
108
106
|
module.meta.packageData = packageData;
|
|
109
|
-
if (!
|
|
107
|
+
if (!features?.lite && origin?.dependencies) Array.from(origin.dependencies).filter((item)=>ModuleGraphTrans.isImportDependency(item)).concat(origin.blocks.reduce((ans, item)=>ans.concat(item.dependencies), [])).forEach((dep)=>appendDependency(dep, module, webpackGraph, graph));
|
|
110
108
|
} catch (e) {
|
|
111
109
|
console.error(`module ${module.path} transform has error:`, e);
|
|
112
110
|
}
|
|
@@ -76,13 +76,12 @@ var __webpack_exports__ = {};
|
|
|
76
76
|
function parsePathQueryFragment(str) {
|
|
77
77
|
const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
|
|
78
78
|
return {
|
|
79
|
-
path:
|
|
80
|
-
query:
|
|
81
|
-
fragment:
|
|
79
|
+
path: match?.[1].replace(/\0(.)/g, '$1') || '',
|
|
80
|
+
query: match?.[2] ? match[2].replace(/\0(.)/g, '$1') : '',
|
|
81
|
+
fragment: match?.[3] || ''
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
function loadLoaderModule(loaderPath, cwd = process.cwd()) {
|
|
85
|
-
var _mod_default, _mod_default1;
|
|
86
85
|
const cleanLoaderPath = parsePathQueryFragment(loaderPath).path;
|
|
87
86
|
const { createRequire } = __webpack_require__("module");
|
|
88
87
|
const requireFn = createRequire(__rslib_import_meta_url__);
|
|
@@ -95,8 +94,8 @@ var __webpack_exports__ = {};
|
|
|
95
94
|
const isESM = mod.__esModule && 'function' == typeof mod.default;
|
|
96
95
|
return {
|
|
97
96
|
default: isESM ? mod.default : 'function' == typeof mod ? mod : null,
|
|
98
|
-
pitch:
|
|
99
|
-
raw:
|
|
97
|
+
pitch: mod.default?.pitch || mod.pitch,
|
|
98
|
+
raw: mod.default?.raw || mod.raw || false
|
|
100
99
|
};
|
|
101
100
|
}
|
|
102
101
|
function extractLoaderName(loaderPath, cwd = '') {
|
|
@@ -169,7 +168,7 @@ var __webpack_exports__ = {};
|
|
|
169
168
|
});
|
|
170
169
|
}
|
|
171
170
|
function isESMLoader(r) {
|
|
172
|
-
let _loaderName = 'object' == typeof r && 'string' == typeof
|
|
171
|
+
let _loaderName = 'object' == typeof r && 'string' == typeof r?.loader ? r.loader : 'string' == typeof r ? r : '';
|
|
173
172
|
if (!_loaderName) return false;
|
|
174
173
|
const isPath = external_node_path_default().isAbsolute(_loaderName) || _loaderName.startsWith('./') || _loaderName.startsWith('../');
|
|
175
174
|
if (isPath) {
|
|
@@ -182,7 +181,7 @@ var __webpack_exports__ = {};
|
|
|
182
181
|
logger_namespaceObject.logger.debug(`isESMLoader function error:${e}`);
|
|
183
182
|
}
|
|
184
183
|
});
|
|
185
|
-
if (
|
|
184
|
+
if (packageJsonData?.type === 'module' && !packageJsonData?.name.includes('@rsdoctor/')) return true;
|
|
186
185
|
}
|
|
187
186
|
return false;
|
|
188
187
|
}
|
|
@@ -209,8 +208,8 @@ var __webpack_exports__ = {};
|
|
|
209
208
|
];
|
|
210
209
|
}
|
|
211
210
|
function getLoaderNameMatch(r, loaderName, strict = true) {
|
|
212
|
-
if (!strict) return 'object' == typeof r && 'string' == typeof
|
|
213
|
-
return 'object' == typeof r && 'string' == typeof
|
|
211
|
+
if (!strict) return 'object' == typeof r && 'string' == typeof r?.loader && r.loader.includes(loaderName) || 'string' == typeof r && r.includes(loaderName);
|
|
212
|
+
return 'object' == typeof r && 'string' == typeof r?.loader && r.loader === loaderName || 'string' == typeof r && r === loaderName;
|
|
214
213
|
}
|
|
215
214
|
function addProbeLoader2Rules(rules, compiler, fn) {
|
|
216
215
|
return rules.map((rule)=>{
|
|
@@ -292,7 +291,7 @@ var __webpack_exports__ = {};
|
|
|
292
291
|
if (options.hasOptions) return (0, compat_namespaceObject.omit)(target.query, [
|
|
293
292
|
common_namespaceObject.Loader.LoaderInternalPropertyName
|
|
294
293
|
]);
|
|
295
|
-
const innerLoaderPath =
|
|
294
|
+
const innerLoaderPath = options?.loader;
|
|
296
295
|
const loaderQuery = parsePathQueryFragment(innerLoaderPath).query;
|
|
297
296
|
return loaderQuery;
|
|
298
297
|
}
|
|
@@ -29,13 +29,12 @@ const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)
|
|
|
29
29
|
function parsePathQueryFragment(str) {
|
|
30
30
|
const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
|
|
31
31
|
return {
|
|
32
|
-
path:
|
|
33
|
-
query:
|
|
34
|
-
fragment:
|
|
32
|
+
path: match?.[1].replace(/\0(.)/g, '$1') || '',
|
|
33
|
+
query: match?.[2] ? match[2].replace(/\0(.)/g, '$1') : '',
|
|
34
|
+
fragment: match?.[3] || ''
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
function loadLoaderModule(loaderPath, cwd = process.cwd()) {
|
|
38
|
-
var _mod_default, _mod_default1;
|
|
39
38
|
const cleanLoaderPath = parsePathQueryFragment(loaderPath).path;
|
|
40
39
|
const { createRequire } = __webpack_require__("module");
|
|
41
40
|
const requireFn = createRequire(import.meta.url);
|
|
@@ -48,8 +47,8 @@ function loadLoaderModule(loaderPath, cwd = process.cwd()) {
|
|
|
48
47
|
const isESM = mod.__esModule && 'function' == typeof mod.default;
|
|
49
48
|
return {
|
|
50
49
|
default: isESM ? mod.default : 'function' == typeof mod ? mod : null,
|
|
51
|
-
pitch:
|
|
52
|
-
raw:
|
|
50
|
+
pitch: mod.default?.pitch || mod.pitch,
|
|
51
|
+
raw: mod.default?.raw || mod.raw || false
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
54
|
function extractLoaderName(loaderPath, cwd = '') {
|
|
@@ -122,7 +121,7 @@ function mapEachRules(rules, callback) {
|
|
|
122
121
|
});
|
|
123
122
|
}
|
|
124
123
|
function isESMLoader(r) {
|
|
125
|
-
let _loaderName = 'object' == typeof r && 'string' == typeof
|
|
124
|
+
let _loaderName = 'object' == typeof r && 'string' == typeof r?.loader ? r.loader : 'string' == typeof r ? r : '';
|
|
126
125
|
if (!_loaderName) return false;
|
|
127
126
|
const isPath = node_path.isAbsolute(_loaderName) || _loaderName.startsWith('./') || _loaderName.startsWith('../');
|
|
128
127
|
if (isPath) {
|
|
@@ -135,7 +134,7 @@ function isESMLoader(r) {
|
|
|
135
134
|
logger.debug(`isESMLoader function error:${e}`);
|
|
136
135
|
}
|
|
137
136
|
});
|
|
138
|
-
if (
|
|
137
|
+
if (packageJsonData?.type === 'module' && !packageJsonData?.name.includes('@rsdoctor/')) return true;
|
|
139
138
|
}
|
|
140
139
|
return false;
|
|
141
140
|
}
|
|
@@ -162,8 +161,8 @@ function appendProbeLoaders(compiler, loaderConfig) {
|
|
|
162
161
|
];
|
|
163
162
|
}
|
|
164
163
|
function getLoaderNameMatch(r, loaderName, strict = true) {
|
|
165
|
-
if (!strict) return 'object' == typeof r && 'string' == typeof
|
|
166
|
-
return 'object' == typeof r && 'string' == typeof
|
|
164
|
+
if (!strict) return 'object' == typeof r && 'string' == typeof r?.loader && r.loader.includes(loaderName) || 'string' == typeof r && r.includes(loaderName);
|
|
165
|
+
return 'object' == typeof r && 'string' == typeof r?.loader && r.loader === loaderName || 'string' == typeof r && r === loaderName;
|
|
167
166
|
}
|
|
168
167
|
function addProbeLoader2Rules(rules, compiler, fn) {
|
|
169
168
|
return rules.map((rule)=>{
|
|
@@ -245,7 +244,7 @@ function createLoaderContextTrap(final) {
|
|
|
245
244
|
if (options.hasOptions) return omit(target.query, [
|
|
246
245
|
Loader.LoaderInternalPropertyName
|
|
247
246
|
]);
|
|
248
|
-
const innerLoaderPath =
|
|
247
|
+
const innerLoaderPath = options?.loader;
|
|
249
248
|
const loaderQuery = parsePathQueryFragment(innerLoaderPath).query;
|
|
250
249
|
return loaderQuery;
|
|
251
250
|
}
|
|
@@ -49,9 +49,8 @@ const parseBundle = (bundlePath, modulesData)=>{
|
|
|
49
49
|
const tagCache = new Map();
|
|
50
50
|
let hasBannerPlugin = content.indexOf('RSDOCTOR_START::') > 0;
|
|
51
51
|
if (hasBannerPlugin && !tagCache.get(bundlePath)) {
|
|
52
|
-
var _tagMatchResult_result;
|
|
53
52
|
const tagMatchResult = getStringBetween(content, 0, /([a-z|A-Z|_]+\.[a-z]+)\(\SRSDOCTOR_START::(.*?)[;,]/, /([a-z|A-Z|_]+\.[a-z]+)\(\SRSDOCTOR_END::(.*?)\)/);
|
|
54
|
-
content =
|
|
53
|
+
content = tagMatchResult.result?.trim() || content;
|
|
55
54
|
tagCache.set(bundlePath, tagMatchResult.loc);
|
|
56
55
|
hasBannerPlugin = true;
|
|
57
56
|
} else if (hasBannerPlugin && !tagCache.get(bundlePath)) {
|
|
@@ -94,10 +93,7 @@ const parseBundle = (bundlePath, modulesData)=>{
|
|
|
94
93
|
if (state.locations) return;
|
|
95
94
|
try {
|
|
96
95
|
if (hasBannerPlugin) {
|
|
97
|
-
const firstVariableDeclaration = node.body.find((node)=>
|
|
98
|
-
var _node_declarations__init, _node_declarations_, _node_declarations, _node_declarations__init_properties, _node_declarations__init1, _node_declarations_1, _node_declarations1;
|
|
99
|
-
return 'VariableDeclaration' === node.type && (null == (_node_declarations = node.declarations) ? void 0 : null == (_node_declarations_ = _node_declarations[0]) ? void 0 : null == (_node_declarations__init = _node_declarations_.init) ? void 0 : _node_declarations__init.type) === 'ObjectExpression' && (null == (_node_declarations1 = node.declarations) ? void 0 : null == (_node_declarations_1 = _node_declarations1[0]) ? void 0 : null == (_node_declarations__init1 = _node_declarations_1.init) ? void 0 : null == (_node_declarations__init_properties = _node_declarations__init1.properties) ? void 0 : _node_declarations__init_properties.length);
|
|
100
|
-
});
|
|
96
|
+
const firstVariableDeclaration = node.body.find((node)=>'VariableDeclaration' === node.type && node.declarations?.[0]?.init?.type === 'ObjectExpression' && node.declarations?.[0]?.init?.properties?.length);
|
|
101
97
|
if (firstVariableDeclaration) {
|
|
102
98
|
for (const declaration of firstVariableDeclaration.declarations)if (declaration.init) {
|
|
103
99
|
state.locations = getModulesLocations(declaration.init);
|
|
@@ -114,7 +110,7 @@ const parseBundle = (bundlePath, modulesData)=>{
|
|
|
114
110
|
AssignmentExpression (node, state) {
|
|
115
111
|
if (state.locations) return;
|
|
116
112
|
const { left, right } = node;
|
|
117
|
-
if (
|
|
113
|
+
if (left?.object && 'exports' === left.object.name && left.property && 'modules' === left.property.name && isModulesHash(right)) state.locations = getModulesLocations(right);
|
|
118
114
|
},
|
|
119
115
|
CallExpression (node, state, c) {
|
|
120
116
|
if (state.locations) return;
|
|
@@ -142,13 +138,12 @@ const parseBundle = (bundlePath, modulesData)=>{
|
|
|
142
138
|
modules = walkState.locations ? (0, compat_namespaceObject.mapValues)(walkState.locations, (loc)=>content.slice(loc.start, loc.end)) : {};
|
|
143
139
|
const modulesObj = {};
|
|
144
140
|
for(const module in modules){
|
|
145
|
-
var _find;
|
|
146
141
|
if (!module) return {};
|
|
147
142
|
const moduleContent = modules[module];
|
|
148
143
|
const size = moduleContent && Buffer.byteLength(moduleContent);
|
|
149
|
-
const identifier = (
|
|
144
|
+
const identifier = (0, compat_namespaceObject.find)(modulesData, {
|
|
150
145
|
renderId: module
|
|
151
|
-
})
|
|
146
|
+
})?.webpackId || '';
|
|
152
147
|
modulesObj[identifier] = {
|
|
153
148
|
size,
|
|
154
149
|
sizeConvert: (0, external_filesize_namespaceObject.filesize)(size || 0),
|
|
@@ -245,15 +240,15 @@ function getModuleLocation(node) {
|
|
|
245
240
|
function getStringBetween(raw, position, start, end) {
|
|
246
241
|
try {
|
|
247
242
|
const matchStart = raw.match(start);
|
|
248
|
-
const startFlagIndex =
|
|
249
|
-
if (-1 === startFlagIndex || !
|
|
243
|
+
const startFlagIndex = matchStart?.length ? raw.indexOf(matchStart[0], position) : -1;
|
|
244
|
+
if (-1 === startFlagIndex || !matchStart?.length) return {
|
|
250
245
|
result: null,
|
|
251
246
|
remain: position
|
|
252
247
|
};
|
|
253
248
|
const startTagLength = matchStart[0].length;
|
|
254
249
|
const matchEnd = raw.match(end);
|
|
255
|
-
const endFlagIndex =
|
|
256
|
-
if (-1 === endFlagIndex || !
|
|
250
|
+
const endFlagIndex = matchEnd?.length ? raw.indexOf(matchEnd[0], startFlagIndex + startTagLength) : -1;
|
|
251
|
+
if (-1 === endFlagIndex || !matchEnd?.length) return {
|
|
257
252
|
result: null,
|
|
258
253
|
remain: position
|
|
259
254
|
};
|
|
@@ -261,7 +256,7 @@ function getStringBetween(raw, position, start, end) {
|
|
|
261
256
|
if (innerContent.endsWith(',')) innerContent = innerContent.slice(0, -1);
|
|
262
257
|
return {
|
|
263
258
|
result: innerContent,
|
|
264
|
-
remain:
|
|
259
|
+
remain: matchEnd?.length ? endFlagIndex + matchEnd[0].length : endFlagIndex,
|
|
265
260
|
loc: {
|
|
266
261
|
start: startFlagIndex + startTagLength,
|
|
267
262
|
end: endFlagIndex
|
|
@@ -13,9 +13,8 @@ const parseBundle = (bundlePath, modulesData)=>{
|
|
|
13
13
|
const tagCache = new Map();
|
|
14
14
|
let hasBannerPlugin = content.indexOf('RSDOCTOR_START::') > 0;
|
|
15
15
|
if (hasBannerPlugin && !tagCache.get(bundlePath)) {
|
|
16
|
-
var _tagMatchResult_result;
|
|
17
16
|
const tagMatchResult = getStringBetween(content, 0, /([a-z|A-Z|_]+\.[a-z]+)\(\SRSDOCTOR_START::(.*?)[;,]/, /([a-z|A-Z|_]+\.[a-z]+)\(\SRSDOCTOR_END::(.*?)\)/);
|
|
18
|
-
content =
|
|
17
|
+
content = tagMatchResult.result?.trim() || content;
|
|
19
18
|
tagCache.set(bundlePath, tagMatchResult.loc);
|
|
20
19
|
hasBannerPlugin = true;
|
|
21
20
|
} else if (hasBannerPlugin && !tagCache.get(bundlePath)) {
|
|
@@ -58,10 +57,7 @@ const parseBundle = (bundlePath, modulesData)=>{
|
|
|
58
57
|
if (state.locations) return;
|
|
59
58
|
try {
|
|
60
59
|
if (hasBannerPlugin) {
|
|
61
|
-
const firstVariableDeclaration = node.body.find((node)=>
|
|
62
|
-
var _node_declarations__init, _node_declarations_, _node_declarations, _node_declarations__init_properties, _node_declarations__init1, _node_declarations_1, _node_declarations1;
|
|
63
|
-
return 'VariableDeclaration' === node.type && (null == (_node_declarations = node.declarations) ? void 0 : null == (_node_declarations_ = _node_declarations[0]) ? void 0 : null == (_node_declarations__init = _node_declarations_.init) ? void 0 : _node_declarations__init.type) === 'ObjectExpression' && (null == (_node_declarations1 = node.declarations) ? void 0 : null == (_node_declarations_1 = _node_declarations1[0]) ? void 0 : null == (_node_declarations__init1 = _node_declarations_1.init) ? void 0 : null == (_node_declarations__init_properties = _node_declarations__init1.properties) ? void 0 : _node_declarations__init_properties.length);
|
|
64
|
-
});
|
|
60
|
+
const firstVariableDeclaration = node.body.find((node)=>'VariableDeclaration' === node.type && node.declarations?.[0]?.init?.type === 'ObjectExpression' && node.declarations?.[0]?.init?.properties?.length);
|
|
65
61
|
if (firstVariableDeclaration) {
|
|
66
62
|
for (const declaration of firstVariableDeclaration.declarations)if (declaration.init) {
|
|
67
63
|
state.locations = getModulesLocations(declaration.init);
|
|
@@ -78,7 +74,7 @@ const parseBundle = (bundlePath, modulesData)=>{
|
|
|
78
74
|
AssignmentExpression (node, state) {
|
|
79
75
|
if (state.locations) return;
|
|
80
76
|
const { left, right } = node;
|
|
81
|
-
if (
|
|
77
|
+
if (left?.object && 'exports' === left.object.name && left.property && 'modules' === left.property.name && isModulesHash(right)) state.locations = getModulesLocations(right);
|
|
82
78
|
},
|
|
83
79
|
CallExpression (node, state, c) {
|
|
84
80
|
if (state.locations) return;
|
|
@@ -106,13 +102,12 @@ const parseBundle = (bundlePath, modulesData)=>{
|
|
|
106
102
|
modules = walkState.locations ? mapValues(walkState.locations, (loc)=>content.slice(loc.start, loc.end)) : {};
|
|
107
103
|
const modulesObj = {};
|
|
108
104
|
for(const module in modules){
|
|
109
|
-
var _find;
|
|
110
105
|
if (!module) return {};
|
|
111
106
|
const moduleContent = modules[module];
|
|
112
107
|
const size = moduleContent && Buffer.byteLength(moduleContent);
|
|
113
|
-
const identifier =
|
|
108
|
+
const identifier = find(modulesData, {
|
|
114
109
|
renderId: module
|
|
115
|
-
})
|
|
110
|
+
})?.webpackId || '';
|
|
116
111
|
modulesObj[identifier] = {
|
|
117
112
|
size,
|
|
118
113
|
sizeConvert: filesize(size || 0),
|
|
@@ -209,15 +204,15 @@ function getModuleLocation(node) {
|
|
|
209
204
|
function getStringBetween(raw, position, start, end) {
|
|
210
205
|
try {
|
|
211
206
|
const matchStart = raw.match(start);
|
|
212
|
-
const startFlagIndex =
|
|
213
|
-
if (-1 === startFlagIndex || !
|
|
207
|
+
const startFlagIndex = matchStart?.length ? raw.indexOf(matchStart[0], position) : -1;
|
|
208
|
+
if (-1 === startFlagIndex || !matchStart?.length) return {
|
|
214
209
|
result: null,
|
|
215
210
|
remain: position
|
|
216
211
|
};
|
|
217
212
|
const startTagLength = matchStart[0].length;
|
|
218
213
|
const matchEnd = raw.match(end);
|
|
219
|
-
const endFlagIndex =
|
|
220
|
-
if (-1 === endFlagIndex || !
|
|
214
|
+
const endFlagIndex = matchEnd?.length ? raw.indexOf(matchEnd[0], startFlagIndex + startTagLength) : -1;
|
|
215
|
+
if (-1 === endFlagIndex || !matchEnd?.length) return {
|
|
221
216
|
result: null,
|
|
222
217
|
remain: position
|
|
223
218
|
};
|
|
@@ -225,7 +220,7 @@ function getStringBetween(raw, position, start, end) {
|
|
|
225
220
|
if (innerContent.endsWith(',')) innerContent = innerContent.slice(0, -1);
|
|
226
221
|
return {
|
|
227
222
|
result: innerContent,
|
|
228
|
-
remain:
|
|
223
|
+
remain: matchEnd?.length ? endFlagIndex + matchEnd[0].length : endFlagIndex,
|
|
229
224
|
loc: {
|
|
230
225
|
start: startFlagIndex + startTagLength,
|
|
231
226
|
end: endFlagIndex
|
|
@@ -31,8 +31,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
31
31
|
const graph_namespaceObject = require("@rsdoctor/graph");
|
|
32
32
|
function shouldInterceptPluginHook(hook) {
|
|
33
33
|
if (hook && hook._fakeHook) return false;
|
|
34
|
-
if (
|
|
35
|
-
if (
|
|
34
|
+
if (hook?.isUsed && 'function' == typeof hook.isUsed) return hook.isUsed();
|
|
35
|
+
if (hook?._map && 0 === hook._map.size) return false;
|
|
36
36
|
return true;
|
|
37
37
|
}
|
|
38
38
|
function interceptCompilerHooks(compiler, interceptor) {
|
|
@@ -3,8 +3,8 @@ import 'module';
|
|
|
3
3
|
import { ModuleGraphTrans } from "@rsdoctor/graph";
|
|
4
4
|
function shouldInterceptPluginHook(hook) {
|
|
5
5
|
if (hook && hook._fakeHook) return false;
|
|
6
|
-
if (
|
|
7
|
-
if (
|
|
6
|
+
if (hook?.isUsed && 'function' == typeof hook.isUsed) return hook.isUsed();
|
|
7
|
+
if (hook?._map && 0 === hook._map.size) return false;
|
|
8
8
|
return true;
|
|
9
9
|
}
|
|
10
10
|
function interceptCompilerHooks(compiler, interceptor) {
|
|
@@ -98,10 +98,7 @@ class InternalBundlePlugin extends external_base_cjs_namespaceObject.InternalBas
|
|
|
98
98
|
}, this.done = async ()=>{
|
|
99
99
|
(0, logger_namespaceObject.time)('InternalBundlePlugin.done');
|
|
100
100
|
try {
|
|
101
|
-
if (this.scheduler.chunkGraph)
|
|
102
|
-
var _this_scheduler_options;
|
|
103
|
-
graph_namespaceObject.Chunks.assetsContents(this.map, this.scheduler.chunkGraph, null == (_this_scheduler_options = this.scheduler.options) ? void 0 : _this_scheduler_options.supports);
|
|
104
|
-
}
|
|
101
|
+
if (this.scheduler.chunkGraph) graph_namespaceObject.Chunks.assetsContents(this.map, this.scheduler.chunkGraph, this.scheduler.options?.supports);
|
|
105
102
|
this.sdk.addClientRoutes([
|
|
106
103
|
types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.ModuleGraph,
|
|
107
104
|
types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.BundleSize
|
|
@@ -72,10 +72,7 @@ class InternalBundlePlugin extends InternalBasePlugin {
|
|
|
72
72
|
}, this.done = async ()=>{
|
|
73
73
|
time('InternalBundlePlugin.done');
|
|
74
74
|
try {
|
|
75
|
-
if (this.scheduler.chunkGraph)
|
|
76
|
-
var _this_scheduler_options;
|
|
77
|
-
Chunks.assetsContents(this.map, this.scheduler.chunkGraph, null == (_this_scheduler_options = this.scheduler.options) ? void 0 : _this_scheduler_options.supports);
|
|
78
|
-
}
|
|
75
|
+
if (this.scheduler.chunkGraph) Chunks.assetsContents(this.map, this.scheduler.chunkGraph, this.scheduler.options?.supports);
|
|
79
76
|
this.sdk.addClientRoutes([
|
|
80
77
|
Manifest.RsdoctorManifestClientRoutes.ModuleGraph,
|
|
81
78
|
Manifest.RsdoctorManifestClientRoutes.BundleSize
|