@rsdoctor/core 1.5.8 → 1.5.10

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.
Files changed (100) hide show
  1. package/dist/build-utils/build/chunks/assetsModules.d.cts +17 -0
  2. package/dist/build-utils/build/chunks/chunkTransform.d.cts +4 -0
  3. package/dist/build-utils/build/chunks/index.d.cts +3 -0
  4. package/dist/build-utils/build/chunks/rspack/transform.d.cts +13 -0
  5. package/dist/build-utils/build/index.d.cts +5 -0
  6. package/dist/build-utils/build/loader/index.d.cts +2 -0
  7. package/dist/build-utils/build/loader/probeLoader.d.cts +4 -0
  8. package/dist/build-utils/build/loader/probeLoaderPlugin.d.cts +5 -0
  9. package/dist/build-utils/build/module-graph/index.d.cts +4 -0
  10. package/dist/build-utils/build/module-graph/parser.d.cts +2 -0
  11. package/dist/build-utils/build/module-graph/rspack/transform.d.cts +26 -0
  12. package/dist/build-utils/build/module-graph/transform.d.cts +4 -0
  13. package/dist/build-utils/build/module-graph/treeShaking.d.cts +2 -0
  14. package/dist/build-utils/build/module-graph/utils.d.cts +3 -0
  15. package/dist/build-utils/build/module-graph/webpack/transform.cjs +1 -1
  16. package/dist/build-utils/build/module-graph/webpack/transform.d.cts +16 -0
  17. package/dist/build-utils/build/module-graph/webpack/transform.js +1 -1
  18. package/dist/build-utils/build/utils/index.d.cts +3 -0
  19. package/dist/build-utils/build/utils/loader.cjs +3 -4
  20. package/dist/build-utils/build/utils/loader.d.cts +20 -0
  21. package/dist/build-utils/build/utils/loader.js +3 -4
  22. package/dist/build-utils/build/utils/parseBundle.d.cts +12 -0
  23. package/dist/build-utils/build/utils/plugin.d.cts +5 -0
  24. package/dist/build-utils/index.d.cts +1 -0
  25. package/dist/index.d.cts +3 -0
  26. package/dist/inner-plugins/constants.d.cts +6 -0
  27. package/dist/inner-plugins/index.d.cts +2 -0
  28. package/dist/inner-plugins/loaders/proxy.cjs +10 -4
  29. package/dist/inner-plugins/loaders/proxy.d.cts +7 -0
  30. package/dist/inner-plugins/loaders/proxy.js +10 -4
  31. package/dist/inner-plugins/plugins/base.d.cts +12 -0
  32. package/dist/inner-plugins/plugins/bundle.d.cts +15 -0
  33. package/dist/inner-plugins/plugins/bundleTagPlugin.cjs +3 -3
  34. package/dist/inner-plugins/plugins/bundleTagPlugin.d.cts +6 -0
  35. package/dist/inner-plugins/plugins/bundleTagPlugin.js +3 -3
  36. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +3 -3
  37. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.cts +36 -0
  38. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +3 -3
  39. package/dist/inner-plugins/plugins/errors.d.cts +11 -0
  40. package/dist/inner-plugins/plugins/index.d.cts +11 -0
  41. package/dist/inner-plugins/plugins/loader.d.cts +10 -0
  42. package/dist/inner-plugins/plugins/plugins.d.cts +8 -0
  43. package/dist/inner-plugins/plugins/progress.d.cts +8 -0
  44. package/dist/inner-plugins/plugins/resolver.d.cts +13 -0
  45. package/dist/inner-plugins/plugins/rspack.d.cts +4 -0
  46. package/dist/inner-plugins/plugins/rules.d.cts +8 -0
  47. package/dist/inner-plugins/plugins/sourcemapTool.cjs +2 -2
  48. package/dist/inner-plugins/plugins/sourcemapTool.d.cts +52 -0
  49. package/dist/inner-plugins/plugins/sourcemapTool.js +2 -2
  50. package/dist/inner-plugins/plugins/summary.cjs +1 -1
  51. package/dist/inner-plugins/plugins/summary.d.cts +14 -0
  52. package/dist/inner-plugins/plugins/summary.js +1 -1
  53. package/dist/inner-plugins/utils/circleDetect.d.cts +4 -0
  54. package/dist/inner-plugins/utils/config.d.cts +5 -0
  55. package/dist/inner-plugins/utils/index.d.cts +9 -0
  56. package/dist/inner-plugins/utils/loader.d.cts +13 -0
  57. package/dist/inner-plugins/utils/normalize-config.d.cts +40 -0
  58. package/dist/inner-plugins/utils/plugin-common.d.cts +11 -0
  59. package/dist/inner-plugins/utils/plugin.cjs +7 -7
  60. package/dist/inner-plugins/utils/plugin.d.cts +4 -0
  61. package/dist/inner-plugins/utils/plugin.js +7 -7
  62. package/dist/inner-plugins/utils/sdk.d.cts +8 -0
  63. package/dist/rules/index.d.cts +3 -0
  64. package/dist/rules/linter.d.cts +9 -0
  65. package/dist/rules/rule.cjs +1 -1
  66. package/dist/rules/rule.d.cts +27 -0
  67. package/dist/rules/rule.js +1 -1
  68. package/dist/rules/rules/cjs-require/index.d.cts +4 -0
  69. package/dist/rules/rules/cjs-require/types.d.cts +7 -0
  70. package/dist/rules/rules/cross-chunks-package/index.d.cts +4 -0
  71. package/dist/rules/rules/cross-chunks-package/types.d.cts +3 -0
  72. package/dist/rules/rules/cross-chunks-package/utils.d.cts +1 -0
  73. package/dist/rules/rules/default-import-check/index.d.cts +4 -0
  74. package/dist/rules/rules/default-import-check/types.d.cts +4 -0
  75. package/dist/rules/rules/default-import-check/utils.d.cts +10 -0
  76. package/dist/rules/rules/duplicate-package/index.d.cts +4 -0
  77. package/dist/rules/rules/duplicate-package/types.d.cts +24 -0
  78. package/dist/rules/rules/duplicate-package/utils.d.cts +3 -0
  79. package/dist/rules/rules/ecma-version-check/index.d.cts +4 -0
  80. package/dist/rules/rules/ecma-version-check/types.d.cts +3 -0
  81. package/dist/rules/rules/ecma-version-check/utils.d.cts +2 -0
  82. package/dist/rules/rules/esm-resolved-to-cjs/index.cjs +30 -2
  83. package/dist/rules/rules/esm-resolved-to-cjs/index.d.cts +4 -0
  84. package/dist/rules/rules/esm-resolved-to-cjs/index.js +30 -2
  85. package/dist/rules/rules/esm-resolved-to-cjs/types.d.cts +8 -0
  86. package/dist/rules/rules/index.d.cts +1 -0
  87. package/dist/rules/rules/loader-performance-optimization/index.d.cts +4 -0
  88. package/dist/rules/rules/loader-performance-optimization/types.d.cts +22 -0
  89. package/dist/rules/rules/loader-performance-optimization/utils.d.cts +1 -0
  90. package/dist/rules/rules/module-mixed-chunks/index.d.cts +4 -0
  91. package/dist/rules/rules/module-mixed-chunks/types.d.cts +3 -0
  92. package/dist/rules/rules/side-effects-only-imports/index.d.cts +4 -0
  93. package/dist/rules/rules/side-effects-only-imports/types.d.cts +9 -0
  94. package/dist/rules/utils.d.cts +3 -0
  95. package/dist/types/chunks.d.cts +6 -0
  96. package/dist/types/index.d.cts +4 -0
  97. package/dist/types/loader.d.cts +19 -0
  98. package/dist/types/plugin.d.cts +51 -0
  99. package/dist/types/rules.d.cts +7 -0
  100. package/package.json +46 -21
