@rsdoctor/core 2.0.0-beta.1 → 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
@@ -23641,11 +23641,13 @@ async function createServer(port, host = defaultHost) {
23641
23641
  let helpers = envinfo.helpers;
23642
23642
  envinfo.run;
23643
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]);
23644
- 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) {
23645
23645
  return Chunks.getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, {
23646
23646
  ...hasParseBundle ? {
23647
23647
  parseBundle: parseBundle_parseBundle
23648
23648
  } : {},
23649
+ brotli: !1 !== brotli,
23650
+ brotliLevel: !1 === brotli ? void 0 : brotli.brotliLevel,
23649
23651
  gzip: gzipOptions?.enabled,
23650
23652
  gzipLevel: gzipOptions?.enabled ? gzipOptions.level : void 0
23651
23653
  }, sourceMapSets, assetsWithoutSourceMap);
@@ -24043,8 +24045,8 @@ function isCompilerWatching(compiler) {
24043
24045
  return !!(compiler.watchMode || compiler.parentCompilation?.compiler.watchMode);
24044
24046
  }
24045
24047
  let normalizeRspackUserOptions = function(config = {}) {
24046
- var mode, mode1, finalMode, value, value1;
24047
- let finalBrief, finalNormalOptions, gzipLevel, reportCodeType, mode2;
24048
+ var mode, mode1, finalMode, value, value1, value2, value3;
24049
+ let finalBrief, finalNormalOptions, gzipLevel, brotliLevel, reportCodeType, mode2;
24048
24050
  for (let { name, value, replacement } of [
24049
24051
  {
24050
24052
  name: "top-level 'mode'",
@@ -24090,6 +24092,9 @@ let normalizeRspackUserOptions = function(config = {}) {
24090
24092
  parseBundle: defaultBoolean(userSupports.parseBundle, !0),
24091
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 && {
24092
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)
24093
24098
  })
24094
24099
  }, disableClientServer = 'true' !== process.env.RSTEST && (!!process.env.CI || userDisableClientServer);
24095
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);
@@ -24612,7 +24617,7 @@ class InternalBundlePlugin extends InternalBasePlugin {
24612
24617
  try {
24613
24618
  compilation.hooks.processAssets && compilation.hooks.afterProcessAssets.tap(this.tapPostOptions, (assets)=>{
24614
24619
  Object.keys(assets).forEach((file)=>{
24615
- this.ensureAssetContent(file).content = assets[file].source().toString();
24620
+ this.ensureAssetContent(file).content = assets[file].source();
24616
24621
  });
24617
24622
  });
24618
24623
  } finally{
@@ -24621,8 +24626,8 @@ class InternalBundlePlugin extends InternalBasePlugin {
24621
24626
  }, this.done = async (compiler)=>{
24622
24627
  logger_time('InternalBundlePlugin.done');
24623
24628
  try {
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([
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([
24626
24631
  Manifest.RsdoctorManifestClientRoutes.ModuleGraph,
24627
24632
  Manifest.RsdoctorManifestClientRoutes.BundleSize
24628
24633
  ]);
@@ -24965,24 +24970,24 @@ let hasConsole = !1, ensureModulesChunksGraphFn = (compiler, _this)=>{
24965
24970
  });
24966
24971
  };
24967
24972
  async function doneHandler(_this, compiler, nativeGraphState) {
24968
- var gzip;
24973
+ var compression, compression1;
24969
24974
  if (!nativeGraphState.chunkGraph || !_this.chunkGraph) throw Error('[RsdoctorRspackPlugin] The Rspack native plugin did not provide chunk graph data.');
24970
24975
  if (!nativeGraphState.moduleGraph) throw Error('[RsdoctorRspackPlugin] The Rspack native plugin did not provide module graph data.');
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 ? {
24976
+ let shouldParseBundle = !1 !== _this.options.supports.parseBundle, gzip = (compression = _this.options.supports.gzip, !isCompilerWatching(compiler) && compression);
24977
+ await getModulesInfos(compiler, _this.modulesGraph, _this.chunkGraph, shouldParseBundle, _this.sourceMapSets, _this.assetsWithoutSourceMap, !1 === gzip ? {
24973
24978
  enabled: !1
24974
24979
  } : {
24975
24980
  enabled: !0,
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');
24981
+ level: gzip.gzipLevel
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');
24978
24983
  }
24979
24984
  let ensureDevtools = (compiler)=>{
24980
24985
  let devtool = compiler.options.devtool;
24981
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);
24982
24987
  };
24983
- async function getModulesInfos(compiler, moduleGraph, chunkGraph, parseBundle, sourceMapSets, assetsWithoutSourceMap, gzipOptions) {
24988
+ async function getModulesInfos(compiler, moduleGraph, chunkGraph, parseBundle, sourceMapSets, assetsWithoutSourceMap, gzipOptions, brotli = !1) {
24984
24989
  if (moduleGraph) try {
24985
- await getAssetsModulesData(moduleGraph, chunkGraph, compiler.outputPath, sourceMapSets, parseBundle, assetsWithoutSourceMap, gzipOptions);
24990
+ await getAssetsModulesData(moduleGraph, chunkGraph, compiler.outputPath, sourceMapSets, parseBundle, assetsWithoutSourceMap, gzipOptions, brotli);
24986
24991
  } catch {}
24987
24992
  }
24988
24993
  function toSeverity(input, defaultLevel) {
@@ -1,4 +1,4 @@
1
- import { SDK } from '@rsdoctor/shared/types';
1
+ import { SDK, Plugin } from '@rsdoctor/shared/types';
2
2
  export type GzipOptions = {
3
3
  enabled: false;
4
4
  } | {
@@ -20,4 +20,4 @@ export type GzipOptions = {
20
20
  * If not provided and no source maps exist (sourceMapSets is empty), all assets will be parsed via AST.
21
21
  * @returns Promise that resolves when module data collection is complete
22
22
  */
23
- export declare function getAssetsModulesData(moduleGraph: SDK.ModuleGraphInstance, chunkGraph: SDK.ChunkGraphInstance, bundleDir: string, sourceMapSets: Map<string, string>, hasParseBundle?: boolean, assetsWithoutSourceMap?: Set<string>, gzipOptions?: GzipOptions): Promise<void>;
23
+ export declare function getAssetsModulesData(moduleGraph: SDK.ModuleGraphInstance, chunkGraph: SDK.ChunkGraphInstance, bundleDir: string, sourceMapSets: Map<string, string>, hasParseBundle?: boolean, assetsWithoutSourceMap?: Set<string>, gzipOptions?: GzipOptions, brotli?: Plugin.NormalizedBrotliConfig): Promise<void>;
package/dist/index.js CHANGED
@@ -1697,7 +1697,7 @@ class RsdoctorSDKController {
1697
1697
  return this.slaves.filter((item)=>this.activeSlaves.has(item));
1698
1698
  }
1699
1699
  }
1700
- var package_namespaceObject = JSON.parse('{"name":"@rsdoctor/core","version":"2.0.0-beta.1","repository":{"type":"git","url":"https://github.com/web-infra-dev/rsdoctor","directory":"packages/core"},"license":"MIT","type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./proxy-loader":{"types":"./dist/proxy-loader.d.ts","default":"./dist/proxy-loader.js"}},"main":"dist/index.js","types":"dist/index.d.ts","typesVersions":{"*":{".":["./dist/index.d.ts"],"proxy-loader":["./dist/proxy-loader.d.ts"]}},"files":["dist","static"],"scripts":{"build":"rs lib","dev":"npm run start","start":"rs lib -w","test":"rs test"},"dependencies":{"@babel/code-frame":"7.26.2","@rsdoctor/client":"workspace:*","@rsdoctor/shared":"workspace:*","@rspack/lite-tapable":"catalog:","@types/estree":"catalog:","acorn":"^8.10.0","acorn-import-attributes":"^1.9.5","acorn-walk":"8.3.5","browserslist-load-config":"^1.0.3","caniuse-lite":"^1.0.30001810","connect-next":"catalog:","cors":"2.8.6","envinfo":"7.21.0","fs-extra":"catalog:","get-port":"5.1.1","launch-editor":"^2.14.1","lines-and-columns":"2.0.4","open":"^11.0.2","raw-body":"3.0.2","rslog":"^2.1.3","semver":"^7.8.5","sirv":"catalog:","source-map":"catalog:","ws":"8.21.3"},"devDependencies":{"@rsbuild/plugin-check-syntax":"catalog:","@rspack/core":"catalog:","@scripts/test-helper":"workspace:*","@types/babel__code-frame":"7.27.0","@types/cors":"2.8.19","@types/envinfo":"7.8.4","@types/fs-extra":"catalog:","@types/node":"catalog:","@types/semver":"^7.8.0","@types/ws":"^8.18.1","babel-loader":"10.1.1","filesize":"catalog:","json-stream-stringify":"3.0.1","string-loader":"0.0.1","ts-loader":"^9.6.2","tslib":"catalog:","typescript":"catalog:"},"peerDependencies":{"@rspack/core":"^2.0.0"},"peerDependenciesMeta":{"@rspack/core":{"optional":true}},"engines":{"node":">=22.18.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"}}');
1700
+ var package_namespaceObject = JSON.parse('{"name":"@rsdoctor/core","version":"2.0.0-beta.2","repository":{"type":"git","url":"https://github.com/web-infra-dev/rsdoctor","directory":"packages/core"},"license":"MIT","type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./proxy-loader":{"types":"./dist/proxy-loader.d.ts","default":"./dist/proxy-loader.js"}},"main":"dist/index.js","types":"dist/index.d.ts","typesVersions":{"*":{".":["./dist/index.d.ts"],"proxy-loader":["./dist/proxy-loader.d.ts"]}},"files":["dist","static"],"scripts":{"build":"rs lib","dev":"npm run start","start":"rs lib -w","test":"rs test"},"dependencies":{"@babel/code-frame":"7.26.2","@rsdoctor/client":"workspace:*","@rsdoctor/shared":"workspace:*","@rspack/lite-tapable":"catalog:","@types/estree":"catalog:","acorn":"^8.10.0","acorn-import-attributes":"^1.9.5","acorn-walk":"8.3.5","browserslist-load-config":"^1.0.3","caniuse-lite":"^1.0.30001810","connect-next":"catalog:","cors":"2.8.6","envinfo":"7.21.0","fs-extra":"catalog:","get-port":"5.1.1","launch-editor":"^2.14.1","lines-and-columns":"2.0.4","open":"^11.0.2","raw-body":"3.0.2","rslog":"^2.1.3","semver":"^7.8.5","sirv":"catalog:","source-map":"catalog:","ws":"8.21.3"},"devDependencies":{"@rsbuild/plugin-check-syntax":"catalog:","@rspack/core":"catalog:","@scripts/test-helper":"workspace:*","@types/babel__code-frame":"7.27.0","@types/cors":"2.8.19","@types/envinfo":"7.8.4","@types/fs-extra":"catalog:","@types/node":"catalog:","@types/semver":"^7.8.0","@types/ws":"^8.18.1","babel-loader":"10.1.1","filesize":"catalog:","json-stream-stringify":"3.0.1","string-loader":"0.0.1","ts-loader":"^9.6.2","tslib":"catalog:","typescript":"catalog:"},"peerDependencies":{"@rspack/core":"^2.0.0"},"peerDependenciesMeta":{"@rspack/core":{"optional":true}},"engines":{"node":"^20.19.0 || >=22.12.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"}}');
1701
1701
  let pluginTapName = 'RsdoctorRspackPlugin', pluginTapPostOptions = {
1702
1702
  name: pluginTapName,
1703
1703
  stage: 999
@@ -3,12 +3,12 @@ import { InternalBasePlugin } from './base.js';
3
3
  export declare class InternalBundlePlugin<T extends Plugin.BaseCompiler> extends InternalBasePlugin<T> {
4
4
  readonly name = "bundle";
5
5
  map: Map<string, {
6
- content: string;
6
+ content: string | Buffer;
7
7
  }>;
8
8
  apply(compiler: T): void;
9
9
  changeDevtoolModuleFilename(compiler: Plugin.BaseCompiler): void;
10
10
  ensureAssetContent(name: string): {
11
- content: string;
11
+ content: string | Buffer;
12
12
  };
13
13
  thisCompilation: (compilation: Plugin.BaseCompilation) => void;
14
14
  done: (compiler: T) => Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import { Linter, Plugin, SDK } from '@rsdoctor/shared/types';
2
2
  export declare function isCompilerWatching(compiler: Pick<Plugin.BaseCompiler, 'watchMode' | 'parentCompilation'>): boolean;
3
- export declare function getEffectiveGzipConfig(compiler: Pick<Plugin.BaseCompiler, 'watchMode' | 'parentCompilation'>, gzip: Plugin.NormalizedGzipConfig): Plugin.NormalizedGzipConfig;
3
+ export declare function getEffectiveCompressionConfig<T extends Plugin.NormalizedGzipConfig | Plugin.NormalizedBrotliConfig>(compiler: Pick<Plugin.BaseCompiler, 'watchMode' | 'parentCompilation'>, compression: T): T | false;
4
4
  export declare function normalizeUserConfig<Rules extends Linter.ExtendRuleData[]>(config?: Plugin.RsdoctorRspackPluginOptions<Rules>): Plugin.RsdoctorPluginOptionsNormalized<Rules>;
5
5
  export declare const normalizeReportType: (reportCodeType: Plugin.NewReportCodeType | undefined, mode: keyof typeof SDK.IMode) => SDK.ToDataType;
6
6
  export declare const normalizeRspackUserOptions: typeof normalizeUserConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/core",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -57,8 +57,8 @@
57
57
  "sirv": "3.0.2",
58
58
  "source-map": "^0.7.6",
59
59
  "ws": "8.21.3",
60
- "@rsdoctor/client": "2.0.0-beta.1",
61
- "@rsdoctor/shared": "2.0.0-beta.1"
60
+ "@rsdoctor/client": "2.0.0-beta.2",
61
+ "@rsdoctor/shared": "2.0.0-beta.2"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@rsbuild/plugin-check-syntax": "^1.6.1",
@@ -88,7 +88,7 @@
88
88
  }
89
89
  },
90
90
  "engines": {
91
- "node": ">=22.18.0"
91
+ "node": "^20.19.0 || >=22.12.0"
92
92
  },
93
93
  "publishConfig": {
94
94
  "access": "public",