@rsdoctor/core 2.0.0-beta.0 → 2.0.0-beta.2

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 CHANGED
@@ -1,7 +1,7 @@
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 fs_extra from "fs-extra";
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";
@@ -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() - 31558432982.399998 * node.years, context);
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,
@@ -23663,11 +23641,13 @@ async function createServer(port, host = defaultHost) {
23663
23641
  let helpers = envinfo.helpers;
23664
23642
  envinfo.run;
23665
23643
  let getCPUInfo = ()=>helpers.getCPUInfo().then((res)=>res[1]), getMemoryInfo = ()=>helpers.getMemoryInfo().then((res)=>res[1]), getNodeVersion = ()=>helpers.getNodeInfo().then((res)=>res[1]), getYarnVersion = ()=>helpers.getYarnInfo().then((res)=>res[1]), getNpmVersion = ()=>helpers.getnpmInfo().then((res)=>res[1]), getPnpmVersion = ()=>helpers.getpnpmInfo().then((res)=>res[1]);
23666
- async function getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, sourceMapSets, hasParseBundle = !0, assetsWithoutSourceMap, gzipOptions) {
23644
+ async function getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, sourceMapSets, hasParseBundle = !0, assetsWithoutSourceMap, gzipOptions, brotli = !1) {
23667
23645
  return Chunks.getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, {
23668
23646
  ...hasParseBundle ? {
23669
23647
  parseBundle: parseBundle_parseBundle
23670
23648
  } : {},
23649
+ brotli: !1 !== brotli,
23650
+ brotliLevel: !1 === brotli ? void 0 : brotli.brotliLevel,
23671
23651
  gzip: gzipOptions?.enabled,
23672
23652
  gzipLevel: gzipOptions?.enabled ? gzipOptions.level : void 0
23673
23653
  }, sourceMapSets, assetsWithoutSourceMap);
@@ -23685,12 +23665,16 @@ class ProbeLoaderPlugin {
23685
23665
  });
23686
23666
  }
23687
23667
  addProbeLoader(compiler) {
23668
+ if (this.instrumentedCompilers.has(compiler)) return;
23688
23669
  let rules = compiler.options.module.rules;
23689
23670
  if (Loader.isVue(compiler)) {
23690
- compiler.options.module.rules = addProbeLoader2Rules(rules, compiler, (r)=>!!r.loader || 'string' == typeof r);
23671
+ compiler.options.module.rules = addProbeLoader2Rules(rules, compiler, (r)=>!!r.loader || 'string' == typeof r), this.instrumentedCompilers.add(compiler);
23691
23672
  return;
23692
23673
  }
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));
23674
+ 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);
23675
+ }
23676
+ constructor(){
23677
+ this.instrumentedCompilers = new WeakSet();
23694
23678
  }
23695
23679
  }