@@ -0,0 +1,17 @@
1
+ import { SDK } from '@rsdoctor/types';
2
+ /**
3
+ * Collects module size data from bundle assets, using source maps when available
4
+ * and falling back to AST parsing for assets without source maps.
5
+ *
6
+ * @param moduleGraph - The module graph instance
7
+ * @param chunkGraph - The chunk graph instance
8
+ * @param bundleDir - Directory containing the bundle assets
9
+ * @param sourceMapSets - Map of module paths to their source code (from source maps)
10
+ * @param hasParseBundle - Whether to enable AST parsing fallback
11
+ * @param assetsWithoutSourceMap - Optional set of asset paths that don't have source maps.
12
+ * When provided, these assets will be parsed using AST parsing instead of source map data.
13
+ * This is used as a fallback mechanism when source maps are unavailable for specific assets.
14
+ * If not provided and no source maps exist (sourceMapSets is empty), all assets will be parsed via AST.
15
+ * @returns Promise that resolves when module data collection is complete
16
+ */
17
+ export declare function getAssetsModulesData(moduleGraph: SDK.ModuleGraphInstance, chunkGraph: SDK.ChunkGraphInstance, bundleDir: string, sourceMapSets: Map<string, string>, hasParseBundle?: boolean, assetsWithoutSourceMap?: Set<string>): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { Plugin } from '@rsdoctor/types';
2
+ export declare function chunkTransform(assetMap: Map<string, {
3
+ content: string;
4
+ }>, bundleStats: Plugin.StatsCompilation): import("@rsdoctor/graph").ChunkGraph;
@@ -0,0 +1,3 @@
1
+ export * from './assetsModules';
2
+ export * from './chunkTransform';
3
+ export * from './rspack/transform';
@@ -0,0 +1,13 @@
1
+ import { Plugin, SDK } from '@rsdoctor/types';
2
+ /**
3
+ * Patch native chunk graph data from Rspack into ChunkGraph instance
4
+ * @param cg The ChunkGraph instance to be patched
5
+ * @param rawChunkGraph Raw chunk graph data from Rspack native plugin
6
+ */
7
+ export declare function patchNativeChunkGraph(cg: SDK.ChunkGraphInstance, rawChunkGraph: Plugin.RspackNativeChunkGraph): void;
8
+ /**
9
+ * Patch native assets data from Rspack into ChunkGraph instance
10
+ * @param cg The ChunkGraph instance to be patched
11
+ * @param rawAssetPatch Raw assets patch data from Rspack native plugin
12
+ */
13
+ export declare function patchNativeAssets(cg: SDK.ChunkGraphInstance, rawAssetPatch: Plugin.RspackNativeAssetPatch): void;
@@ -0,0 +1,5 @@
1
+ export * as Chunks from './chunks';
2
+ export * as Utils from './utils';
3
+ export * as Loader from './loader';
4
+ export * as Types from '../../types';
5
+ export * as ModuleGraph from './module-graph';
@@ -0,0 +1,2 @@
1
+ export * from './probeLoaderPlugin';
2
+ export * from './probeLoader';
@@ -0,0 +1,4 @@
1
+ import { Plugin } from '@rsdoctor/types';
2
+ import type { LoaderDefinitionFunction } from '@rspack/core';
3
+ export declare const loaderModule: Plugin.LoaderDefinition<Parameters<LoaderDefinitionFunction>, {}>;
4
+ export default loaderModule;
@@ -0,0 +1,5 @@
1
+ import { Plugin } from '@rsdoctor/types';
2
+ export declare class ProbeLoaderPlugin {
3
+ apply(compiler: Plugin.BaseCompiler): void;
4
+ private addProbeLoader;
5
+ }
@@ -0,0 +1,4 @@
1
+ export * from './webpack/transform';
2
+ export * from './transform';
3
+ export * from './treeShaking';
4
+ export * from './rspack/transform';
@@ -0,0 +1,2 @@
1
+ import { Node } from '@rsdoctor/utils/ruleUtils';
2
+ export declare function hasSetEsModuleStatement(program: Node.Program): boolean;
@@ -0,0 +1,26 @@
1
+ import { Plugin, SDK } from '@rsdoctor/types';
2
+ /**
3
+ * Patch native module graph data from Rspack into ModuleGraph instance
4
+ * @param mg The ModuleGraph instance to be patched
5
+ * @param cg The ChunkGraph instance to be patched
6
+ * @param rawModuleGraph Raw module graph data from Rspack native plugin
7
+ */
8
+ export declare function patchNativeModuleGraph(mg: SDK.ModuleGraphInstance, cg: SDK.ChunkGraphInstance, rawModuleGraph: Plugin.RspackNativeModuleGraph): void;
9
+ /**
10
+ * Patch native ids data from Rspack into ModuleGraph instance
11
+ * @param mg The ModuleGraph instance to be patched
12
+ * @param rawModuleIdsPatch Raw ids patch data from Rspack native plugin
13
+ */
14
+ export declare function patchNativeModuleIds(mg: SDK.ModuleGraphInstance, rawModuleIdsPatch: Plugin.RspackNativeModuleIdsPatch): void;
15
+ /**
16
+ * Patch native sources data from Rspack into ModuleGraph instance
17
+ * @param mg The ModuleGraph instance to be patched
18
+ * @param rawModuleIdsPatch Raw sources patch data from Rspack native plugin
19
+ */
20
+ export declare function patchNativeModuleSources(mg: SDK.ModuleGraphInstance, rawModuleSourcesPatch: Plugin.RspackNativeModuleSourcePatch): void;
21
+ /**
22
+ * Extract and store code snippets for side effect locations
23
+ * This should be called after module sources have been set
24
+ * @param mg The ModuleGraph instance with modules and side effect locations
25
+ */
26
+ export declare function extractSideEffectCodes(mg: SDK.ModuleGraphInstance): void;
@@ -0,0 +1,4 @@
1
+ import { Plugin } from '@rsdoctor/types';
2
+ import { TransformContext } from '.';
3
+ import { SDK } from '@rsdoctor/types';
4
+ export declare function getModuleGraphByStats(compilation: Plugin.BaseCompilation, stats: Plugin.StatsCompilation, root: string, chunkGraph: SDK.ChunkGraphInstance, features?: Plugin.RsdoctorWebpackPluginFeatures, context?: TransformContext): Promise<SDK.ModuleGraphInstance>;
@@ -0,0 +1,2 @@
1
+ import type { SDK, Plugin } from '@rsdoctor/types';
2
+ export declare function appendTreeShaking(moduleGraph: SDK.ModuleGraphInstance, compilation: Plugin.BaseCompilation): SDK.ModuleGraphInstance;
@@ -0,0 +1,3 @@
1
+ import { SDK } from '@rsdoctor/types';
2
+ export declare function getExportIdentifierStatement(name: string, module: SDK.ModuleInstance): SDK.StatementInstance | undefined;
3
+ export declare function getDeclarationIdentifier(name: string, module: SDK.ModuleInstance): SDK.StatementInstance | undefined;
@@ -155,7 +155,7 @@ async function appendModuleGraphByCompilation(compilation, graph, features, cont
155
155
  await Promise.all(allModules.map((module)=>appendModuleData(module, webpackGraph, graph, fileSystemInfo, features, context)));
156
156
  graph_namespaceObject.ModuleGraphTrans.removeNoImportStyle(graph);
157
157
  return graph;
158
- } catch (e) {
158
+ } catch {
159
159
  return graph;
160
160
  }
