@rsdoctor/core 2.0.0-alpha.2 → 2.0.0-beta.1
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/26.js +220 -157
- package/dist/630.js +28 -17
- package/dist/630.js.LICENSE.txt +1 -1
- package/dist/build-utils/build/json.d.ts +1 -1
- package/dist/build-utils/build/loader/probeLoaderPlugin.d.ts +1 -0
- package/dist/build-utils/build/server.d.ts +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +405 -164
- package/dist/inner-plugins/plugins/bundle.d.ts +1 -1
- package/dist/inner-plugins/plugins/errors.d.ts +1 -0
- package/dist/inner-plugins/plugins/loader.d.ts +2 -0
- package/dist/inner-plugins/plugins/plugins.d.ts +1 -1
- package/dist/inner-plugins/plugins/summary.d.ts +3 -2
- package/dist/inner-plugins/utils/config.d.ts +3 -1
- package/dist/inner-plugins/utils/normalize-config.d.ts +3 -8
- package/dist/inner-plugins/utils/ruleWarnings.d.ts +2 -0
- package/dist/inner-plugins/utils/sdk.d.ts +2 -1
- package/dist/proxy-loader.js +7 -3
- package/dist/rspack-plugin/index.d.ts +0 -1
- package/dist/rspack-plugin/plugin.d.ts +47 -17
- package/dist/rspack-plugin/session.d.ts +19 -0
- package/dist/rspack-plugin/writeStore.d.ts +2 -0
- package/dist/rule-utils/parser/utils.d.ts +3 -6
- package/dist/rules/rules/ecma-version-check/index.d.ts +1 -1
- package/dist/sdk/multiple/controller.d.ts +13 -2
- package/dist/sdk/multiple/primary.d.ts +14 -6
- package/dist/sdk/sdk/core.d.ts +3 -2
- package/dist/sdk/sdk/types.d.ts +1 -1
- package/dist/sdk/utils/index.d.ts +1 -0
- package/dist/sdk/utils/manifestSharding.d.ts +16 -0
- package/dist/types/loader.d.ts +5 -0
- package/dist/types/plugin.d.ts +0 -8
- package/package.json +27 -28
- package/dist/rspack-plugin/multiple.d.ts +0 -8
package/dist/26.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
let flagForceColor;
|
|
2
2
|
import __rslib_shim_module__, { createRequire, createRequire as __rspack_createRequire } from "node:module";
|
|
3
3
|
let require = __rslib_shim_module__.createRequire(import.meta.url);
|
|
4
|
-
import
|
|
4
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
5
5
|
import fs_0 from "fs";
|
|
6
6
|
import path_0, { dirname, isAbsolute, resolve as external_path_resolve } from "path";
|
|
7
7
|
import node_fs from "node:fs";
|
|
8
|
-
import connect from "connect";
|
|
8
|
+
import { connect } from "connect-next";
|
|
9
9
|
import http from "http";
|
|
10
10
|
import os from "os";
|
|
11
11
|
import "get-port";
|
|
@@ -22,6 +22,7 @@ import { color } from "rslog";
|
|
|
22
22
|
import assert from "assert";
|
|
23
23
|
import { exec as external_node_child_process_exec } from "node:child_process";
|
|
24
24
|
import node_path, { join, dirname as __rspack_dirname } from "node:path";
|
|
25
|
+
import { randomUUID } from "node:crypto";
|
|
25
26
|
import { SourceMapConsumer } from "source-map";
|
|
26
27
|
import { diff, gt } from "semver";
|
|
27
28
|
import { builtinModules } from "module";
|
|
@@ -30,7 +31,6 @@ import node_process from "node:process";
|
|
|
30
31
|
import node_os from "node:os";
|
|
31
32
|
import node_tty from "node:tty";
|
|
32
33
|
import { loadConfig } from "browserslist-load-config";
|
|
33
|
-
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
34
34
|
import { addProbeLoader2Rules, parseBundle as parseBundle_parseBundle, interceptCompilationHooks, timeEnd as logger_timeEnd, logger_time, getSDK, extractLoaderName, logger as rsdoctorLogger, mapEachRules, getDocument, isESMLoader, parseQuery, filesize as filesize_filesize, color as external_rslog_color, getLoaderNameMatch, interceptCompilerHooks, loadLoaderModule, parser as parser_parser } from "./630.js";
|
|
35
35
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
36
36
|
var CheckVersionMap, __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
@@ -43,7 +43,7 @@ __webpack_require__.add({
|
|
|
43
43
|
BrowserslistError.prototype = Error.prototype, module.exports = BrowserslistError;
|
|
44
44
|
},
|
|
45
45
|
"../../node_modules/.pnpm/browserslist@4.28.2/node_modules/browserslist/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
46
|
-
var bbm = __webpack_require__("../../node_modules/.pnpm/baseline-browser-mapping@2.10.29/node_modules/baseline-browser-mapping/dist/index.cjs"), jsReleases = __webpack_require__("../../node_modules/.pnpm/node-releases@2.0.38/node_modules/node-releases/data/processed/envs.json"), agents = __webpack_require__("caniuse-lite/dist/unpacker/agents").agents, e2c = __webpack_require__("../../node_modules/.pnpm/electron-to-chromium@1.5.353/node_modules/electron-to-chromium/versions.js"), jsEOL = __webpack_require__("../../node_modules/.pnpm/node-releases@2.0.38/node_modules/node-releases/data/release-schedule/release-schedule.json"), path = __webpack_require__("path?37f5"), BrowserslistError = __webpack_require__("../../node_modules/.pnpm/browserslist@4.28.2/node_modules/browserslist/error.js"), env = __webpack_require__("../../node_modules/.pnpm/browserslist@4.28.2/node_modules/browserslist/node.js"), parseWithoutCache = __webpack_require__("../../node_modules/.pnpm/browserslist@4.28.2/node_modules/browserslist/parse.js");
|
|
46
|
+
var bbm = __webpack_require__("../../node_modules/.pnpm/baseline-browser-mapping@2.10.29/node_modules/baseline-browser-mapping/dist/index.cjs"), jsReleases = __webpack_require__("../../node_modules/.pnpm/node-releases@2.0.38/node_modules/node-releases/data/processed/envs.json"), agents = __webpack_require__("caniuse-lite/dist/unpacker/agents").agents, e2c = __webpack_require__("../../node_modules/.pnpm/electron-to-chromium@1.5.353/node_modules/electron-to-chromium/versions.js"), jsEOL = __webpack_require__("../../node_modules/.pnpm/node-releases@2.0.38/node_modules/node-releases/data/release-schedule/release-schedule.json"), path = __webpack_require__("path?37f5"), BrowserslistError = __webpack_require__("../../node_modules/.pnpm/browserslist@4.28.2/node_modules/browserslist/error.js"), env = __webpack_require__("../../node_modules/.pnpm/browserslist@4.28.2/node_modules/browserslist/node.js"), parseWithoutCache = __webpack_require__("../../node_modules/.pnpm/browserslist@4.28.2/node_modules/browserslist/parse.js"), YEAR = 365.259641 * 86400000;
|
|
47
47
|
function isVersionsMatch(versionA, versionB) {
|
|
48
48
|
return 0 === (versionA + '.').indexOf(versionB + '.');
|
|
49
49
|
}
|
|
@@ -468,7 +468,7 @@ __webpack_require__.add({
|
|
|
468
468
|
],
|
|
469
469
|
regexp: /^last\s+((\d+\.)?\d+)\s+years?$/i,
|
|
470
470
|
select: function(context, node) {
|
|
471
|
-
return filterByYear(Date.now() -
|
|
471
|
+
return filterByYear(Date.now() - YEAR * node.years, context);
|
|
472
472
|
}
|
|
473
473
|
},
|
|
474
474
|
since_y: {
|
|
@@ -23562,28 +23562,6 @@ var duplicate_package_types_namespaceObject = {};
|
|
|
23562
23562
|
__webpack_require__.r(duplicate_package_types_namespaceObject), __webpack_require__.d(duplicate_package_types_namespaceObject, {
|
|
23563
23563
|
J: ()=>types_CheckVersionMap
|
|
23564
23564
|
});
|
|
23565
|
-
class FileSharding {
|
|
23566
|
-
constructor(content, limitBytes = 10485760, encoding = 'utf-8'){
|
|
23567
|
-
this.content = content, this.limitBytes = limitBytes, this.encoding = encoding;
|
|
23568
|
-
}
|
|
23569
|
-
createVirtualShardingFiles(ext = '', index = 0) {
|
|
23570
|
-
let bf = Buffer.from(this.content, this.encoding), res = [], threshold = this.limitBytes, tmpBytes = 0;
|
|
23571
|
-
for(; bf.byteLength > tmpBytes;)res.push(bf.subarray(tmpBytes, tmpBytes + threshold)), tmpBytes += threshold;
|
|
23572
|
-
return res.map((e, i)=>({
|
|
23573
|
-
filename: `${i + index}${ext}`,
|
|
23574
|
-
content: e
|
|
23575
|
-
}));
|
|
23576
|
-
}
|
|
23577
|
-
async writeStringToFolder(folder, ext = '', index) {
|
|
23578
|
-
let dist = path_0.resolve(folder);
|
|
23579
|
-
await fs_extra.ensureDir(dist);
|
|
23580
|
-
let res = this.createVirtualShardingFiles(ext, index);
|
|
23581
|
-
return await Promise.all(res.map((e)=>new Promise((resolve, reject)=>{
|
|
23582
|
-
let stream = fs_0.createWriteStream(path_0.join(dist, e.filename), this.encoding);
|
|
23583
|
-
stream.end(e.content), stream.once('close', ()=>resolve(void 0)), stream.once('error', (err)=>reject(err));
|
|
23584
|
-
}))), res;
|
|
23585
|
-
}
|
|
23586
|
-
}
|
|
23587
23565
|
let RESTRICTED_PORTS = [
|
|
23588
23566
|
3659,
|
|
23589
23567
|
4045,
|
|
@@ -23685,12 +23663,16 @@ class ProbeLoaderPlugin {
|
|
|
23685
23663
|
});
|
|
23686
23664
|
}
|
|
23687
23665
|
addProbeLoader(compiler) {
|
|
23666
|
+
if (this.instrumentedCompilers.has(compiler)) return;
|
|
23688
23667
|
let rules = compiler.options.module.rules;
|
|
23689
23668
|
if (Loader.isVue(compiler)) {
|
|
23690
|
-
compiler.options.module.rules = addProbeLoader2Rules(rules, compiler, (r)=>!!r.loader || 'string' == typeof r);
|
|
23669
|
+
compiler.options.module.rules = addProbeLoader2Rules(rules, compiler, (r)=>!!r.loader || 'string' == typeof r), this.instrumentedCompilers.add(compiler);
|
|
23691
23670
|
return;
|
|
23692
23671
|
}
|
|
23693
|
-
rules = addProbeLoader2Rules(rules, compiler, (r)=>getLoaderNameMatch(r, 'builtin:swc-loader', !0)), rules = addProbeLoader2Rules(rules, compiler, (r)=>getLoaderNameMatch(r, 'builtin:lightningcss-loader', !0)), compiler.options.module.rules = addProbeLoader2Rules(rules, compiler, (r)=>getLoaderNameMatch(r, '.mjs', !1) || isESMLoader(r));
|
|
23672
|
+
rules = addProbeLoader2Rules(rules, compiler, (r)=>getLoaderNameMatch(r, 'builtin:swc-loader', !0)), rules = addProbeLoader2Rules(rules, compiler, (r)=>getLoaderNameMatch(r, 'builtin:lightningcss-loader', !0)), compiler.options.module.rules = addProbeLoader2Rules(rules, compiler, (r)=>getLoaderNameMatch(r, '.mjs', !1) || isESMLoader(r)), this.instrumentedCompilers.add(compiler);
|
|
23673
|
+
}
|
|
23674
|
+
constructor(){
|
|
23675
|
+
this.instrumentedCompilers = new WeakSet();
|
|
23694
23676
|
}
|
|
23695
23677
|
}
|
|
23696
23678
|
function truncateMessage(input, maxLen = 1000) {
|
|
@@ -23983,8 +23965,8 @@ async function reportLoader(ctx, start, startHRTime, isPitch, sync, code, err, r
|
|
|
23983
23965
|
sourcesContent: data.sourcesContent,
|
|
23984
23966
|
mappings: data.mappings,
|
|
23985
23967
|
file: loaderData[0].resource.path
|
|
23986
|
-
}, sdk = getSDK(
|
|
23987
|
-
return sdk?.reportLoader
|
|
23968
|
+
}, compilation = ctx._compilation, sdk = getSDK(compilation?.compiler?.compilerPath || compilation?.name);
|
|
23969
|
+
return sdk?.reportLoader ? (sdk.reportLoader(loaderData), sdk.reportSourceMap(sourceMapData)) : await Promise.all([
|
|
23988
23970
|
Fetch.postJSON(`${host}${SDK.ServerAPI.API.ReportLoader}`, loaderData, 8888).catch((err)=>{
|
|
23989
23971
|
rsdoctorLogger.debug(`${err.message}`, '[RspackPlugin.ReportLoader][error]');
|
|
23990
23972
|
}),
|
|
@@ -24057,56 +24039,69 @@ function makeRulesSerializable(rules) {
|
|
|
24057
24039
|
function defaultBoolean(v, dft) {
|
|
24058
24040
|
return 'boolean' == typeof v ? v : dft;
|
|
24059
24041
|
}
|
|
24060
|
-
function
|
|
24061
|
-
return
|
|
24062
|
-
mode: void 0,
|
|
24063
|
-
reportCodeType: {
|
|
24064
|
-
noModuleSource: !1,
|
|
24065
|
-
noAssetsAndModuleSource: !1,
|
|
24066
|
-
noCode: !1
|
|
24067
|
-
},
|
|
24068
|
-
options: void 0,
|
|
24069
|
-
reportDir: '',
|
|
24070
|
-
compressData: void 0
|
|
24071
|
-
};
|
|
24042
|
+
function isCompilerWatching(compiler) {
|
|
24043
|
+
return !!(compiler.watchMode || compiler.parentCompilation?.compiler.watchMode);
|
|
24072
24044
|
}
|
|
24073
|
-
function
|
|
24045
|
+
let normalizeRspackUserOptions = function(config = {}) {
|
|
24074
24046
|
var mode, mode1, finalMode, value, value1;
|
|
24075
|
-
let
|
|
24047
|
+
let finalBrief, finalNormalOptions, gzipLevel, reportCodeType, mode2;
|
|
24048
|
+
for (let { name, value, replacement } of [
|
|
24049
|
+
{
|
|
24050
|
+
name: "top-level 'mode'",
|
|
24051
|
+
value: config.mode,
|
|
24052
|
+
replacement: 'lite' === config.mode ? 'output.reportCodeType' : 'output.mode'
|
|
24053
|
+
},
|
|
24054
|
+
{
|
|
24055
|
+
name: "top-level 'port'",
|
|
24056
|
+
value: config.port,
|
|
24057
|
+
replacement: 'server.port'
|
|
24058
|
+
},
|
|
24059
|
+
{
|
|
24060
|
+
name: "top-level 'brief'",
|
|
24061
|
+
value: config.brief,
|
|
24062
|
+
replacement: 'output.options.htmlOptions'
|
|
24063
|
+
},
|
|
24064
|
+
{
|
|
24065
|
+
name: "'output.compressData'",
|
|
24066
|
+
value: config.output?.compressData,
|
|
24067
|
+
replacement: "output.mode: 'brief' and output.options.type: ['json']"
|
|
24068
|
+
}
|
|
24069
|
+
])void 0 !== value && rsdoctorLogger.info(external_rslog_color.yellow(`The ${name} configuration was removed in Rsdoctor 2.x and is ignored. Please use '${replacement}' instead.`));
|
|
24070
|
+
config.supports?.generateTileGraph !== void 0 && rsdoctorLogger.info(external_rslog_color.yellow("The 'supports.generateTileGraph' configuration was removed in Rsdoctor 2.x and is ignored. Treemap is supported by default."));
|
|
24071
|
+
let userOutput = config.output, outputConfig = 'json' === process.env.RSDOCTOR_OUTPUT ? {
|
|
24076
24072
|
reportDir: userOutput?.reportDir,
|
|
24077
|
-
compressData: userOutput?.compressData,
|
|
24078
24073
|
mode: 'brief',
|
|
24079
24074
|
options: {
|
|
24080
24075
|
type: [
|
|
24081
24076
|
'json'
|
|
24082
24077
|
]
|
|
24083
24078
|
}
|
|
24084
|
-
} : userOutput ??
|
|
24079
|
+
} : userOutput ?? {
|
|
24080
|
+
mode: void 0,
|
|
24081
|
+
options: void 0,
|
|
24082
|
+
reportDir: ''
|
|
24083
|
+
}, { linter = {}, features = {}, loaderInterceptorOptions = {}, disableClientServer: userDisableClientServer = !1, sdkInstance, innerClientPath = '', output = outputConfig, supports: userSupports = {}, server: userServer = {}, printLog = {
|
|
24085
24084
|
serverUrls: !0
|
|
24086
|
-
},
|
|
24085
|
+
}, multiCompiler = !0 } = {
|
|
24087
24086
|
...config,
|
|
24088
24087
|
output: outputConfig
|
|
24089
24088
|
}, supports = {
|
|
24090
|
-
|
|
24091
|
-
|
|
24092
|
-
},
|
|
24093
|
-
...userSupports,
|
|
24089
|
+
banner: defaultBoolean(userSupports.banner, !0),
|
|
24090
|
+
parseBundle: defaultBoolean(userSupports.parseBundle, !0),
|
|
24094
24091
|
gzip: (assert(void 0 === (value = userSupports.gzip) || 'boolean' == typeof value || 'object' == typeof value && null !== value && !Array.isArray(value), '`supports.gzip` must be a boolean or an object.'), !1 !== value && {
|
|
24095
24092
|
gzipLevel: (assert('number' == typeof (gzipLevel = void 0 === (value1 = 'object' == typeof value && null !== value ? value.gzipLevel : void 0) ? 6 : value1) && Number.isInteger(gzipLevel) && gzipLevel >= 0 && gzipLevel <= 9, '`supports.gzip.gzipLevel` must be an integer between 0 and 9.'), gzipLevel)
|
|
24096
24093
|
})
|
|
24097
24094
|
}, disableClientServer = 'true' !== process.env.RSTEST && (!!process.env.CI || userDisableClientServer);
|
|
24098
|
-
assert('object' == typeof linter), assert('object' == typeof features || Array.isArray(features)), assert('object' == typeof loaderInterceptorOptions), assert('boolean' == typeof disableClientServer), assert(
|
|
24095
|
+
assert('object' == typeof linter), assert('object' == typeof features || Array.isArray(features)), assert('object' == typeof loaderInterceptorOptions), assert('boolean' == typeof disableClientServer), assert('object' == typeof userServer && null !== userServer);
|
|
24099
24096
|
let server = {
|
|
24100
24097
|
...userServer
|
|
24101
24098
|
};
|
|
24102
|
-
assert(void 0 === server.port || 'number' == typeof server.port),
|
|
24099
|
+
assert(void 0 === server.port || 'number' == typeof server.port), assert('boolean' == typeof multiCompiler || 'object' == typeof multiCompiler && null !== multiCompiler);
|
|
24103
24100
|
let finalMode1 = ('mode' in output && 'string' == typeof (mode = output.mode) && [
|
|
24104
24101
|
'brief',
|
|
24105
24102
|
'normal',
|
|
24106
24103
|
'lite'
|
|
24107
|
-
].includes(mode) ? 'lite' === output.mode ? SDK.IMode[SDK.IMode.normal] : output.mode : void 0) ||
|
|
24108
|
-
mode2 && rsdoctorLogger.info(external_rslog_color.yellow("The 'mode' configuration will be deprecated in a future version. Please use 'output.mode' instead."));
|
|
24109
|
-
let _features = (mode1 = finalMode1, Array.isArray(features) ? {
|
|
24104
|
+
].includes(mode) ? 'lite' === output.mode ? SDK.IMode[SDK.IMode.normal] : output.mode : void 0) || SDK.IMode[SDK.IMode.normal], _features = (mode1 = finalMode1, Array.isArray(features) ? {
|
|
24110
24105
|
loader: features.includes('loader'),
|
|
24111
24106
|
plugins: features.includes('plugins'),
|
|
24112
24107
|
resolver: features.includes('resolver'),
|
|
@@ -24125,12 +24120,9 @@ function normalizeUserConfig(config = {}) {
|
|
|
24125
24120
|
extends: [],
|
|
24126
24121
|
level: 'Error',
|
|
24127
24122
|
...linter
|
|
24128
|
-
}
|
|
24129
|
-
(_features.lite || finalMode1 === SDK.IMode[SDK.IMode.lite]) && rsdoctorLogger.info(external_rslog_color.yellow("Lite features will be deprecated in a future version. Please use 'output: { reportCodeType: { noAssetsAndModuleSource: true }}' instead."));
|
|
24130
|
-
let { finalBrief: finalBrief1, finalNormalOptions: finalNormalOptions1 } = (finalBrief = {}, finalNormalOptions = {}, 'brief' === (finalMode = finalMode1) ? finalBrief = function(output, brief) {
|
|
24123
|
+
}, { finalBrief: finalBrief1, finalNormalOptions: finalNormalOptions1 } = (finalBrief = {}, finalNormalOptions = {}, 'brief' === (finalMode = finalMode1) ? finalBrief = function(output) {
|
|
24131
24124
|
let htmlOptions = {
|
|
24132
|
-
reportHtmlName: void 0
|
|
24133
|
-
writeDataJson: !1
|
|
24125
|
+
reportHtmlName: void 0
|
|
24134
24126
|
}, jsonOptions = {}, briefOptions = output?.options || {};
|
|
24135
24127
|
if ('type' in briefOptions && briefOptions.type?.includes('json') && (jsonOptions = briefOptions.jsonOptions || {
|
|
24136
24128
|
fileName: 'rsdoctor-data.json',
|
|
@@ -24142,8 +24134,7 @@ function normalizeUserConfig(config = {}) {
|
|
|
24142
24134
|
}), 'type' in briefOptions && briefOptions.type?.includes('html') || !briefOptions.type) {
|
|
24143
24135
|
let outputBriefOptions = briefOptions?.htmlOptions;
|
|
24144
24136
|
htmlOptions = {
|
|
24145
|
-
reportHtmlName: outputBriefOptions?.reportHtmlName ||
|
|
24146
|
-
writeDataJson: outputBriefOptions?.writeDataJson || brief?.writeDataJson || !1
|
|
24137
|
+
reportHtmlName: outputBriefOptions?.reportHtmlName || void 0
|
|
24147
24138
|
};
|
|
24148
24139
|
}
|
|
24149
24140
|
return {
|
|
@@ -24153,12 +24144,17 @@ function normalizeUserConfig(config = {}) {
|
|
|
24153
24144
|
htmlOptions,
|
|
24154
24145
|
jsonOptions
|
|
24155
24146
|
};
|
|
24156
|
-
}(output
|
|
24147
|
+
}(output) : 'normal' === finalMode && (finalNormalOptions = {}), {
|
|
24157
24148
|
finalBrief,
|
|
24158
24149
|
finalNormalOptions
|
|
24159
24150
|
});
|
|
24160
24151
|
_features.lite && finalMode1 !== SDK.IMode[SDK.IMode.brief] && (finalMode1 = SDK.IMode[SDK.IMode.lite]);
|
|
24161
|
-
let
|
|
24152
|
+
let reportCodeType1 = (reportCodeType = output.reportCodeType, mode2 = finalMode1, (assert(void 0 === reportCodeType || [
|
|
24153
|
+
'noModuleSource',
|
|
24154
|
+
'noAssetsAndModuleSource',
|
|
24155
|
+
'noCode'
|
|
24156
|
+
].includes(reportCodeType), '`output.reportCodeType` must be "noModuleSource", "noAssetsAndModuleSource", or "noCode".'), mode2 === SDK.IMode[SDK.IMode.brief] && void 0 !== reportCodeType && 'noCode' !== reportCodeType && rsdoctorLogger.warn('`output.reportCodeType` is ignored when `output.mode` is "brief"; brief mode always uses "noCode".'), 'noCode' === reportCodeType || mode2 === SDK.IMode[SDK.IMode.brief]) ? SDK.ToDataType.NoCode : mode2 === SDK.IMode[SDK.IMode.lite] || 'noAssetsAndModuleSource' === reportCodeType ? SDK.ToDataType.NoSourceAndAssets : 'noModuleSource' === reportCodeType ? SDK.ToDataType.NoSource : SDK.ToDataType.Normal);
|
|
24157
|
+
return {
|
|
24162
24158
|
linter: _linter,
|
|
24163
24159
|
features: _features,
|
|
24164
24160
|
loaderInterceptorOptions: {
|
|
@@ -24169,27 +24165,19 @@ function normalizeUserConfig(config = {}) {
|
|
|
24169
24165
|
output: {
|
|
24170
24166
|
mode: finalMode1,
|
|
24171
24167
|
options: 'brief' === finalMode1 ? finalBrief1 : finalNormalOptions1,
|
|
24172
|
-
reportCodeType,
|
|
24168
|
+
reportCodeType: reportCodeType1,
|
|
24173
24169
|
reportDir: output.reportDir || ''
|
|
24174
24170
|
},
|
|
24175
24171
|
innerClientPath,
|
|
24176
24172
|
supports,
|
|
24177
|
-
port,
|
|
24178
24173
|
server,
|
|
24179
|
-
printLog
|
|
24180
|
-
|
|
24181
|
-
|
|
24182
|
-
|
|
24183
|
-
let normalizeReportType = (reportCodeType, mode)=>{
|
|
24184
|
-
let convertedReportCodeType = 'object' == typeof reportCodeType ? function(reportCodeType) {
|
|
24185
|
-
if (reportCodeType) {
|
|
24186
|
-
if (reportCodeType.noCode) return 'noCode';
|
|
24187
|
-
else if (reportCodeType.noAssetsAndModuleSource) return 'noAssetsAndModuleSource';
|
|
24188
|
-
else if (reportCodeType.noModuleSource) return 'noModuleSource';
|
|
24174
|
+
printLog,
|
|
24175
|
+
multiCompiler: {
|
|
24176
|
+
enabled: !1 !== multiCompiler,
|
|
24177
|
+
group: 'object' == typeof multiCompiler ? multiCompiler.group : void 0
|
|
24189
24178
|
}
|
|
24190
|
-
}
|
|
24191
|
-
|
|
24192
|
-
}, normalizeRspackUserOptions = normalizeUserConfig, execAsync = promisify(external_node_child_process_exec), supportedChromiumBrowsers = [
|
|
24179
|
+
};
|
|
24180
|
+
}, execAsync = promisify(external_node_child_process_exec), supportedChromiumBrowsers = [
|
|
24193
24181
|
'Google Chrome Canary',
|
|
24194
24182
|
'Google Chrome Dev',
|
|
24195
24183
|
'Google Chrome Beta',
|
|
@@ -24322,7 +24310,9 @@ class InternalLoaderPlugin extends InternalBasePlugin {
|
|
|
24322
24310
|
apply(compiler) {
|
|
24323
24311
|
logger_time('InternalLoaderPlugin.apply');
|
|
24324
24312
|
try {
|
|
24325
|
-
compiler.
|
|
24313
|
+
compiler.isChild() ? this.sdk.addClientRoutes([
|
|
24314
|
+
Manifest.RsdoctorManifestClientRoutes.Loaders
|
|
24315
|
+
]) : compiler.hooks.afterPlugins.tap(this.tapPostOptions, this.afterPlugins.bind(this, compiler)), compiler.hooks.compilation.tap(this.tapPreOptions, (compilation)=>this.compilation(compiler, compilation));
|
|
24326
24316
|
} finally{
|
|
24327
24317
|
logger_timeEnd('InternalLoaderPlugin.apply');
|
|
24328
24318
|
}
|
|
@@ -24330,7 +24320,7 @@ class InternalLoaderPlugin extends InternalBasePlugin {
|
|
|
24330
24320
|
compilation(compiler, compilation) {
|
|
24331
24321
|
logger_time('InternalLoaderPlugin.compilation');
|
|
24332
24322
|
try {
|
|
24333
|
-
if (compiler.
|
|
24323
|
+
if (compilation.compiler && compilation.compiler !== compiler) return;
|
|
24334
24324
|
let wrapper = (callback)=>(loaderContext, module)=>{
|
|
24335
24325
|
let originLoaders = (module?.loaders || loaderContext?.loaders || []).map((loader)=>{
|
|
24336
24326
|
let rawOptions = loader.options, opts = 'object' == typeof rawOptions && null !== rawOptions ? rawOptions : {};
|
|
@@ -24374,6 +24364,7 @@ class InternalLoaderPlugin extends InternalBasePlugin {
|
|
|
24374
24364
|
}
|
|
24375
24365
|
}
|
|
24376
24366
|
getInterceptRules(compiler, rules) {
|
|
24367
|
+
let cacheMarkerPath = this.getCacheMarkerPath(compiler);
|
|
24377
24368
|
return function(rules, loaderPath, options, loaderResolver, cwd = process.cwd()) {
|
|
24378
24369
|
return mapEachRules(rules, (rule)=>{
|
|
24379
24370
|
if (rule.loader?.startsWith('builtin:') || rule.loader?.endsWith('.mjs') || isESMLoader(rule)) return rule;
|
|
@@ -24397,16 +24388,26 @@ class InternalLoaderPlugin extends InternalBasePlugin {
|
|
|
24397
24388
|
};
|
|
24398
24389
|
});
|
|
24399
24390
|
}(rules, this.internalLoaderPath, {
|
|
24391
|
+
cacheMarkerPath,
|
|
24400
24392
|
cwd: compiler.context || process.cwd(),
|
|
24401
24393
|
host: this.sdk.server.origin,
|
|
24402
24394
|
skipLoaders: this.options.loaderInterceptorOptions.skipLoaders
|
|
24403
24395
|
}, compiler.resolverFactory.get('loader', compiler.options.resolveLoader), this.sdk.root);
|
|
24404
24396
|
}
|
|
24397
|
+
getCacheMarkerPath(compiler) {
|
|
24398
|
+
if ('object' != typeof compiler.options.cache || 'persistent' !== compiler.options.cache.type) return;
|
|
24399
|
+
if (this.cacheMarkerPath) return this.cacheMarkerPath;
|
|
24400
|
+
let markerPath = node_path.join(this.sdk.outputDir, '.loader-cache');
|
|
24401
|
+
node_fs.mkdirSync(node_path.dirname(markerPath), {
|
|
24402
|
+
recursive: !0
|
|
24403
|
+
});
|
|
24404
|
+
let previous = node_fs.existsSync(markerPath) ? node_fs.readFileSync(markerPath, 'utf8') : '', prefix = previous.length < 4096 ? previous : '';
|
|
24405
|
+
return node_fs.writeFileSync(markerPath, `${prefix}${randomUUID()}\n`), this.cacheMarkerPath = markerPath, markerPath;
|
|
24406
|
+
}
|
|
24405
24407
|
constructor(...args){
|
|
24406
24408
|
super(...args), this.name = 'loader', this.internalLoaderPath = loader_require.resolve('@rsdoctor/core/proxy-loader'), this.afterPlugins = (compiler)=>{
|
|
24407
24409
|
logger_time('InternalLoaderPlugin.afterPlugins');
|
|
24408
24410
|
try {
|
|
24409
|
-
if (compiler.isChild()) return;
|
|
24410
24411
|
compiler.options.module.rules = this.getInterceptRules(compiler, compiler.options.module.rules), this.sdk.addClientRoutes([
|
|
24411
24412
|
Manifest.RsdoctorManifestClientRoutes.Loaders
|
|
24412
24413
|
]);
|
|
@@ -24420,7 +24421,7 @@ class InternalPluginsPlugin extends InternalBasePlugin {
|
|
|
24420
24421
|
apply(compiler) {
|
|
24421
24422
|
logger_time('InternalPluginsPlugin.apply');
|
|
24422
24423
|
try {
|
|
24423
|
-
compiler.hooks.afterPlugins.tap(this.tapPostOptions, this.afterPlugins.bind(this, compiler)), compiler.hooks.compilation.tap(this.tapPostOptions, this.compilation);
|
|
24424
|
+
compiler.isChild() ? this.afterPlugins(compiler) : compiler.hooks.afterPlugins.tap(this.tapPostOptions, this.afterPlugins.bind(this, compiler)), compiler.hooks.compilation.tap(this.tapPostOptions, (compilation)=>this.compilation(compiler, compilation));
|
|
24424
24425
|
} finally{
|
|
24425
24426
|
logger_timeEnd('InternalPluginsPlugin.apply');
|
|
24426
24427
|
}
|
|
@@ -24429,17 +24430,16 @@ class InternalPluginsPlugin extends InternalBasePlugin {
|
|
|
24429
24430
|
super(...args), this.name = 'plugins', this.afterPlugins = (compiler)=>{
|
|
24430
24431
|
logger_time('InternalPluginsPlugin.afterPlugins');
|
|
24431
24432
|
try {
|
|
24432
|
-
if (compiler.isChild()) return;
|
|
24433
24433
|
interceptCompilerHooks(compiler, (name, hook)=>interceptPluginHook(this.sdk, name, hook)), this.sdk.addClientRoutes([
|
|
24434
24434
|
Manifest.RsdoctorManifestClientRoutes.Plugins
|
|
24435
24435
|
]);
|
|
24436
24436
|
} finally{
|
|
24437
24437
|
logger_timeEnd('InternalPluginsPlugin.afterPlugins');
|
|
24438
24438
|
}
|
|
24439
|
-
}, this.compilation = (compilation)=>{
|
|
24439
|
+
}, this.compilation = (compiler, compilation)=>{
|
|
24440
24440
|
logger_time('InternalPluginsPlugin.compilation');
|
|
24441
24441
|
try {
|
|
24442
|
-
if (compilation.compiler.
|
|
24442
|
+
if (compilation.compiler && compilation.compiler !== compiler) return;
|
|
24443
24443
|
interceptCompilationHooks(compilation, (name, hook)=>interceptPluginHook(this.sdk, name, hook));
|
|
24444
24444
|
} finally{
|
|
24445
24445
|
logger_timeEnd('InternalPluginsPlugin.compilation');
|
|
@@ -24451,7 +24451,7 @@ class InternalErrorReporterPlugin extends InternalBasePlugin {
|
|
|
24451
24451
|
apply(compiler) {
|
|
24452
24452
|
logger_time('InternalErrorReporterPlugin.apply');
|
|
24453
24453
|
try {
|
|
24454
|
-
compiler.hooks.done.tapPromise(this.tapPreOptions, this.done);
|
|
24454
|
+
compiler.isChild() ? compiler.hooks.afterCompile.tapPromise(this.tapPreOptions, this.afterCompile) : compiler.hooks.done.tapPromise(this.tapPreOptions, this.done);
|
|
24455
24455
|
} finally{
|
|
24456
24456
|
logger_timeEnd('InternalErrorReporterPlugin.apply');
|
|
24457
24457
|
}
|
|
@@ -24500,6 +24500,11 @@ class InternalErrorReporterPlugin extends InternalBasePlugin {
|
|
|
24500
24500
|
} finally{
|
|
24501
24501
|
logger_timeEnd('InternalErrorReporterPlugin.done');
|
|
24502
24502
|
}
|
|
24503
|
+
}, this.afterCompile = async (compilation)=>{
|
|
24504
|
+
await Promise.all([
|
|
24505
|
+
this.reportErrors(compilation.errors || []),
|
|
24506
|
+
this.reportWarnings(compilation.warnings || [])
|
|
24507
|
+
]);
|
|
24503
24508
|
};
|
|
24504
24509
|
}
|
|
24505
24510
|
}
|
|
@@ -24507,7 +24512,7 @@ class InternalSummaryPlugin extends InternalBasePlugin {
|
|
|
24507
24512
|
apply(compiler) {
|
|
24508
24513
|
logger_time('InternalSummaryPlugin.apply');
|
|
24509
24514
|
try {
|
|
24510
|
-
compiler.hooks.beforeCompile.tapPromise(this.tapPostOptions, this.beforeCompile), compiler.hooks.afterCompile.tapPromise(this.tapPreOptions, this.afterCompile), compiler.hooks.done.tapPromise(this.tapPostOptions, this.done.bind(this, compiler));
|
|
24515
|
+
compiler.hooks.beforeCompile.tapPromise(this.tapPostOptions, this.beforeCompile.bind(this, compiler)), compiler.hooks.afterCompile.tapPromise(this.tapPreOptions, this.afterCompile.bind(this, compiler)), compiler.isChild() || compiler.hooks.done.tapPromise(this.tapPostOptions, this.done.bind(this, compiler));
|
|
24511
24516
|
} finally{
|
|
24512
24517
|
logger_timeEnd('InternalSummaryPlugin.apply');
|
|
24513
24518
|
}
|
|
@@ -24534,20 +24539,20 @@ class InternalSummaryPlugin extends InternalBasePlugin {
|
|
|
24534
24539
|
});
|
|
24535
24540
|
}
|
|
24536
24541
|
constructor(...args){
|
|
24537
|
-
super(...args), this.name = 'summary', this.times = new Map(), this.preTimes = new Map(), this.postTimes = new Map(), this.beforeCompile = async ()=>{
|
|
24542
|
+
super(...args), this.name = 'summary', this.times = new Map(), this.preTimes = new Map(), this.postTimes = new Map(), this.createdAt = Date.now(), this.beforeCompile = async (compiler)=>{
|
|
24538
24543
|
logger_time('InternalSummaryPlugin.beforeCompile');
|
|
24539
24544
|
try {
|
|
24540
24545
|
if (!this.times.has(Summary.SummaryCostsDataName.Bootstrap)) {
|
|
24541
|
-
let
|
|
24546
|
+
let startAt = compiler.isChild() ? this.createdAt : Date.now() - Math.floor(1000 * process.uptime());
|
|
24542
24547
|
this.report(Summary.SummaryCostsDataName.Bootstrap, startAt), this.mark(Summary.SummaryCostsDataName.Bootstrap, 'post');
|
|
24543
24548
|
}
|
|
24544
24549
|
} finally{
|
|
24545
24550
|
logger_timeEnd('InternalSummaryPlugin.beforeCompile');
|
|
24546
24551
|
}
|
|
24547
|
-
}, this.afterCompile = async (compilation)=>{
|
|
24552
|
+
}, this.afterCompile = async (compiler, compilation)=>{
|
|
24548
24553
|
logger_time('InternalSummaryPlugin.afterCompile');
|
|
24549
24554
|
try {
|
|
24550
|
-
if (!this.times.has(Summary.SummaryCostsDataName.Compile) && !compilation.compiler.
|
|
24555
|
+
if (!this.times.has(Summary.SummaryCostsDataName.Compile) && (!compilation.compiler || compilation.compiler === compiler)) {
|
|
24551
24556
|
let start = this.postTimes.get(Summary.SummaryCostsDataName.Bootstrap);
|
|
24552
24557
|
this.report(Summary.SummaryCostsDataName.Compile, start), this.mark(Summary.SummaryCostsDataName.Compile, 'post');
|
|
24553
24558
|
}
|
|
@@ -24582,7 +24587,9 @@ class InternalBundlePlugin extends InternalBasePlugin {
|
|
|
24582
24587
|
apply(compiler) {
|
|
24583
24588
|
logger_time('InternalBundlePlugin.apply');
|
|
24584
24589
|
try {
|
|
24585
|
-
this.scheduler.ensureModulesChunksGraphApplied(compiler), this.changeDevtoolModuleFilename(compiler), compiler.hooks.compilation.tap(this.tapPostOptions,
|
|
24590
|
+
this.scheduler.ensureModulesChunksGraphApplied(compiler), this.changeDevtoolModuleFilename(compiler), compiler.hooks.compilation.tap(this.tapPostOptions, (compilation)=>{
|
|
24591
|
+
compilation.compiler && compilation.compiler !== compiler || this.thisCompilation(compilation);
|
|
24592
|
+
}), compiler.isChild() ? compiler.hooks.afterCompile.tapPromise(this.tapPreOptions, this.done.bind(this, compiler)) : compiler.hooks.done.tapPromise(this.tapPreOptions, this.done.bind(this, compiler));
|
|
24586
24593
|
} finally{
|
|
24587
24594
|
logger_timeEnd('InternalBundlePlugin.apply');
|
|
24588
24595
|
}
|
|
@@ -24611,10 +24618,11 @@ class InternalBundlePlugin extends InternalBasePlugin {
|
|
|
24611
24618
|
} finally{
|
|
24612
24619
|
logger_timeEnd('InternalBundlePlugin.thisCompilation');
|
|
24613
24620
|
}
|
|
24614
|
-
}, this.done = async ()=>{
|
|
24621
|
+
}, this.done = async (compiler)=>{
|
|
24615
24622
|
logger_time('InternalBundlePlugin.done');
|
|
24616
24623
|
try {
|
|
24617
|
-
|
|
24624
|
+
var gzip;
|
|
24625
|
+
this.scheduler.chunkGraph && Chunks.assetsContents(this.map, this.scheduler.chunkGraph, (gzip = this.scheduler.options.supports.gzip, !isCompilerWatching(compiler) && gzip)), this.sdk.addClientRoutes([
|
|
24618
24626
|
Manifest.RsdoctorManifestClientRoutes.ModuleGraph,
|
|
24619
24627
|
Manifest.RsdoctorManifestClientRoutes.BundleSize
|
|
24620
24628
|
]);
|
|
@@ -24636,8 +24644,8 @@ async function collectSourceMaps(map, assetLinesCodeList, _compilation, _this, s
|
|
|
24636
24644
|
let sourceMapDir1, consumer = await new SourceMapConsumer(map);
|
|
24637
24645
|
sourceMapPath ? sourceMapDir1 = dirname(sourceMapPath) : _compilation.options.output?.path && (sourceMapDir1 = 'string' == typeof _compilation.options.output.path ? _compilation.options.output.path : void 0);
|
|
24638
24646
|
let sourceRoot1 = map.sourceRoot, getRealSourcePath = (context = _this.sdk.root || process.cwd(), cache = _this._realSourcePathCache, sourceMapDir = sourceMapDir1, sourceRoot = sourceRoot1 ?? void 0, cache = cache || new Map(), (source, sourceMapFilenameRegex)=>{
|
|
24647
|
+
let resolved;
|
|
24639
24648
|
if (cache.has(source)) return cache.get(source);
|
|
24640
|
-
let resolved = UNASSIGNED;
|
|
24641
24649
|
if (source.startsWith('file://')) resolved = external_path_resolve(context, source.replace(/^file:\/\//, ''));
|
|
24642
24650
|
else if (source.startsWith('webpack://')) if (sourceMapFilenameRegex) {
|
|
24643
24651
|
let match = source.match(sourceMapFilenameRegex), filePath = match?.[1], baseDir = namespace && source.startsWith(`webpack://${namespace}`) || namespace && source.startsWith(`file://${namespace}`) ? process.cwd() : context;
|
|
@@ -24684,6 +24692,9 @@ async function collectSourceMaps(map, assetLinesCodeList, _compilation, _this, s
|
|
|
24684
24692
|
}
|
|
24685
24693
|
}
|
|
24686
24694
|
}
|
|
24695
|
+
function markAssetWithoutSourceMap(assetsWithoutSourceMap, assetName) {
|
|
24696
|
+
'string' == typeof assetName && /\.(?:js|bundle|css)$/.test(assetName) && assetsWithoutSourceMap.add(assetName);
|
|
24697
|
+
}
|
|
24687
24698
|
async function handleAfterEmitAssets(compilation, _this, sourceMapFilenameRegex, namespace) {
|
|
24688
24699
|
if ('rspack' in compilation.compiler) {
|
|
24689
24700
|
_this.sourceMapSets = new Map(), _this.assetsWithoutSourceMap ? _this.assetsWithoutSourceMap.clear() : _this.assetsWithoutSourceMap = new Set(), logger_time('ensureModulesChunkGraph.afterEmit.start');
|
|
@@ -24742,20 +24753,27 @@ async function handleAfterEmitAssets(compilation, _this, sourceMapFilenameRegex,
|
|
|
24742
24753
|
let baseNameWithoutHash = Graph.formatAssetName(sourceMapFileAssetName, 'string' == typeof compilation.options.output.filename ? compilation.options.output.filename : void 0);
|
|
24743
24754
|
sourceMapAsset = assets.find((asset)=>Graph.formatAssetName(asset.name, 'string' == typeof compilation.options.output.filename ? compilation.options.output.filename : void 0).includes(baseNameWithoutHash) && asset.name.endsWith('.map'));
|
|
24744
24755
|
}
|
|
24745
|
-
|
|
24746
|
-
|
|
24747
|
-
|
|
24748
|
-
|
|
24756
|
+
try {
|
|
24757
|
+
let sourceMapContent = sourceMapAsset?.source?.source();
|
|
24758
|
+
sourceMapContent && (map = JSON.parse(sourceMapContent.toString()));
|
|
24759
|
+
} catch (error) {
|
|
24760
|
+
rsdoctorLogger.debug(`Error parsing source map asset ${sourceMapFile}:`, error);
|
|
24761
|
+
}
|
|
24762
|
+
if (!map) {
|
|
24763
|
+
markAssetWithoutSourceMap(_this.assetsWithoutSourceMap, assetName);
|
|
24764
|
+
continue;
|
|
24749
24765
|
}
|
|
24766
|
+
let outputPath = compilation.options.output?.path;
|
|
24767
|
+
outputPath && 'string' == typeof outputPath && sourceMapAsset && (sourceMapPath = external_path_resolve(outputPath, sourceMapAsset.name));
|
|
24750
24768
|
} else {
|
|
24751
|
-
|
|
24769
|
+
markAssetWithoutSourceMap(_this.assetsWithoutSourceMap, assetName);
|
|
24752
24770
|
continue;
|
|
24753
24771
|
}
|
|
24754
24772
|
}
|
|
24755
24773
|
try {
|
|
24756
24774
|
await collectSourceMaps(map, assetLinesCodeList, compilation, _this, sourceMapFilenameRegex, namespace, skipSources, sourceMapPath);
|
|
24757
24775
|
} catch (e) {
|
|
24758
|
-
rsdoctorLogger.debug(e);
|
|
24776
|
+
rsdoctorLogger.debug(e), markAssetWithoutSourceMap(_this.assetsWithoutSourceMap, assetName);
|
|
24759
24777
|
}
|
|
24760
24778
|
_this.sourceMapSets.forEach((_value, key)=>{
|
|
24761
24779
|
skipSources.has(key) || skipSources.add(key);
|
|
@@ -24773,6 +24791,7 @@ let hasConsole = !1, ensureModulesChunksGraphFn = (compiler, _this)=>{
|
|
|
24773
24791
|
chunkGraph: !1,
|
|
24774
24792
|
moduleGraph: !1
|
|
24775
24793
|
}, rsdoctorLogger.debug('[RspackNativePlugin] Apply hooks'), compiler.hooks.compilation.tap('RsdoctorRspackPlugin', (compilation)=>{
|
|
24794
|
+
if (compilation.compiler && compilation.compiler !== compiler) return;
|
|
24776
24795
|
state.chunkGraph = !1, state.moduleGraph = !1;
|
|
24777
24796
|
let hooks = RsdoctorRspackPlugin.getCompilationHooks(compilation), cached = {}, dependOn = {
|
|
24778
24797
|
chunkGraphData: [],
|
|
@@ -24924,13 +24943,13 @@ let hasConsole = !1, ensureModulesChunksGraphFn = (compiler, _this)=>{
|
|
|
24924
24943
|
rsdoctorLogger.debug('[RspackNativePlugin] Called assets hook'), tryConsumeData('assetPatchData', rawAssetPatch);
|
|
24925
24944
|
});
|
|
24926
24945
|
}), state);
|
|
24927
|
-
_this._realSourcePathCache || (_this._realSourcePathCache = new Map()), compiler.hooks.done.tapPromise(internalPluginTapPreOptions('moduleGraph'), async ()=>{
|
|
24946
|
+
_this._realSourcePathCache || (_this._realSourcePathCache = new Map()), ('function' == typeof compiler.isChild && compiler.isChild() ? compiler.hooks.afterCompile : compiler.hooks.done).tapPromise(internalPluginTapPreOptions('moduleGraph'), async ()=>{
|
|
24928
24947
|
await doneHandler(_this, compiler, nativeGraphState);
|
|
24929
24948
|
}), compiler.hooks.compilation.tap({
|
|
24930
24949
|
...pluginTapPostOptions,
|
|
24931
24950
|
name: 'RsdoctorSourceMapCollector'
|
|
24932
24951
|
}, (compilation)=>{
|
|
24933
|
-
compilation.hooks.processAssets && compilation.hooks.processAssets.tapPromise({
|
|
24952
|
+
(!compilation.compiler || compilation.compiler === compiler) && compilation.hooks.processAssets && compilation.hooks.processAssets.tapPromise({
|
|
24934
24953
|
name: 'RsdoctorSourceMapCollector',
|
|
24935
24954
|
stage: 2400
|
|
24936
24955
|
}, async ()=>{
|
|
@@ -24946,15 +24965,16 @@ let hasConsole = !1, ensureModulesChunksGraphFn = (compiler, _this)=>{
|
|
|
24946
24965
|
});
|
|
24947
24966
|
};
|
|
24948
24967
|
async function doneHandler(_this, compiler, nativeGraphState) {
|
|
24968
|
+
var gzip;
|
|
24949
24969
|
if (!nativeGraphState.chunkGraph || !_this.chunkGraph) throw Error('[RsdoctorRspackPlugin] The Rspack native plugin did not provide chunk graph data.');
|
|
24950
24970
|
if (!nativeGraphState.moduleGraph) throw Error('[RsdoctorRspackPlugin] The Rspack native plugin did not provide module graph data.');
|
|
24951
|
-
let shouldParseBundle = !1 !== _this.options.supports.parseBundle, gzip = _this.options.supports.gzip;
|
|
24952
|
-
await getModulesInfos(compiler, _this.modulesGraph, _this.chunkGraph, shouldParseBundle, _this.sourceMapSets, _this.assetsWithoutSourceMap, !1 ===
|
|
24971
|
+
let shouldParseBundle = !1 !== _this.options.supports.parseBundle, gzip1 = (gzip = _this.options.supports.gzip, !isCompilerWatching(compiler) && gzip);
|
|
24972
|
+
await getModulesInfos(compiler, _this.modulesGraph, _this.chunkGraph, shouldParseBundle, _this.sourceMapSets, _this.assetsWithoutSourceMap, !1 === gzip1 ? {
|
|
24953
24973
|
enabled: !1
|
|
24954
24974
|
} : {
|
|
24955
24975
|
enabled: !0,
|
|
24956
|
-
level:
|
|
24957
|
-
}), rsdoctorLogger.debug('reportModuleGraph start'), await _this.sdk.reportModuleGraph(_this.modulesGraph), rsdoctorLogger.debug('reportModuleGraph done'), rsdoctorLogger.debug('reportChunkGraph start'), await _this.sdk.reportChunkGraph(_this.chunkGraph), rsdoctorLogger.debug('reportChunkGraph done'),
|
|
24976
|
+
level: gzip1.gzipLevel
|
|
24977
|
+
}), rsdoctorLogger.debug('reportModuleGraph start'), await _this.sdk.reportModuleGraph(_this.modulesGraph), rsdoctorLogger.debug('reportModuleGraph done'), rsdoctorLogger.debug('reportChunkGraph start'), await _this.sdk.reportChunkGraph(_this.chunkGraph), rsdoctorLogger.debug('reportChunkGraph done'), rsdoctorLogger.debug('doneHandler done');
|
|
24958
24978
|
}
|
|
24959
24979
|
let ensureDevtools = (compiler)=>{
|
|
24960
24980
|
let devtool = compiler.options.devtool;
|
|
@@ -25047,7 +25067,7 @@ class rule_Rule {
|
|
|
25047
25067
|
function defineRule(ruleCreator) {
|
|
25048
25068
|
return ruleCreator();
|
|
25049
25069
|
}
|
|
25050
|
-
var types_CheckVersionMap = ((CheckVersionMap = {})[CheckVersionMap.null = 0] = "null", CheckVersionMap[CheckVersionMap.prerelease =
|
|
25070
|
+
var types_CheckVersionMap = ((CheckVersionMap = {})[CheckVersionMap.null = 0] = "null", CheckVersionMap[CheckVersionMap.prerelease = 0x0000001] = "prerelease", CheckVersionMap[CheckVersionMap.prepatch = 0x0000011] = "prepatch", CheckVersionMap[CheckVersionMap.patch = 0x0000111] = "patch", CheckVersionMap[CheckVersionMap.preminor = 0x0001111] = "preminor", CheckVersionMap[CheckVersionMap.minor = 0x0011111] = "minor", CheckVersionMap[CheckVersionMap.premajor = 0x0111111] = "premajor", CheckVersionMap[CheckVersionMap.major = 0x1111111] = "major", CheckVersionMap);
|
|
25051
25071
|
let { J: duplicate_package_CheckVersionMap } = duplicate_package_types_namespaceObject, duplicate_package_rule = defineRule(()=>({
|
|
25052
25072
|
meta: {
|
|
25053
25073
|
code: 'E1001',
|
|
@@ -25116,7 +25136,7 @@ let { J: duplicate_package_CheckVersionMap } = duplicate_package_types_namespace
|
|
|
25116
25136
|
return node = dep.dependency.getProgram(), compare = [
|
|
25117
25137
|
exportsDefault,
|
|
25118
25138
|
moduleExportsDefault
|
|
25119
|
-
], !node.body.filter(parser_parser.asserts.isExpressionStatement).map((node)=>node.expression).filter(parser_parser.asserts.isAssignmentExpression).map((node)=>node.left).find((node)=>compare.some((item)=>parser_parser.utils.
|
|
25139
|
+
], !node.body.filter(parser_parser.asserts.isExpressionStatement).map((node)=>node.expression).filter(parser_parser.asserts.isAssignmentExpression).map((node)=>node.left).find((node)=>compare.some((item)=>parser_parser.utils.isSameSyntax(node, item)));
|
|
25120
25140
|
}).map((dependency)=>{
|
|
25121
25141
|
var node;
|
|
25122
25142
|
let { module, request } = dependency, node1 = module.getProgram() && (node = module.getProgram(), parser_parser.utils.getDefaultImports(node).find((decl)=>decl.source.value === request));
|
|
@@ -25244,7 +25264,7 @@ let loader_performance_optimization_rule = defineRule(()=>({
|
|
|
25244
25264
|
}
|
|
25245
25265
|
let sum = (arr)=>{
|
|
25246
25266
|
let v1 = arr.reduce((t, c)=>t + c.__costs__, 0), v2 = Math.max.apply(null, arr.map((e)=>e.endAt)) - Math.min.apply(arr.map((e)=>e.startAt));
|
|
25247
|
-
return v2 >= v1 ||
|
|
25267
|
+
return v2 >= v1 || -1 / 0 === v2 ? v1 : v2;
|
|
25248
25268
|
};
|
|
25249
25269
|
for (let [loaderName, v] of resultMap.entries()){
|
|
25250
25270
|
let nodeModulesFiles = v.filter((e)=>nodeModulesPathRegexp.test(e.__resource__.path)), nodeModulesFilesCosts = sum(nodeModulesFiles), outofCwdFiles = v.filter((e)=>!e.__resource__.path.startsWith(cwd)), outofCwdFilesCosts = sum(outofCwdFiles), msg = [
|
|
@@ -25360,7 +25380,7 @@ class ECMASyntaxError extends Error {
|
|
|
25360
25380
|
super(message), _define_property(this, "source", void 0), _define_property(this, "output", void 0), this.source = options.source, this.output = options.output;
|
|
25361
25381
|
}
|
|
25362
25382
|
}
|
|
25363
|
-
let
|
|
25383
|
+
let dist_isExcluded = (input, exclude)=>{
|
|
25364
25384
|
if (!exclude) return !1;
|
|
25365
25385
|
let excludes = Array.isArray(exclude) ? exclude : [
|
|
25366
25386
|
exclude
|
|
@@ -25387,7 +25407,7 @@ async function generateError({ err, code, filepath, rootPath, exclude, excludeEr
|
|
|
25387
25407
|
column: err.loc.column,
|
|
25388
25408
|
code: displayCodePointer(code, err.pos)
|
|
25389
25409
|
}
|
|
25390
|
-
})),
|
|
25410
|
+
})), dist_isExcluded(error.source.absolutePath, exclude) || dist_isExcluded(error.message, excludeErrorMessage)) ? null : error;
|
|
25391
25411
|
}
|
|
25392
25412
|
async function tryGenerateErrorFromSourceMap({ err, code, rootPath, outputFilepath, relativeOutputPath }) {
|
|
25393
25413
|
let sourceMapPath = `${outputFilepath}.map`;
|
|
@@ -25453,18 +25473,8 @@ async function tryGenerateErrorFromSourceMap({ err, code, rootPath, outputFilepa
|
|
|
25453
25473
|
}
|
|
25454
25474
|
async function generateHtmlScripts(filepath) {
|
|
25455
25475
|
var html;
|
|
25456
|
-
let
|
|
25457
|
-
return html = await node_fs.promises.readFile(filepath, 'utf-8'),
|
|
25458
|
-
onopentag (name, attrs) {
|
|
25459
|
-
"script" !== name || attrs.src || attrs.type && "application/javascript" !== attrs.type && "text/javascript" !== attrs.type || (currentScript = '');
|
|
25460
|
-
},
|
|
25461
|
-
ontext (text) {
|
|
25462
|
-
null !== currentScript && (currentScript += text);
|
|
25463
|
-
},
|
|
25464
|
-
onclosetag (tagname) {
|
|
25465
|
-
"script" === tagname && currentScript && inlineScripts.push(currentScript.trim()), currentScript = null;
|
|
25466
|
-
}
|
|
25467
|
-
})).write(html), parser.end(), inlineScripts;
|
|
25476
|
+
let parser;
|
|
25477
|
+
return html = await node_fs.promises.readFile(filepath, 'utf-8'), (parser = new Parser()).write(html), parser.end(), [];
|
|
25468
25478
|
}
|
|
25469
25479
|
function checkSyntax_define_property(obj, key, value) {
|
|
25470
25480
|
return key in obj ? Object.defineProperty(obj, key, {
|
|
@@ -25481,7 +25491,7 @@ class CheckSyntax {
|
|
|
25481
25491
|
if (HTML_REGEX.test(filepath)) {
|
|
25482
25492
|
let htmlScripts = await generateHtmlScripts(filepath);
|
|
25483
25493
|
await Promise.all(htmlScripts.map(async (script)=>{
|
|
25484
|
-
|
|
25494
|
+
dist_isExcluded(filepath, this.exclude) || await this.tryParse(filepath, script);
|
|
25485
25495
|
}));
|
|
25486
25496
|
}
|
|
25487
25497
|
if (JS_REGEX.test(filepath)) {
|
|
@@ -25706,35 +25716,54 @@ let ecma_version_check_rule = defineRule(()=>({
|
|
|
25706
25716
|
category: 'bundle',
|
|
25707
25717
|
severity: Linter.Severity.Warn,
|
|
25708
25718
|
defaultConfig: {
|
|
25709
|
-
ecmaVersion: void 0
|
|
25710
|
-
targets: []
|
|
25719
|
+
ecmaVersion: void 0
|
|
25711
25720
|
}
|
|
25712
25721
|
},
|
|
25713
25722
|
async check ({ chunkGraph, report, ruleConfig, root, configs }) {
|
|
25714
|
-
|
|
25715
|
-
|
|
25716
|
-
|
|
25717
|
-
|
|
25718
|
-
|
|
25719
|
-
|
|
25720
|
-
|
|
25721
|
-
|
|
25722
|
-
|
|
25723
|
-
|
|
25724
|
-
|
|
25725
|
-
|
|
25726
|
-
|
|
25727
|
-
|
|
25728
|
-
|
|
25729
|
-
|
|
25730
|
-
|
|
25731
|
-
|
|
25732
|
-
|
|
25733
|
-
|
|
25734
|
-
|
|
25723
|
+
let assets = chunkGraph.getAssets().filter((asset)=>{
|
|
25724
|
+
let extension = path_0.extname(asset.path);
|
|
25725
|
+
return '.js' === extension || '.bundle' === extension;
|
|
25726
|
+
});
|
|
25727
|
+
if (!assets.length) return;
|
|
25728
|
+
let { exclude, excludeErrorMessage, excludeOutput, targets, ecmaVersion } = ruleConfig, hasEcmaVersion = void 0 !== ecmaVersion, buildConfig = configs[0]?.config, context = buildConfig?.context || root, finalTargets = targets ?? (hasEcmaVersion ? [] : loadConfig({
|
|
25729
|
+
path: context,
|
|
25730
|
+
env: 'production'
|
|
25731
|
+
})) ?? [];
|
|
25732
|
+
if (!finalTargets.length && !hasEcmaVersion) return;
|
|
25733
|
+
let outputDir = buildConfig?.output?.path || path_0.resolve(root, 'dist'), checkSyntax = new CheckSyntax({
|
|
25734
|
+
exclude,
|
|
25735
|
+
excludeErrorMessage,
|
|
25736
|
+
excludeOutput,
|
|
25737
|
+
ecmaVersion,
|
|
25738
|
+
rootPath: context,
|
|
25739
|
+
targets: finalTargets
|
|
25740
|
+
});
|
|
25741
|
+
for (let asset of assets){
|
|
25742
|
+
let assetPath = path_0.resolve(outputDir, asset.path);
|
|
25743
|
+
!function(filepath, exclude) {
|
|
25744
|
+
if (!exclude) return !1;
|
|
25745
|
+
let conditions = Array.isArray(exclude) ? exclude : [
|
|
25746
|
+
exclude
|
|
25747
|
+
], normalizedPath = filepath.replace(/\\/g, '/');
|
|
25748
|
+
return conditions.some((condition)=>{
|
|
25749
|
+
if ('function' == typeof condition) return condition(filepath);
|
|
25750
|
+
if ('string' == typeof condition) return normalizedPath.startsWith(condition.replace(/\\/g, '/'));
|
|
25751
|
+
let lastIndex = condition.lastIndex;
|
|
25752
|
+
condition.lastIndex = 0;
|
|
25753
|
+
let isExcluded = condition.test(normalizedPath);
|
|
25754
|
+
return condition.lastIndex = lastIndex, isExcluded;
|
|
25735
25755
|
});
|
|
25736
|
-
});
|
|
25756
|
+
}(assetPath, excludeOutput) && await checkSyntax.check(assetPath, asset.content);
|
|
25737
25757
|
}
|
|
25758
|
+
checkSyntax.errors.forEach((err)=>{
|
|
25759
|
+
report({
|
|
25760
|
+
message: `Found syntax that does not match "ecmaVersion <= ${checkSyntax.ecmaVersion}"`,
|
|
25761
|
+
detail: {
|
|
25762
|
+
error: err,
|
|
25763
|
+
type: 'link'
|
|
25764
|
+
}
|
|
25765
|
+
});
|
|
25766
|
+
});
|
|
25738
25767
|
}
|
|
25739
25768
|
})), cross_chunks_package_title = 'cross-chunks-package', cross_chunks_package_rule = defineRule(()=>({
|
|
25740
25769
|
meta: {
|
|
@@ -25910,7 +25939,7 @@ function normalizePathForCompare(filePath) {
|
|
|
25910
25939
|
let splitIndex = [
|
|
25911
25940
|
filePath.indexOf('?'),
|
|
25912
25941
|
filePath.indexOf('#')
|
|
25913
|
-
].filter((index)=>index >= 0).reduce((min, index)=>Math.min(min, index), 1 / 0), cleanPath =
|
|
25942
|
+
].filter((index)=>index >= 0).reduce((min, index)=>Math.min(min, index), 1 / 0), cleanPath = 1 / 0 === splitIndex ? filePath : filePath.slice(0, splitIndex);
|
|
25914
25943
|
return path_0.normalize(cleanPath);
|
|
25915
25944
|
}
|
|
25916
25945
|
function isRecord(value) {
|
|
@@ -26070,11 +26099,21 @@ class linter_Linter {
|
|
|
26070
26099
|
await Promise.all(this.rules.map((rule)=>rule.afterValidate(context)));
|
|
26071
26100
|
}
|
|
26072
26101
|
}
|
|
26102
|
+
let ECMA_VERSION_CHECK_CODE = 'E1004';
|
|
26103
|
+
function formatLocation(error) {
|
|
26104
|
+
let syntaxError = error.detail?.error, location = syntaxError?.output ?? syntaxError?.source;
|
|
26105
|
+
if (!location?.path) return;
|
|
26106
|
+
let position = [
|
|
26107
|
+
location.line,
|
|
26108
|
+
location.column
|
|
26109
|
+
].filter((value)=>'number' == typeof value).join(':');
|
|
26110
|
+
return position ? `${location.path}:${position}` : location.path;
|
|
26111
|
+
}
|
|
26073
26112
|
class InternalRulesPlugin extends InternalBasePlugin {
|
|
26074
26113
|
apply(compiler) {
|
|
26075
26114
|
logger_time('InternalRulesPlugin.apply');
|
|
26076
26115
|
try {
|
|
26077
|
-
compiler.hooks.done.tapPromise(this.tapPreOptions, this.done);
|
|
26116
|
+
compiler.isChild() ? compiler.hooks.afterCompile.tapPromise(this.tapPreOptions, this.lint.bind(this)) : compiler.hooks.done.tapPromise(this.tapPreOptions, this.done);
|
|
26078
26117
|
} finally{
|
|
26079
26118
|
logger_timeEnd('InternalRulesPlugin.apply');
|
|
26080
26119
|
}
|
|
@@ -26087,12 +26126,35 @@ class InternalRulesPlugin extends InternalBasePlugin {
|
|
|
26087
26126
|
controller: {
|
|
26088
26127
|
noColor: !0
|
|
26089
26128
|
}
|
|
26090
|
-
})), errors = validateErrors.filter((item)=>'Error' === item.level), warnings = validateErrors.filter((item)=>'Warn' === item.level)
|
|
26129
|
+
})), errors = validateErrors.filter((item)=>'Error' === item.level), warnings = validateErrors.filter((item)=>'Warn' === item.level), compilationWarnings = function(warnings) {
|
|
26130
|
+
let firstWarning, target, issueCount, locations, displayedLocations, remainingFileCount, message, ecmaVersionWarnings = warnings.filter(({ code })=>code === ECMA_VERSION_CHECK_CODE);
|
|
26131
|
+
if (!ecmaVersionWarnings.length) return warnings;
|
|
26132
|
+
let summary = (firstWarning = ecmaVersionWarnings[0], target = firstWarning.message.match(/"([^"]+)"/)?.[1], issueCount = ecmaVersionWarnings.length, displayedLocations = (locations = [
|
|
26133
|
+
...new Set(ecmaVersionWarnings.map(formatLocation).filter(Boolean))
|
|
26134
|
+
]).slice(0, 3), remainingFileCount = locations.length - displayedLocations.length, message = [
|
|
26135
|
+
`Found ${issueCount} incompatible syntax ${1 === issueCount ? 'issue' : 'issues'}${target ? ` for "${target}"` : ''}.`,
|
|
26136
|
+
displayedLocations.length ? `Affected outputs: ${displayedLocations.join(', ')}${remainingFileCount > 0 ? `, ... (+${remainingFileCount} more ${1 === remainingFileCount ? 'file' : 'files'})` : ''}` : void 0,
|
|
26137
|
+
'View the Rsdoctor report for source-level details.'
|
|
26138
|
+
].filter(Boolean).join('\n'), new DevToolError(firstWarning.title, message, {
|
|
26139
|
+
category: firstWarning.category,
|
|
26140
|
+
code: firstWarning.code,
|
|
26141
|
+
controller: {
|
|
26142
|
+
noColor: !0
|
|
26143
|
+
},
|
|
26144
|
+
detail: firstWarning.detail,
|
|
26145
|
+
level: firstWarning.level
|
|
26146
|
+
})), summaryAdded = !1;
|
|
26147
|
+
return warnings.flatMap((warning)=>warning.code !== ECMA_VERSION_CHECK_CODE ? [
|
|
26148
|
+
warning
|
|
26149
|
+
] : summaryAdded ? [] : (summaryAdded = !0, [
|
|
26150
|
+
summary
|
|
26151
|
+
]));
|
|
26152
|
+
}(warnings);
|
|
26091
26153
|
result.replace.forEach((item)=>{
|
|
26092
26154
|
Array.isArray(compilation.errors) && compilation.errors.includes(item) && pull(compilation.errors, item), Array.isArray(compilation.warnings) && compilation.warnings.includes(item) && pull(compilation.warnings, item);
|
|
26093
26155
|
}), Array.isArray(compilation.errors) && errors.forEach((err)=>{
|
|
26094
26156
|
compilation.errors.push(err.toError());
|
|
26095
|
-
}), Array.isArray(compilation.warnings) &&
|
|
26157
|
+
}), Array.isArray(compilation.warnings) && compilationWarnings.forEach((err)=>{
|
|
26096
26158
|
compilation.warnings.push(err.toError());
|
|
26097
26159
|
}), this.sdk.reportError(validateErrors), await linter.afterValidate({
|
|
26098
26160
|
data: this.sdk.getRuleContext({}),
|
|
@@ -26160,4 +26222,5 @@ class InternalResolverPlugin extends InternalBasePlugin {
|
|
|
26160
26222
|
};
|
|
26161
26223
|
}
|
|
26162
26224
|
}
|
|
26163
|
-
export {
|
|
26225
|
+
export { default as fs_extra } from "fs-extra";
|
|
26226
|
+
export { DevToolError, InternalBundlePlugin, InternalErrorReporterPlugin, InternalLoaderPlugin, InternalPluginsPlugin, InternalResolverPlugin, InternalRulesPlugin, InternalSummaryPlugin, Linter as LinterType, ProbeLoaderPlugin, createServer, defaultHost, defaultPort, defineRule, ensureModulesChunksGraphFn, getCPUInfo, getInternalLoaderOptions, getMemoryInfo, getNodeVersion, getNpmVersion, getOriginLoaderModule, getPnpmVersion, getPortSync, getRspackNativePlugin, getYarnVersion, handleBriefModeReport, isCompilerWatching, linter_Linter as Linter, normalizeRspackUserOptions, processCompilerConfig, reportLoader, rule_Rule as LinterRule, rules_rules as rules, shouldSkipLoader };
|