23696
23680
  function truncateMessage(input, maxLen = 1000) {
@@ -24057,65 +24041,72 @@ function makeRulesSerializable(rules) {
24057
24041
  function defaultBoolean(v, dft) {
24058
24042
  return 'boolean' == typeof v ? v : dft;
24059
24043
  }
24060
- function getDefaultOutput() {
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
- };
24044
+ function isCompilerWatching(compiler) {
24045
+ return !!(compiler.watchMode || compiler.parentCompilation?.compiler.watchMode);
24072
24046
  }
24073
- let normalizeReportType = (reportCodeType, mode)=>{
24074
- let convertedReportCodeType = 'object' == typeof reportCodeType ? function(reportCodeType) {
24075
- if (reportCodeType) {
24076
- if (reportCodeType.noCode) return 'noCode';
24077
- else if (reportCodeType.noAssetsAndModuleSource) return 'noAssetsAndModuleSource';
24078
- else if (reportCodeType.noModuleSource) return 'noModuleSource';
24047
+ let normalizeRspackUserOptions = function(config = {}) {
24048
+ var mode, mode1, finalMode, value, value1, value2, value3;
24049
+ let finalBrief, finalNormalOptions, gzipLevel, brotliLevel, reportCodeType, mode2;
24050
+ for (let { name, value, replacement } of [
24051
+ {
24052
+ name: "top-level 'mode'",
24053
+ value: config.mode,
24054
+ replacement: 'lite' === config.mode ? 'output.reportCodeType' : 'output.mode'
24055
+ },
24056
+ {
24057
+ name: "top-level 'port'",
24058
+ value: config.port,
24059
+ replacement: 'server.port'
24060
+ },
24061
+ {
24062
+ name: "top-level 'brief'",
24063
+ value: config.brief,
24064
+ replacement: 'output.options.htmlOptions'
24065
+ },
24066
+ {
24067
+ name: "'output.compressData'",
24068
+ value: config.output?.compressData,
24069
+ replacement: "output.mode: 'brief' and output.options.type: ['json']"
24079
24070
  }
24080
- }(reportCodeType) : reportCodeType;
24081
- return 'noCode' === convertedReportCodeType || mode === SDK.IMode[SDK.IMode.brief] ? SDK.ToDataType.NoCode : mode === SDK.IMode[SDK.IMode.lite] || 'noAssetsAndModuleSource' === convertedReportCodeType ? SDK.ToDataType.NoSourceAndAssets : 'noModuleSource' === convertedReportCodeType ? SDK.ToDataType.NoSource : SDK.ToDataType.Normal;
24082
- }, normalizeRspackUserOptions = function(config = {}) {
24083
- var mode, mode1, finalMode, value, value1;
24084
- let gzipLevel, finalBrief, finalNormalOptions, userOutput = config.output, defaultOutput = getDefaultOutput(), outputConfig = 'json' === process.env.RSDOCTOR_OUTPUT ? {
24071
+ ])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.`));
24072
+ 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."));
24073
+ let userOutput = config.output, outputConfig = 'json' === process.env.RSDOCTOR_OUTPUT ? {
24085
24074
  reportDir: userOutput?.reportDir,
24086
- compressData: userOutput?.compressData,
24087
24075
  mode: 'brief',
24088
24076
  options: {
24089
24077
  type: [
24090
24078
  'json'
24091
24079
  ]
24092
24080
  }
24093
- } : userOutput ?? defaultOutput, { linter = {}, features = {}, loaderInterceptorOptions = {}, disableClientServer: userDisableClientServer = !1, sdkInstance, innerClientPath = '', output = outputConfig, supports: userSupports = {}, port, server: userServer = {}, printLog = {
24081
+ } : userOutput ?? {
24082
+ mode: void 0,
24083
+ options: void 0,
24084
+ reportDir: ''
24085
+ }, { linter = {}, features = {}, loaderInterceptorOptions = {}, disableClientServer: userDisableClientServer = !1, sdkInstance, innerClientPath = '', output = outputConfig, supports: userSupports = {}, server: userServer = {}, printLog = {
24094
24086
  serverUrls: !0
24095
- }, mode: mode2, brief, multiCompiler = !0 } = {
24087
+ }, multiCompiler = !0 } = {
24096
24088
  ...config,
24097
24089
  output: outputConfig
24098
24090
  }, supports = {
24099
- ...{
24100
- parseBundle: !0
24101
- },
24102
- ...userSupports,
24091
+ banner: defaultBoolean(userSupports.banner, !0),
24092
+ parseBundle: defaultBoolean(userSupports.parseBundle, !0),
24103
24093
  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 && {
24104
24094
  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)
24095
+ }),
24096
+ brotli: (assert(void 0 === (value2 = userSupports.brotli) || 'boolean' == typeof value2 || 'object' == typeof value2 && null !== value2 && !Array.isArray(value2), '`supports.brotli` must be a boolean or an object.'), !1 !== value2 && void 0 !== value2 && {
24097
+ brotliLevel: (assert('number' == typeof (brotliLevel = void 0 === (value3 = 'object' == typeof value2 && null !== value2 ? value2.brotliLevel : void 0) ? 6 : value3) && Number.isInteger(brotliLevel) && brotliLevel >= 0 && brotliLevel <= 11, '`supports.brotli.brotliLevel` must be an integer between 0 and 11.'), brotliLevel)
24105
24098
  })
24106
24099
  }, disableClientServer = 'true' !== process.env.RSTEST && (!!process.env.CI || userDisableClientServer);
24107
- assert('object' == typeof linter), assert('object' == typeof features || Array.isArray(features)), assert('object' == typeof loaderInterceptorOptions), assert('boolean' == typeof disableClientServer), assert(void 0 === port || 'number' == typeof port), assert('object' == typeof userServer && null !== userServer);
24100
+ 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);
24108
24101
  let server = {
24109
24102
  ...userServer
24110
24103
  };
24111
- assert(void 0 === server.port || 'number' == typeof server.port), assert('boolean' == typeof multiCompiler || 'object' == typeof multiCompiler && null !== multiCompiler), void 0 === server.port && void 0 !== port && (server.port = port);
24104
+ assert(void 0 === server.port || 'number' == typeof server.port), assert('boolean' == typeof multiCompiler || 'object' == typeof multiCompiler && null !== multiCompiler);
24112
24105
  let finalMode1 = ('mode' in output && 'string' == typeof (mode = output.mode) && [
24113
24106
  'brief',
24114
24107
  'normal',
24115
24108
  'lite'
24116
- ].includes(mode) ? 'lite' === output.mode ? SDK.IMode[SDK.IMode.normal] : output.mode : void 0) || mode2 || SDK.IMode[SDK.IMode.normal];
24117
- mode2 && rsdoctorLogger.info(external_rslog_color.yellow("The 'mode' configuration will be deprecated in a future version. Please use 'output.mode' instead."));
24118
- let _features = (mode1 = finalMode1, Array.isArray(features) ? {
24109
+ ].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) ? {
24119
24110
  loader: features.includes('loader'),
24120
24111
  plugins: features.includes('plugins'),
24121
24112
  resolver: features.includes('resolver'),
@@ -24134,12 +24125,9 @@ let normalizeReportType = (reportCodeType, mode)=>{
24134
24125
  extends: [],
24135
24126
  level: 'Error',
24136
24127
  ...linter
24137
- };
24138
- (_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."));
24139
- let { finalBrief: finalBrief1, finalNormalOptions: finalNormalOptions1 } = (finalBrief = {}, finalNormalOptions = {}, 'brief' === (finalMode = finalMode1) ? finalBrief = function(output, brief) {
24128
+ }, { finalBrief: finalBrief1, finalNormalOptions: finalNormalOptions1 } = (finalBrief = {}, finalNormalOptions = {}, 'brief' === (finalMode = finalMode1) ? finalBrief = function(output) {
24140
24129
  let htmlOptions = {
24141
- reportHtmlName: void 0,
24142
- writeDataJson: !1
24130
+ reportHtmlName: void 0
24143
24131
  }, jsonOptions = {}, briefOptions = output?.options || {};
24144
24132
  if ('type' in briefOptions && briefOptions.type?.includes('json') && (jsonOptions = briefOptions.jsonOptions || {
24145
24133
  fileName: 'rsdoctor-data.json',
@@ -24151,8 +24139,7 @@ let normalizeReportType = (reportCodeType, mode)=>{
24151
24139
  }), 'type' in briefOptions && briefOptions.type?.includes('html') || !briefOptions.type) {
24152
24140
  let outputBriefOptions = briefOptions?.htmlOptions;
24153
24141
  htmlOptions = {
24154
- reportHtmlName: outputBriefOptions?.reportHtmlName || brief?.reportHtmlName || void 0,
24155
- writeDataJson: outputBriefOptions?.writeDataJson || brief?.writeDataJson || !1
24142
+ reportHtmlName: outputBriefOptions?.reportHtmlName || void 0
24156
24143
  };
24157
24144
  }
24158
24145
  return {
@@ -24162,12 +24149,17 @@ let normalizeReportType = (reportCodeType, mode)=>{
24162
24149
  htmlOptions,
24163
24150
  jsonOptions
24164
24151
  };
24165
- }(output, brief) : 'normal' === finalMode && (finalNormalOptions = {}), {
24152
+ }(output) : 'normal' === finalMode && (finalNormalOptions = {}), {
24166
24153
  finalBrief,
24167
24154
  finalNormalOptions
24168
24155
  });
24169
24156
  _features.lite && finalMode1 !== SDK.IMode[SDK.IMode.brief] && (finalMode1 = SDK.IMode[SDK.IMode.lite]);
24170
- let reportCodeType = output.reportCodeType ? normalizeReportType(output.reportCodeType, finalMode1) : normalizeReportType(getDefaultOutput().reportCodeType, finalMode1), res = {
24157
+ let reportCodeType1 = (reportCodeType = output.reportCodeType, mode2 = finalMode1, (assert(void 0 === reportCodeType || [
24158
+ 'noModuleSource',
24159
+ 'noAssetsAndModuleSource',
24160
+ 'noCode'
24161
+ ].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);
24162
+ return {
24171
24163
  linter: _linter,
24172
24164
  features: _features,
24173
24165
  loaderInterceptorOptions: {
@@ -24178,12 +24170,11 @@ let normalizeReportType = (reportCodeType, mode)=>{
24178
24170
  output: {
24179
24171
  mode: finalMode1,
24180
24172
  options: 'brief' === finalMode1 ? finalBrief1 : finalNormalOptions1,
24181
- reportCodeType,
24173
+ reportCodeType: reportCodeType1,
24182
24174
  reportDir: output.reportDir || ''
24183
24175
  },
24184
24176
  innerClientPath,
24185
24177
  supports,
24186
- port,
24187
24178
  server,
24188
24179
  printLog,
24189
24180
  multiCompiler: {
@@ -24191,7 +24182,6 @@ let normalizeReportType = (reportCodeType, mode)=>{
24191
24182
  group: 'object' == typeof multiCompiler ? multiCompiler.group : void 0
24192
24183
  }
24193
24184
  };
24194
- return void 0 !== output.compressData && rsdoctorLogger.info(external_rslog_color.yellow("The 'compressData' configuration will be deprecated in a future version.")), res;
24195
24185
  }, execAsync = promisify(external_node_child_process_exec), supportedChromiumBrowsers = [
24196
24186
  'Google Chrome Canary',
24197
24187
  'Google Chrome Dev',
@@ -24379,6 +24369,7 @@ class InternalLoaderPlugin extends InternalBasePlugin {
24379
24369
  }
24380
24370
  }
24381
24371
  getInterceptRules(compiler, rules) {
24372
+ let cacheMarkerPath = this.getCacheMarkerPath(compiler);
24382
24373
  return function(rules, loaderPath, options, loaderResolver, cwd = process.cwd()) {
24383
24374
  return mapEachRules(rules, (rule)=>{
24384
24375
  if (rule.loader?.startsWith('builtin:') || rule.loader?.endsWith('.mjs') || isESMLoader(rule)) return rule;
@@ -24402,11 +24393,22 @@ class InternalLoaderPlugin extends InternalBasePlugin {
24402
24393
  };
24403
24394
  });
24404
24395
  }(rules, this.internalLoaderPath, {
24396
+ cacheMarkerPath,
24405
24397
  cwd: compiler.context || process.cwd(),
24406
24398
  host: this.sdk.server.origin,
24407
24399
  skipLoaders: this.options.loaderInterceptorOptions.skipLoaders
24408
24400
  }, compiler.resolverFactory.get('loader', compiler.options.resolveLoader), this.sdk.root);
24409
24401
  }
24402
+ getCacheMarkerPath(compiler) {
24403
+ if ('object' != typeof compiler.options.cache || 'persistent' !== compiler.options.cache.type) return;
24404
+ if (this.cacheMarkerPath) return this.cacheMarkerPath;
24405
+ let markerPath = node_path.join(this.sdk.outputDir, '.loader-cache');
24406
+ node_fs.mkdirSync(node_path.dirname(markerPath), {
24407
+ recursive: !0
24408
+ });
24409
+ let previous = node_fs.existsSync(markerPath) ? node_fs.readFileSync(markerPath, 'utf8') : '', prefix = previous.length < 4096 ? previous : '';
24410
+ return node_fs.writeFileSync(markerPath, `${prefix}${randomUUID()}\n`), this.cacheMarkerPath = markerPath, markerPath;
24411
+ }
24410
24412
  constructor(...args){
24411
24413
  super(...args), this.name = 'loader', this.internalLoaderPath = loader_require.resolve('@rsdoctor/core/proxy-loader'), this.afterPlugins = (compiler)=>{
24412
24414
  logger_time('InternalLoaderPlugin.afterPlugins');
@@ -24592,7 +24594,7 @@ class InternalBundlePlugin extends InternalBasePlugin {
24592
24594
  try {
24593
24595
  this.scheduler.ensureModulesChunksGraphApplied(compiler), this.changeDevtoolModuleFilename(compiler), compiler.hooks.compilation.tap(this.tapPostOptions, (compilation)=>{
24594
24596
  compilation.compiler && compilation.compiler !== compiler || this.thisCompilation(compilation);
24595
- }), compiler.isChild() ? compiler.hooks.afterCompile.tapPromise(this.tapPreOptions, this.done.bind(this)) : compiler.hooks.done.tapPromise(this.tapPreOptions, this.done.bind(this));
24597
+ }), compiler.isChild() ? compiler.hooks.afterCompile.tapPromise(this.tapPreOptions, this.done.bind(this, compiler)) : compiler.hooks.done.tapPromise(this.tapPreOptions, this.done.bind(this, compiler));
24596
24598
  } finally{
24597
24599
  logger_timeEnd('InternalBundlePlugin.apply');
24598
24600
  }
@@ -24615,16 +24617,17 @@ class InternalBundlePlugin extends InternalBasePlugin {
24615
24617
  try {
24616
24618
  compilation.hooks.processAssets && compilation.hooks.afterProcessAssets.tap(this.tapPostOptions, (assets)=>{
24617
24619
  Object.keys(assets).forEach((file)=>{
24618
- this.ensureAssetContent(file).content = assets[file].source().toString();
24620
+ this.ensureAssetContent(file).content = assets[file].source();
24619
24621
  });
24620
24622
  });
24621
24623
  } finally{
24622
24624
  logger_timeEnd('InternalBundlePlugin.thisCompilation');
24623
24625
  }
24624
- }, this.done = async ()=>{
24626
+ }, this.done = async (compiler)=>{
24625
24627
  logger_time('InternalBundlePlugin.done');
24626
24628
  try {
24627
- this.scheduler.chunkGraph && Chunks.assetsContents(this.map, this.scheduler.chunkGraph, this.scheduler.options.supports.gzip), this.sdk.addClientRoutes([
24629
+ var compression, compression1;
24630
+ this.scheduler.chunkGraph && Chunks.assetsContents(this.map, this.scheduler.chunkGraph, (compression = this.scheduler.options.supports.gzip, !isCompilerWatching(compiler) && compression), (compression1 = this.scheduler.options.supports.brotli, !isCompilerWatching(compiler) && compression1)), this.sdk.addClientRoutes([
24628
24631
  Manifest.RsdoctorManifestClientRoutes.ModuleGraph,
24629
24632
  Manifest.RsdoctorManifestClientRoutes.BundleSize
24630
24633
  ]);
@@ -24694,6 +24697,9 @@ async function collectSourceMaps(map, assetLinesCodeList, _compilation, _this, s
24694
24697
  }
24695
24698
  }
24696
24699
  }
24700
+ function markAssetWithoutSourceMap(assetsWithoutSourceMap, assetName) {
24701
+ 'string' == typeof assetName && /\.(?:js|bundle|css)$/.test(assetName) && assetsWithoutSourceMap.add(assetName);
24702
+ }
24697
24703
  async function handleAfterEmitAssets(compilation, _this, sourceMapFilenameRegex, namespace) {
24698
24704
  if ('rspack' in compilation.compiler) {
24699
24705
  _this.sourceMapSets = new Map(), _this.assetsWithoutSourceMap ? _this.assetsWithoutSourceMap.clear() : _this.assetsWithoutSourceMap = new Set(), logger_time('ensureModulesChunkGraph.afterEmit.start');
@@ -24752,20 +24758,27 @@ async function handleAfterEmitAssets(compilation, _this, sourceMapFilenameRegex,
24752
24758
  let baseNameWithoutHash = Graph.formatAssetName(sourceMapFileAssetName, 'string' == typeof compilation.options.output.filename ? compilation.options.output.filename : void 0);
24753
24759
  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'));
24754
24760
  }
24755
- if (sourceMapAsset) {
24756
- map = JSON.parse(sourceMapAsset.source.source().toString());
24757
- let outputPath = compilation.options.output?.path;
24758
- outputPath && 'string' == typeof outputPath && (sourceMapPath = external_path_resolve(outputPath, sourceMapAsset.name));
24761
+ try {
24762
+ let sourceMapContent = sourceMapAsset?.source?.source();
24763
+ sourceMapContent && (map = JSON.parse(sourceMapContent.toString()));
24764
+ } catch (error) {
24765
+ rsdoctorLogger.debug(`Error parsing source map asset ${sourceMapFile}:`, error);
24759
24766
  }
24767
+ if (!map) {
24768
+ markAssetWithoutSourceMap(_this.assetsWithoutSourceMap, assetName);
24769
+ continue;
24770
+ }
24771
+ let outputPath = compilation.options.output?.path;
24772
+ outputPath && 'string' == typeof outputPath && sourceMapAsset && (sourceMapPath = external_path_resolve(outputPath, sourceMapAsset.name));
24760
24773
  } else {
24761
- assetName && 'string' == typeof assetName && (assetName.endsWith('.js') || assetName.endsWith('.bundle') || assetName.endsWith('.css')) && _this.assetsWithoutSourceMap.add(assetName);
24774
+ markAssetWithoutSourceMap(_this.assetsWithoutSourceMap, assetName);
24762
24775
  continue;
24763
24776
  }
24764
24777
  }
24765
24778
  try {
24766
24779
  await collectSourceMaps(map, assetLinesCodeList, compilation, _this, sourceMapFilenameRegex, namespace, skipSources, sourceMapPath);
24767
24780
  } catch (e) {
24768
- rsdoctorLogger.debug(e);
24781
+ rsdoctorLogger.debug(e), markAssetWithoutSourceMap(_this.assetsWithoutSourceMap, assetName);
24769
24782
  }
24770
24783
  _this.sourceMapSets.forEach((_value, key)=>{
24771
24784
  skipSources.has(key) || skipSources.add(key);
@@ -24957,23 +24970,24 @@ let hasConsole = !1, ensureModulesChunksGraphFn = (compiler, _this)=>{
24957
24970
  });
24958
24971
  };
24959
24972
  async function doneHandler(_this, compiler, nativeGraphState) {
24973
+ var compression, compression1;
24960
24974
  if (!nativeGraphState.chunkGraph || !_this.chunkGraph) throw Error('[RsdoctorRspackPlugin] The Rspack native plugin did not provide chunk graph data.');
24961
24975
  if (!nativeGraphState.moduleGraph) throw Error('[RsdoctorRspackPlugin] The Rspack native plugin did not provide module graph data.');
24962
- let shouldParseBundle = !1 !== _this.options.supports.parseBundle, gzip = _this.options.supports.gzip;
24976
+ let shouldParseBundle = !1 !== _this.options.supports.parseBundle, gzip = (compression = _this.options.supports.gzip, !isCompilerWatching(compiler) && compression);
24963
24977
  await getModulesInfos(compiler, _this.modulesGraph, _this.chunkGraph, shouldParseBundle, _this.sourceMapSets, _this.assetsWithoutSourceMap, !1 === gzip ? {
24964
24978
  enabled: !1
24965
24979
  } : {
24966
24980
  enabled: !0,
24967
24981
  level: gzip.gzipLevel
24968
- }), 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'), _this.options.supports.generateTileGraph && rsdoctorLogger.warn(external_rslog_color.yellow('The option generateTileGraph is deprecated. Treemap (i.e. Tile Graph) is now supported by default.')), rsdoctorLogger.debug('doneHandler done');
24982
+ }, (compression1 = _this.options.supports.brotli, !isCompilerWatching(compiler) && compression1)), 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');
24969
24983
  }
24970
24984
  let ensureDevtools = (compiler)=>{
24971
24985
  let devtool = compiler.options.devtool;
24972
24986
  return !('string' == typeof devtool && /eval/i.test(devtool)) || (hasConsole || rsdoctorLogger.warn('SourceMap with eval is not supported. Please use other sourcemap options.'), hasConsole = !0, !1);
24973
24987
  };
24974
- async function getModulesInfos(compiler, moduleGraph, chunkGraph, parseBundle, sourceMapSets, assetsWithoutSourceMap, gzipOptions) {
24988
+ async function getModulesInfos(compiler, moduleGraph, chunkGraph, parseBundle, sourceMapSets, assetsWithoutSourceMap, gzipOptions, brotli = !1) {
24975
24989
  if (moduleGraph) try {
24976
- await getAssetsModulesData(moduleGraph, chunkGraph, compiler.outputPath, sourceMapSets, parseBundle, assetsWithoutSourceMap, gzipOptions);
24990
+ await getAssetsModulesData(moduleGraph, chunkGraph, compiler.outputPath, sourceMapSets, parseBundle, assetsWithoutSourceMap, gzipOptions, brotli);
24977
24991
  } catch {}
24978
24992
  }
24979
24993
  function toSeverity(input, defaultLevel) {
@@ -25058,7 +25072,7 @@ class rule_Rule {
25058
25072
  function defineRule(ruleCreator) {
25059
25073
  return ruleCreator();
25060
25074
  }
25061
- var types_CheckVersionMap = ((CheckVersionMap = {})[CheckVersionMap.null = 0] = "null", CheckVersionMap[CheckVersionMap.prerelease = 1] = "prerelease", CheckVersionMap[CheckVersionMap.prepatch = 17] = "prepatch", CheckVersionMap[CheckVersionMap.patch = 273] = "patch", CheckVersionMap[CheckVersionMap.preminor = 4369] = "preminor", CheckVersionMap[CheckVersionMap.minor = 69905] = "minor", CheckVersionMap[CheckVersionMap.premajor = 1118481] = "premajor", CheckVersionMap[CheckVersionMap.major = 17895697] = "major", CheckVersionMap);
25075
+ 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);
25062
25076
  let { J: duplicate_package_CheckVersionMap } = duplicate_package_types_namespaceObject, duplicate_package_rule = defineRule(()=>({
25063
25077
  meta: {
25064
25078
  code: 'E1001',
@@ -25127,7 +25141,7 @@ let { J: duplicate_package_CheckVersionMap } = duplicate_package_types_namespace
25127
25141
  return node = dep.dependency.getProgram(), compare = [
25128
25142
  exportsDefault,
25129
25143
  moduleExportsDefault
25130
- ], !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.isSameSemantics(node, item)));
25144
+ ], !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)));
25131
25145
  }).map((dependency)=>{
25132
25146
  var node;
25133
25147
  let { module, request } = dependency, node1 = module.getProgram() && (node = module.getProgram(), parser_parser.utils.getDefaultImports(node).find((decl)=>decl.source.value === request));
@@ -25255,7 +25269,7 @@ let loader_performance_optimization_rule = defineRule(()=>({
25255
25269
  }
25256
25270
  let sum = (arr)=>{
25257
25271
  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));
25258
- return v2 >= v1 || v2 === -1 / 0 ? v1 : v2;
25272
+ return v2 >= v1 || -1 / 0 === v2 ? v1 : v2;
25259
25273
  };
25260
25274
  for (let [loaderName, v] of resultMap.entries()){
25261
25275
  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 = [
@@ -25371,7 +25385,7 @@ class ECMASyntaxError extends Error {
25371
25385
  super(message), _define_property(this, "source", void 0), _define_property(this, "output", void 0), this.source = options.source, this.output = options.output;
25372
25386
  }
25373
25387
  }
25374
- let isExcluded = (input, exclude)=>{
25388
+ let dist_isExcluded = (input, exclude)=>{
25375
25389
  if (!exclude) return !1;
25376
25390
  let excludes = Array.isArray(exclude) ? exclude : [
25377
25391
  exclude
@@ -25398,7 +25412,7 @@ async function generateError({ err, code, filepath, rootPath, exclude, excludeEr
25398
25412
  column: err.loc.column,
25399
25413
  code: displayCodePointer(code, err.pos)
25400
25414
  }
25401
- })), isExcluded(error.source.absolutePath, exclude) || isExcluded(error.message, excludeErrorMessage)) ? null : error;
25415
+ })), dist_isExcluded(error.source.absolutePath, exclude) || dist_isExcluded(error.message, excludeErrorMessage)) ? null : error;
25402
25416
  }
25403
25417
  async function tryGenerateErrorFromSourceMap({ err, code, rootPath, outputFilepath, relativeOutputPath }) {
25404
25418
  let sourceMapPath = `${outputFilepath}.map`;
@@ -25464,18 +25478,8 @@ async function tryGenerateErrorFromSourceMap({ err, code, rootPath, outputFilepa
25464
25478
  }
25465
25479
  async function generateHtmlScripts(filepath) {
25466
25480
  var html;
25467
- let inlineScripts, currentScript, parser;
25468
- return html = await node_fs.promises.readFile(filepath, 'utf-8'), inlineScripts = [], currentScript = null, (parser = new Parser({
25469
- onopentag (name, attrs) {
25470
- "script" !== name || attrs.src || attrs.type && "application/javascript" !== attrs.type && "text/javascript" !== attrs.type || (currentScript = '');
25471
- },
25472
- ontext (text) {
25473
- null !== currentScript && (currentScript += text);
25474
- },
25475
- onclosetag (tagname) {
25476
- "script" === tagname && currentScript && inlineScripts.push(currentScript.trim()), currentScript = null;
25477
- }
25478
- })).write(html), parser.end(), inlineScripts;
25481
+ let parser;
25482
+ return html = await node_fs.promises.readFile(filepath, 'utf-8'), (parser = new Parser()).write(html), parser.end(), [];
25479
25483
  }
25480
25484
  function checkSyntax_define_property(obj, key, value) {
25481
25485
  return key in obj ? Object.defineProperty(obj, key, {
@@ -25492,7 +25496,7 @@ class CheckSyntax {
25492
25496
  if (HTML_REGEX.test(filepath)) {
25493
25497
  let htmlScripts = await generateHtmlScripts(filepath);
25494
25498
  await Promise.all(htmlScripts.map(async (script)=>{
25495
- isExcluded(filepath, this.exclude) || await this.tryParse(filepath, script);
25499
+ dist_isExcluded(filepath, this.exclude) || await this.tryParse(filepath, script);
25496
25500
  }));
25497
25501
  }
25498
25502
  if (JS_REGEX.test(filepath)) {
@@ -25717,35 +25721,54 @@ let ecma_version_check_rule = defineRule(()=>({
25717
25721
  category: 'bundle',
25718
25722
  severity: Linter.Severity.Warn,
25719
25723
  defaultConfig: {
25720
- ecmaVersion: void 0,
25721
- targets: []
25724
+ ecmaVersion: void 0
25722
25725
  }
25723
25726
  },
25724
25727
  async check ({ chunkGraph, report, ruleConfig, root, configs }) {
25725
- for (let asset of chunkGraph.getAssets()){
25726
- if ('.js' !== path_0.extname(asset.path) && '.bundle' !== path_0.extname(asset.path)) continue;
25727
- let browserslistConfig = loadConfig({
25728
- path: root,
25729
- env: 'production'
25730
- }), { exclude, excludeOutput, targets, ecmaVersion } = ruleConfig, finalTargets = targets || browserslistConfig || [];
25731
- if (!finalTargets.length && !ecmaVersion) return;
25732
- let buildConfig = configs[0]?.config, checkSyntax = new CheckSyntax({
25733
- exclude,
25734
- excludeOutput,
25735
- ecmaVersion,
25736
- rootPath: buildConfig?.context || root,
25737
- targets: finalTargets
25738
- }), outputDir = buildConfig?.output?.path || path_0.resolve(root, 'dist'), assetPath = path_0.resolve(outputDir, asset.path);
25739
- await checkSyntax.check(assetPath, asset.content), checkSyntax.errors.forEach((err)=>{
25740
- report({
25741
- message: `Found syntax that does not match "ecmaVersion <= ${checkSyntax.ecmaVersion}"`,
25742
- detail: {
25743
- error: err,
25744
- type: 'link'
25745
- }
25728
+ let assets = chunkGraph.getAssets().filter((asset)=>{
25729
+ let extension = path_0.extname(asset.path);
25730
+ return '.js' === extension || '.bundle' === extension;
25731
+ });
25732
+ if (!assets.length) return;
25733
+ let { exclude, excludeErrorMessage, excludeOutput, targets, ecmaVersion } = ruleConfig, hasEcmaVersion = void 0 !== ecmaVersion, buildConfig = configs[0]?.config, context = buildConfig?.context || root, finalTargets = targets ?? (hasEcmaVersion ? [] : loadConfig({
25734
+ path: context,
25735
+ env: 'production'
25736
+ })) ?? [];
25737
+ if (!finalTargets.length && !hasEcmaVersion) return;
25738
+ let outputDir = buildConfig?.output?.path || path_0.resolve(root, 'dist'), checkSyntax = new CheckSyntax({
25739
+ exclude,
25740
+ excludeErrorMessage,
25741
+ excludeOutput,
25742
+ ecmaVersion,
25743
+ rootPath: context,
25744
+ targets: finalTargets
25745
+ });
25746
+ for (let asset of assets){
25747
+ let assetPath = path_0.resolve(outputDir, asset.path);
25748
+ !function(filepath, exclude) {
25749
+ if (!exclude) return !1;
25750
+ let conditions = Array.isArray(exclude) ? exclude : [
25751
+ exclude
25752
+ ], normalizedPath = filepath.replace(/\\/g, '/');
25753
+ return conditions.some((condition)=>{
25754
+ if ('function' == typeof condition) return condition(filepath);
25755
+ if ('string' == typeof condition) return normalizedPath.startsWith(condition.replace(/\\/g, '/'));
25756
+ let lastIndex = condition.lastIndex;
25757
+ condition.lastIndex = 0;
25758
+ let isExcluded = condition.test(normalizedPath);
25759
+ return condition.lastIndex = lastIndex, isExcluded;
25746
25760
  });
25747
- });
25761
+ }(assetPath, excludeOutput) && await checkSyntax.check(assetPath, asset.content);
25748
25762
  }
25763
+ checkSyntax.errors.forEach((err)=>{
25764
+ report({
25765
+ message: `Found syntax that does not match "ecmaVersion <= ${checkSyntax.ecmaVersion}"`,
25766
+ detail: {
25767
+ error: err,
25768
+ type: 'link'
25769
+ }
25770
+ });
25771
+ });
25749
25772
  }
25750
25773
  })), cross_chunks_package_title = 'cross-chunks-package', cross_chunks_package_rule = defineRule(()=>({
25751
25774
  meta: {
@@ -25921,7 +25944,7 @@ function normalizePathForCompare(filePath) {
25921
25944
  let splitIndex = [
25922
25945
  filePath.indexOf('?'),
25923
25946
  filePath.indexOf('#')
25924
- ].filter((index)=>index >= 0).reduce((min, index)=>Math.min(min, index), 1 / 0), cleanPath = splitIndex === 1 / 0 ? filePath : filePath.slice(0, splitIndex);
25947
+ ].filter((index)=>index >= 0).reduce((min, index)=>Math.min(min, index), 1 / 0), cleanPath = 1 / 0 === splitIndex ? filePath : filePath.slice(0, splitIndex);
25925
25948
  return path_0.normalize(cleanPath);
25926
25949
  }
25927
25950
  function isRecord(value) {
@@ -26081,6 +26104,16 @@ class linter_Linter {
26081
26104
  await Promise.all(this.rules.map((rule)=>rule.afterValidate(context)));
26082
26105
  }
26083
26106
  }
26107
+ let ECMA_VERSION_CHECK_CODE = 'E1004';
26108
+ function formatLocation(error) {
26109
+ let syntaxError = error.detail?.error, location = syntaxError?.output ?? syntaxError?.source;
26110
+ if (!location?.path) return;
26111
+ let position = [
26112
+ location.line,
26113
+ location.column
26114
+ ].filter((value)=>'number' == typeof value).join(':');
26115
+ return position ? `${location.path}:${position}` : location.path;
26116
+ }
26084
26117
  class InternalRulesPlugin extends InternalBasePlugin {
26085
26118
  apply(compiler) {
26086
26119
  logger_time('InternalRulesPlugin.apply');
@@ -26098,12 +26131,35 @@ class InternalRulesPlugin extends InternalBasePlugin {
26098
26131
  controller: {
26099
26132
  noColor: !0
26100
26133
  }
26101
- })), errors = validateErrors.filter((item)=>'Error' === item.level), warnings = validateErrors.filter((item)=>'Warn' === item.level);
26134
+ })), errors = validateErrors.filter((item)=>'Error' === item.level), warnings = validateErrors.filter((item)=>'Warn' === item.level), compilationWarnings = function(warnings) {
26135
+ let firstWarning, target, issueCount, locations, displayedLocations, remainingFileCount, message, ecmaVersionWarnings = warnings.filter(({ code })=>code === ECMA_VERSION_CHECK_CODE);
26136
+ if (!ecmaVersionWarnings.length) return warnings;
26137
+ let summary = (firstWarning = ecmaVersionWarnings[0], target = firstWarning.message.match(/"([^"]+)"/)?.[1], issueCount = ecmaVersionWarnings.length, displayedLocations = (locations = [
26138
+ ...new Set(ecmaVersionWarnings.map(formatLocation).filter(Boolean))
26139
+ ]).slice(0, 3), remainingFileCount = locations.length - displayedLocations.length, message = [
26140
+ `Found ${issueCount} incompatible syntax ${1 === issueCount ? 'issue' : 'issues'}${target ? ` for "${target}"` : ''}.`,
26141
+ displayedLocations.length ? `Affected outputs: ${displayedLocations.join(', ')}${remainingFileCount > 0 ? `, ... (+${remainingFileCount} more ${1 === remainingFileCount ? 'file' : 'files'})` : ''}` : void 0,
26142
+ 'View the Rsdoctor report for source-level details.'
26143
+ ].filter(Boolean).join('\n'), new DevToolError(firstWarning.title, message, {
26144
+ category: firstWarning.category,
26145
+ code: firstWarning.code,
26146
+ controller: {
26147
+ noColor: !0
26148
+ },
26149
+ detail: firstWarning.detail,
26150
+ level: firstWarning.level
26151
+ })), summaryAdded = !1;
26152
+ return warnings.flatMap((warning)=>warning.code !== ECMA_VERSION_CHECK_CODE ? [
26153
+ warning
26154
+ ] : summaryAdded ? [] : (summaryAdded = !0, [
26155
+ summary
26156
+ ]));
26157
+ }(warnings);
26102
26158
  result.replace.forEach((item)=>{
26103
26159
  Array.isArray(compilation.errors) && compilation.errors.includes(item) && pull(compilation.errors, item), Array.isArray(compilation.warnings) && compilation.warnings.includes(item) && pull(compilation.warnings, item);
26104
26160
  }), Array.isArray(compilation.errors) && errors.forEach((err)=>{
26105
26161
  compilation.errors.push(err.toError());
26106
- }), Array.isArray(compilation.warnings) && warnings.forEach((err)=>{
26162
+ }), Array.isArray(compilation.warnings) && compilationWarnings.forEach((err)=>{
26107
26163
  compilation.warnings.push(err.toError());
26108
26164
  }), this.sdk.reportError(validateErrors), await linter.afterValidate({
26109
26165
  data: this.sdk.getRuleContext({}),
@@ -26171,4 +26227,5 @@ class InternalResolverPlugin extends InternalBasePlugin {
26171
26227
  };
26172
26228
  }
26173
26229
  }
26174
- export { DevToolError, FileSharding, InternalBundlePlugin, InternalErrorReporterPlugin, InternalLoaderPlugin, InternalPluginsPlugin, InternalResolverPlugin, InternalRulesPlugin, InternalSummaryPlugin, Linter as LinterType, ProbeLoaderPlugin, createServer, defaultHost, defaultPort, defineRule, ensureModulesChunksGraphFn, fs_extra, getCPUInfo, getMemoryInfo, getNodeVersion, getNpmVersion, getOriginLoaderModule, getPnpmVersion, getPortSync, getRspackNativePlugin, getYarnVersion, handleBriefModeReport, linter_Linter as Linter, normalizeRspackUserOptions, processCompilerConfig, reportLoader, rule_Rule as LinterRule, rules_rules as rules, shouldSkipLoader };
26230
+ export { default as fs_extra } from "fs-extra";
26231
+ 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 };