161
161
  }
@@ -0,0 +1,16 @@
1
+ import type { SourceMapConsumer } from 'source-map';
2
+ import * as Webpack from 'webpack';
3
+ import * as Rspack from '@rspack/core';
4
+ import { Node } from '@rsdoctor/utils/ruleUtils';
5
+ import { Plugin, SDK } from '@rsdoctor/types';
6
+ export interface TransformContext {
7
+ astCache?: Map<Webpack.NormalModule, Node.Program>;
8
+ packagePathMap?: Map<string, string>;
9
+ getSourceMap?(module: string): Promise<SourceMapConsumer | undefined>;
10
+ }
11
+ /**
12
+ * Get the type of dependencies between modules.
13
+ * This property can determine what runtime webpack has added to the modules.
14
+ */
15
+ export declare function getModuleExportsType(module: Webpack.NormalModule | Rspack.NormalModule, moduleGraph?: Webpack.ModuleGraph, strict?: boolean): SDK.DependencyBuildMeta['exportsType'];
16
+ export declare function appendModuleGraphByCompilation(compilation: Plugin.BaseCompilation, graph: SDK.ModuleGraphInstance, features?: Plugin.RsdoctorWebpackPluginFeatures, context?: TransformContext): Promise<SDK.ModuleGraphInstance>;
@@ -117,7 +117,7 @@ async function appendModuleGraphByCompilation(compilation, graph, features, cont
117
117
  await Promise.all(allModules.map((module)=>appendModuleData(module, webpackGraph, graph, fileSystemInfo, features, context)));
118
118
  ModuleGraphTrans.removeNoImportStyle(graph);
119
119
  return graph;
120
- } catch (e) {
120
+ } catch {
121
121
  return graph;
122
122
  }
123
123
  }
@@ -0,0 +1,3 @@
1
+ export * from './loader';
2
+ export * from './plugin';
3
+ export * from './parseBundle';
@@ -139,7 +139,7 @@ var __webpack_exports__ = {};
139
139
  const newRule = {
140
140
  ...rule,
141
141
  use: (...args)=>{
142
- const rules = funcUse.apply(null, args);
142
+ const rules = funcUse(...args);
143
143
  return mapEachRules(rules, callback);
144
144
  }
145
145
  };
@@ -168,7 +168,7 @@ var __webpack_exports__ = {};
168
168
  });
169
169
  }
170
170
  function isESMLoader(r) {
171
- let _loaderName = 'object' == typeof r && 'string' == typeof r?.loader ? r.loader : 'string' == typeof r ? r : '';
171
+ const _loaderName = 'object' == typeof r && 'string' == typeof r?.loader ? r.loader : 'string' == typeof r ? r : '';
172
172
  if (!_loaderName) return false;
173
173
  const isPath = external_node_path_default().isAbsolute(_loaderName) || _loaderName.startsWith('./') || _loaderName.startsWith('../');
174
174
  if (isPath) {
@@ -302,8 +302,7 @@ var __webpack_exports__ = {};
302
302
  common_namespaceObject.Loader.LoaderInternalPropertyName
303
303
  ]) : Reflect.get(target, key, receiver);
304
304
  default:
305
- const _target = target;
306
- return _target[key];
305
+ return target[key];
307
306
  }
308
307
  },
309
308
  set (target, key, value, receiver) {
@@ -0,0 +1,20 @@
1
+ import type { Common, Plugin } from '@rsdoctor/types';
2
+ export declare function parsePathQueryFragment(str: string): {
3
+ path: string;
4
+ query: string;
5
+ fragment: string;
6
+ };
7
+ export declare function loadLoaderModule(loaderPath: string, cwd?: string): {
8
+ default: Plugin.LoaderDefinition<Common.PlainObject, {}>;
9
+ pitch: Plugin.PitchLoaderDefinitionFunction;
10
+ raw: boolean | void;
11
+ };
12
+ export declare function extractLoaderName(loaderPath: string, cwd?: string): string;
13
+ export declare function mapEachRules<T extends Plugin.BuildRuleSetRule>(rules: T[], callback: (rule: T) => T): T[];
14
+ export declare function isESMLoader(r: Plugin.BuildRuleSetRule): boolean;
15
+ export declare function getLoaderNameMatch(r: Plugin.BuildRuleSetRule, loaderName: string, strict?: boolean): boolean;
16
+ export declare function addProbeLoader2Rules<T extends Plugin.BuildRuleSetRule>(rules: T[], compiler: Plugin.BaseCompiler, fn: (r: Plugin.BuildRuleSetRule) => boolean): T[];
17
+ export declare function createLoaderContextTrap(this: Plugin.LoaderContext<Common.PlainObject>, final: (err: Error | null | undefined, res: string | Buffer | null, sourceMap?: Plugin.SourceMapInput) => void): Plugin.LoaderContext<Common.PlainObject<any>>;
18
+ export declare function parseQuery(query: string): {
19
+ [k: string]: string;
20
+ };
@@ -84,7 +84,7 @@ function mapEachRules(rules, callback) {
84
84
  const newRule = {
85
85
  ...rule,
86
86
  use: (...args)=>{
87
- const rules = funcUse.apply(null, args);
87
+ const rules = funcUse(...args);
88
88
  return mapEachRules(rules, callback);
89
89
  }
90
90
  };
@@ -113,7 +113,7 @@ function mapEachRules(rules, callback) {
113
113
  });
114
114
  }
115
115
  function isESMLoader(r) {
116
- let _loaderName = 'object' == typeof r && 'string' == typeof r?.loader ? r.loader : 'string' == typeof r ? r : '';
116
+ const _loaderName = 'object' == typeof r && 'string' == typeof r?.loader ? r.loader : 'string' == typeof r ? r : '';
117
117
  if (!_loaderName) return false;
118
118
  const isPath = node_path.isAbsolute(_loaderName) || _loaderName.startsWith('./') || _loaderName.startsWith('../');
119
119
  if (isPath) {
@@ -247,8 +247,7 @@ function createLoaderContextTrap(final) {
247
247
  Loader.LoaderInternalPropertyName
248
248
  ]) : Reflect.get(target, key, receiver);
249
249
  default:
250
- const _target = target;
251
- return _target[key];
250
+ return target[key];
252
251
  }
253
252
  },
254
253
  set (target, key, value, receiver) {
@@ -0,0 +1,12 @@
1
+ import type { ParseBundle } from '@rsdoctor/graph';
2
+ /**
3
+ * The following code is based on
4
+ * https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/44bd8d0f9aa3b098e271af220096ea70cc44bc9e/src/parseUtils.js#L10
5
+ *
6
+ *
7
+ * MIT Licensed
8
+ * Author th0r
9
+ * Copyright JS Foundation and other contributors.
10
+ * https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/44bd8d0f9aa3b098e271af220096ea70cc44bc9e/LICENSE
11
+ */
12
+ export declare const parseBundle: ParseBundle;
@@ -0,0 +1,5 @@
1
+ import { Plugin } from '@rsdoctor/types';
2
+ export type IHook = Plugin.BaseCompiler['hooks'][keyof Plugin.BaseCompiler['hooks']];
3
+ export declare function shouldInterceptPluginHook<T extends IHook>(hook: T): boolean;
4
+ export declare function interceptCompilerHooks(compiler: Plugin.BaseCompiler, interceptor: (name: string, hook: IHook, scope: 'compiler') => void): void;
5
+ export declare function interceptCompilationHooks(compilation: Plugin.BaseCompilation, interceptor: (name: string, hook: IHook, scope: 'compilation') => void): void;
@@ -0,0 +1 @@
1
+ export * as Build from './build';
@@ -0,0 +1,3 @@
1
+ export * from './build-utils';
2
+ export * as InnerPlugins from './inner-plugins';
3
+ export * from './types';
@@ -0,0 +1,6 @@
1
+ import type { Tap } from 'tapable';
2
+ export declare const pluginTapName = "RsdoctorWebpackPlugin";
3
+ export declare const pluginTapPostOptions: Tap;
4
+ export declare const pluginTapPreOptions: Tap;
5
+ export declare const internalPluginTapPreOptions: (namespace: string) => Tap;
6
+ export declare const internalPluginTapPostOptions: (namespace: string) => Tap;
@@ -0,0 +1,2 @@
1
+ export * from './plugins';
2
+ export * from './utils';
@@ -36,8 +36,11 @@ const loaderModule = function(...args) {
36
36
  const mod = (0, external_utils_index_cjs_namespaceObject.getOriginLoaderModule)(this);
37
37
  if (mod.default) {
38
38
  if (false === mod.raw && Buffer.isBuffer(args[0])) args[0] = args[0].toString();
39
- let start;
40
- let startHRTime;
39
+ let start = 0;
40
+ let startHRTime = [
41
+ 0,
42
+ 0
43
+ ];
41
44
  const trap = index_cjs_namespaceObject.Utils.createLoaderContextTrap.call(this, (err, res, sourceMap)=>{
42
45
  (0, external_utils_index_cjs_namespaceObject.reportLoader)(this, start, startHRTime, false, false, args[0].toString(), err, res, sourceMap);
43
46
  });
@@ -61,8 +64,11 @@ const pitch = function() {
61
64
  this.cacheable(false);
62
65
  const mod = (0, external_utils_index_cjs_namespaceObject.getOriginLoaderModule)(this);
63
66
  if (mod.pitch && 'function' == typeof mod.pitch) {
64
- let start;
65
- let startHRTime;
67
+ let start = 0;
68
+ let startHRTime = [
69
+ 0,
70
+ 0
71
+ ];
66
72
  const trap = index_cjs_namespaceObject.Utils.createLoaderContextTrap.call(this, (err, res)=>{
67
73
  (0, external_utils_index_cjs_namespaceObject.reportLoader)(this, start, startHRTime, true, false, err ? 'Loader Pitch Async Error' : '', err, res);
68
74
  });
@@ -0,0 +1,7 @@
1
+ import type { Plugin as PluginType } from '@rsdoctor/types';
2
+ import { Plugin } from '@rsdoctor/types';
3
+ import type { ProxyLoaderOptions } from '../../types';
4
+ declare const loaderModule: Plugin.LoaderDefinition<ProxyLoaderOptions, {}>;
5
+ export declare const pitch: (this: PluginType.LoaderContext<ProxyLoaderOptions>) => string | void | Buffer<ArrayBufferLike> | Promise<string | Buffer<ArrayBufferLike>>;
6
+ export declare const raw = true;
7
+ export default loaderModule;
@@ -7,8 +7,11 @@ const loaderModule = function(...args) {
7
7
  const mod = getOriginLoaderModule(this);
8
8
  if (mod.default) {
9
9
  if (false === mod.raw && Buffer.isBuffer(args[0])) args[0] = args[0].toString();
10
- let start;
11
- let startHRTime;
10
+ let start = 0;
11
+ let startHRTime = [
12
+ 0,
13
+ 0
14
+ ];
12
15
  const trap = Utils.createLoaderContextTrap.call(this, (err, res, sourceMap)=>{
13
16
  reportLoader(this, start, startHRTime, false, false, args[0].toString(), err, res, sourceMap);
14
17
  });
@@ -32,8 +35,11 @@ const pitch = function() {
32
35
  this.cacheable(false);
33
36
  const mod = getOriginLoaderModule(this);
34
37
  if (mod.pitch && 'function' == typeof mod.pitch) {
35
- let start;
36
- let startHRTime;
38
+ let start = 0;
39
+ let startHRTime = [
40
+ 0,
41
+ 0
42
+ ];
37
43
  const trap = Utils.createLoaderContextTrap.call(this, (err, res)=>{
38
44
  reportLoader(this, start, startHRTime, true, false, err ? 'Loader Pitch Async Error' : '', err, res);
39
45
  });
@@ -0,0 +1,12 @@
1
+ import type { Linter, Plugin, SDK } from '@rsdoctor/types';
2
+ import type { InternalPlugin, RsdoctorPluginInstance } from '../../types';
3
+ export declare abstract class InternalBasePlugin<T extends Plugin.BaseCompiler> implements InternalPlugin<T, Linter.ExtendRuleData[]> {
4
+ readonly scheduler: RsdoctorPluginInstance<T, Linter.ExtendRuleData[]>;
5
+ abstract name: string;
6
+ constructor(scheduler: RsdoctorPluginInstance<T, Linter.ExtendRuleData[]>);
7
+ abstract apply(compiler: T): void;
8
+ get options(): Plugin.RsdoctorPluginOptionsNormalized<Linter.ExtendRuleData<any, string>[]>;
9
+ get sdk(): SDK.RsdoctorBuilderSDKInstance;
10
+ get tapPostOptions(): import("tapable").Tap;
11
+ get tapPreOptions(): import("tapable").Tap;
12
+ }
@@ -0,0 +1,15 @@
1
+ import { Plugin } from '@rsdoctor/types';
2
+ import { InternalBasePlugin } from './base';
3
+ export declare class InternalBundlePlugin<T extends Plugin.BaseCompiler> extends InternalBasePlugin<T> {
4
+ readonly name = "bundle";
5
+ map: Map<string, {
6
+ content: string;
7
+ }>;
8
+ apply(compiler: T): void;
9
+ changeDevtoolModuleFilename(compiler: Plugin.BaseCompiler): void;
10
+ ensureAssetContent(name: string): {
11
+ content: string;
12
+ };
13
+ thisCompilation: (compilation: Plugin.BaseCompilation) => void;
14
+ done: () => Promise<void>;
15
+ }
@@ -52,13 +52,13 @@ class InternalBundleTagPlugin extends external_base_cjs_namespaceObject.Internal
52
52
  if (true === terserDropConsole || true === swcDropConsole) logger_namespaceObject.logger.warn(logger_namespaceObject.chalk.yellow('Warning: BannerPlugin detected in project. Please disable drop_console option in TerserPlugin or SwcJsMinimizerRspackPlugin to enable Rsdoctor analysis for BannerPlugin.'));
53
53
  }
54
54
  const chunks = compilation.chunks;
55
- for (let chunk of chunks)for (const file of chunk.files){
55
+ for (const chunk of chunks)for (const file of chunk.files){
56
56
  if (!file || '.js' !== (0, external_path_namespaceObject.extname)(file)) continue;
57
57
  const { ConcatSource } = compiler.webpack.sources;
58
58
  compilation.updateAsset(file, (old)=>{
59
59
  const concatSource = new ConcatSource();
60
- let header = "\n console.log('RSDOCTOR_START::');\n";
61
- let footer = "\n console.log('RSDOCTOR_END::');\n";
60
+ const header = "\n console.log('RSDOCTOR_START::');\n";
61
+ const footer = "\n console.log('RSDOCTOR_END::');\n";
62
62
  concatSource.add(header);
63
63
  concatSource.add(old);
64
64
  concatSource.add(footer);
@@ -0,0 +1,6 @@
1
+ import { Plugin } from '@rsdoctor/types';
2
+ import { InternalBasePlugin } from './base';
3
+ export declare class InternalBundleTagPlugin<T extends Plugin.BaseCompiler> extends InternalBasePlugin<T> {
4
+ readonly name = "bundleTag";
5
+ apply(compiler: Plugin.BaseCompiler): void;
6
+ }
@@ -25,13 +25,13 @@ class InternalBundleTagPlugin extends InternalBasePlugin {
25
25
  if (true === terserDropConsole || true === swcDropConsole) logger.warn(chalk.yellow('Warning: BannerPlugin detected in project. Please disable drop_console option in TerserPlugin or SwcJsMinimizerRspackPlugin to enable Rsdoctor analysis for BannerPlugin.'));
26
26
  }
27
27
  const chunks = compilation.chunks;
28
- for (let chunk of chunks)for (const file of chunk.files){
28
+ for (const chunk of chunks)for (const file of chunk.files){
29
29
  if (!file || '.js' !== extname(file)) continue;
30
30
  const { ConcatSource } = compiler.webpack.sources;
31
31
  compilation.updateAsset(file, (old)=>{
32
32
  const concatSource = new ConcatSource();
33
- let header = "\n console.log('RSDOCTOR_START::');\n";
34
- let footer = "\n console.log('RSDOCTOR_END::');\n";
33
+ const header = "\n console.log('RSDOCTOR_START::');\n";
34
+ const footer = "\n console.log('RSDOCTOR_END::');\n";
35
35
  concatSource.add(header);
36
36
  concatSource.add(old);
37
37
  concatSource.add(footer);
@@ -111,7 +111,7 @@ async function doneHandler(_stats, _this, context, compiler) {
111
111
  await getModulesInfos(compiler, _this.modulesGraph, _this.chunkGraph, shouldParseBundle, _this.sourceMapSets, _this.assetsWithoutSourceMap);
112
112
  logger_namespaceObject.logger.debug(`${build_namespaceObject.Process.getMemoryUsageMessage()}, '[After Transform ModuleGraph]'`);
113
113
  logger_namespaceObject.logger.debug('reportModuleGraph start');
114
- _this.modulesGraph && await _this.sdk.reportModuleGraph(_this.modulesGraph);
114
+ if (_this.modulesGraph) await _this.sdk.reportModuleGraph(_this.modulesGraph);
115
115
  logger_namespaceObject.logger.debug('reportModuleGraph done');
116
116
  logger_namespaceObject.logger.debug('reportChunkGraph start');
117
117
  await _this.sdk.reportChunkGraph(_this.chunkGraph);
@@ -122,7 +122,7 @@ async function doneHandler(_stats, _this, context, compiler) {
122
122
  const ensureDevtools = (compiler)=>{
123
123
  const devtool = compiler.options.devtool;
124
124
  if ('string' == typeof devtool && /eval/i.test(devtool)) {
125
- hasConsole || logger_namespaceObject.logger.warn('SourceMap with eval is not supported. Please use other sourcemap options.');
125
+ if (!hasConsole) logger_namespaceObject.logger.warn('SourceMap with eval is not supported. Please use other sourcemap options.');
126
126
  hasConsole = true;
127
127
  return false;
128
128
  }
@@ -138,7 +138,7 @@ async function getModulesInfos(compiler, moduleGraph, chunkGraph, parseBundle, s
138
138
  if (!moduleGraph) return;
139
139
  try {
140
140
  await index_cjs_namespaceObject.Chunks.getAssetsModulesData(moduleGraph, chunkGraph, compiler.outputPath, sourceMapSets, parseBundle, assetsWithoutSourceMap);
141
- } catch (e) {}
141
+ } catch {}
142
142
  }
143
143
  function escapeRegExp(str) {
144
144
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
@@ -0,0 +1,36 @@
1
+ import { RsdoctorPluginInstance } from '../../types';
2
+ import { Linter, Plugin } from '@rsdoctor/types';
3
+ /**
4
+ * Represents a mapping item from a source map.
5
+ */
6
+ export interface MappingItem {
7
+ source: string | null;
8
+ generatedLine: number;
9
+ generatedColumn: number;
10
+ originalLine: number | null;
11
+ originalColumn: number | null;
12
+ name: string | null;
13
+ }
14
+ /**
15
+ * Main function to generate ModuleGraph and ChunkGraph from stats and Webpack module APIs.
16
+ * Sets up hooks to process stats, generate graphs, handle tree shaking, and collect source maps.
17
+ * @param compiler - The Webpack or Rspack compiler instance.
18
+ * @param _this - The Rsdoctor plugin instance.
19
+ */
20
+ export declare const ensureModulesChunksGraphFn: (compiler: Plugin.BaseCompiler, _this: RsdoctorPluginInstance<Plugin.BaseCompiler, Linter.ExtendRuleData[]>) => void;
21
+ /**
22
+ * Checks if source map processing is enabled and supported by the current compiler configuration.
23
+ * Warns if eval-based source maps are used (unsupported).
24
+ * @param compiler - The Webpack or Rspack compiler instance.
25
+ * @returns true if source maps are enabled and supported, false otherwise.
26
+ */
27
+ export declare const ensureDevtools: (compiler: Plugin.BaseCompiler) => boolean;
28
+ /**
29
+ * Calculates namespace and source map filename regex for source map resolution.
30
+ * @param compiler - The Webpack or Rspack compiler instance.
31
+ * @returns An object containing namespace and sourceMapFilenameRegex.
32
+ */
33
+ export declare function calculateNamespaceAndRegex(compiler: Plugin.BaseCompiler): {
34
+ namespace: string;
35
+ sourceMapFilenameRegex: RegExp;
36
+ };
@@ -82,7 +82,7 @@ async function doneHandler(_stats, _this, context, compiler) {
82
82
  await getModulesInfos(compiler, _this.modulesGraph, _this.chunkGraph, shouldParseBundle, _this.sourceMapSets, _this.assetsWithoutSourceMap);
83
83
  logger.debug(`${Process.getMemoryUsageMessage()}, '[After Transform ModuleGraph]'`);
84
84
  logger.debug('reportModuleGraph start');
85
- _this.modulesGraph && await _this.sdk.reportModuleGraph(_this.modulesGraph);
85
+ if (_this.modulesGraph) await _this.sdk.reportModuleGraph(_this.modulesGraph);
86
86
  logger.debug('reportModuleGraph done');
87
87
  logger.debug('reportChunkGraph start');
88
88
  await _this.sdk.reportChunkGraph(_this.chunkGraph);
@@ -93,7 +93,7 @@ async function doneHandler(_stats, _this, context, compiler) {
93
93
  const ensureDevtools = (compiler)=>{
94
94
  const devtool = compiler.options.devtool;
95
95
  if ('string' == typeof devtool && /eval/i.test(devtool)) {
96
- hasConsole || logger.warn('SourceMap with eval is not supported. Please use other sourcemap options.');
96
+ if (!hasConsole) logger.warn('SourceMap with eval is not supported. Please use other sourcemap options.');
97
97
  hasConsole = true;
98
98
  return false;
99
99
  }
@@ -109,7 +109,7 @@ async function getModulesInfos(compiler, moduleGraph, chunkGraph, parseBundle, s
109
109
  if (!moduleGraph) return;
110
110
  try {
111
111
  await Chunks.getAssetsModulesData(moduleGraph, chunkGraph, compiler.outputPath, sourceMapSets, parseBundle, assetsWithoutSourceMap);
112
- } catch (e) {}
112
+ } catch {}
113
113
  }
114
114
  function escapeRegExp(str) {
115
115
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
@@ -0,0 +1,11 @@
1
+ import { Rule, Err, Plugin } from '@rsdoctor/types';
2
+ import { InternalBasePlugin } from './base';
3
+ import { DevToolError } from '@rsdoctor/utils/error';
4
+ export declare class InternalErrorReporterPlugin<T extends Plugin.BaseCompiler> extends InternalBasePlugin<T> {
5
+ readonly name = "error-reporter";
6
+ apply(compiler: T): void;
7
+ done: (stats: Plugin.BaseStats) => Promise<void>;
8
+ handleWebpackError(err: Plugin.BuildError, category: Rule.RuleMessageCategory, level: keyof typeof Err.ErrorLevel): DevToolError;
9
+ reportWarnings(warnings: Plugin.BuildError[]): Promise<void>;
10
+ reportErrors(errors: Plugin.BuildWarning[]): Promise<void>;
11
+ }
@@ -0,0 +1,11 @@
1
+ export * from './loader';
2
+ export * from './plugins';
3
+ export * from './errors';
4
+ export * from './progress';
5
+ export * from './summary';
6
+ export * from './base';
7
+ export * from './bundle';
8
+ export * from './ensureModulesChunkGraph';
9
+ export * from './rules';
10
+ export * from './bundleTagPlugin';
11
+ export * from './resolver';
@@ -0,0 +1,10 @@
1
+ import { Plugin } from '@rsdoctor/types';
2
+ import { InternalBasePlugin } from './base';
3
+ export declare class InternalLoaderPlugin<T extends Plugin.BaseCompiler> extends InternalBasePlugin<T> {
4
+ readonly name = "loader";
5
+ readonly internalLoaderPath: string;
6
+ apply(compiler: T): void;
7
+ afterPlugins: (compiler: T) => void;
8
+ compilation(compiler: T, compilation: Plugin.BaseCompilation): void;
9
+ getInterceptRules(compiler: T, rules: Plugin.BuildRuleSetRules): Plugin.BuildRuleSetRule[];
10
+ }
@@ -0,0 +1,8 @@
1
+ import { Plugin } from '@rsdoctor/types';
2
+ import { InternalBasePlugin } from './base';
3
+ export declare class InternalPluginsPlugin<T extends Plugin.BaseCompiler> extends InternalBasePlugin<T> {
4
+ readonly name = "plugins";
5
+ apply(compiler: Plugin.BaseCompiler): void;
6
+ afterPlugins: (compiler: Plugin.BaseCompiler) => void;
7
+ compilation: (compilation: Plugin.BaseCompilation) => void;
8
+ }
@@ -0,0 +1,8 @@
1
+ import { SDK } from '@rsdoctor/types';
2
+ import type { Plugin } from '@rsdoctor/types';
3
+ import { InternalBasePlugin } from './base';
4
+ export declare class InternalProgressPlugin<T extends Plugin.BaseCompilerType<'webpack'>> extends InternalBasePlugin<T> {
5
+ readonly name = "progress";
6
+ protected currentProgress: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.APIExtends.GetCompileProgress>;
7
+ apply(compiler: T): void;
8
+ }
@@ -0,0 +1,13 @@
1
+ import { Plugin } from '@rsdoctor/types';
2
+ import { InternalBasePlugin } from './base';
3
+ import type { Compiler as WebpackCompiler } from 'webpack';
4
+ export declare class InternalResolverPlugin<T extends Plugin.BaseCompiler> extends InternalBasePlugin<T> {
5
+ readonly name = "resolver";
6
+ protected resolveDataMap: Map<string, {
7
+ startAt: number;
8
+ startHRTime: [number, number];
9
+ request: string;
10
+ }>;
11
+ apply(compiler: T): void;
12
+ protected handleNormalModuleFactory: (normalModuleFactory: Plugin.RspackNormalModuleFactory | ReturnType<WebpackCompiler["createNormalModuleFactory"]>) => void;
13
+ }
@@ -0,0 +1,4 @@
1
+ import { Linter, Plugin } from '@rsdoctor/types';
2
+ import type { experiments } from '@rspack/core';
3
+ import { RsdoctorPluginInstance } from '../../types';
4
+ export declare function applyRspackNativePlugin(compiler: Plugin.BaseCompiler, plugin: RsdoctorPluginInstance<Plugin.BaseCompiler, Linter.ExtendRuleData[]>, RsdoctorRspackPlugin: typeof experiments.RsdoctorPlugin): void;
@@ -0,0 +1,8 @@
1
+ import { InternalBasePlugin } from './base';
2
+ import { Plugin } from '@rsdoctor/types';
3
+ export declare class InternalRulesPlugin extends InternalBasePlugin<Plugin.BaseCompiler> {
4
+ readonly name = "rules";
5
+ apply(compiler: Plugin.BaseCompiler): void;
6
+ done: (stats: Plugin.BaseStats) => Promise<void>;
7
+ protected lint(compilation: Plugin.BaseCompilation): Promise<void>;
8
+ }
@@ -137,8 +137,8 @@ async function handleAfterEmitAssets(compilation, _this, sourceMapFilenameRegex,
137
137
  sourceMapPath = (0, external_path_namespaceObject.resolve)(outputPath, mapFileName);
138
138
  }
139
139
  } else {
140
- let sourceMapFile = asset.info.related?.sourceMap;
141
- let sourceMapFileAssetName = sourceMapFile?.replace(/(\.[^.]+)(\.[^.]+)?$/, '$1');
140
+ const sourceMapFile = asset.info.related?.sourceMap;
141
+ const sourceMapFileAssetName = sourceMapFile?.replace(/(\.[^.]+)(\.[^.]+)?$/, '$1');
142
142
  if (sourceMapFile) {
143
143
  let sourceMapAsset = assets.find((asset)=>asset.name === sourceMapFile);
144
144
  if (!sourceMapAsset && sourceMapFileAssetName) {