@rsdoctor/types 1.5.3 → 1.5.4

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/index.cjs CHANGED
@@ -410,6 +410,22 @@ const E1006_message = {
410
410
  category: 'bundle',
411
411
  description: "\n#### Description\n\nWhen a module is included in both **initial chunks** and **async chunks**, the same module code is bundled into multiple chunks, increasing output size and potentially affecting first-screen load and cache efficiency.\n\n- **Initial chunks**: Chunks loaded with the main entry (e.g. entry points, synchronous `import` in the main bundle).\n- **Async chunks**: Chunks loaded on demand via dynamic `import()` or similar.\n\nIn the **Module Mixed Chunks** tab of Bundle Alerts, each entry shows the module path, **Initial Chunks** list, and **Async Chunks** list so you can locate duplicated modules.\n\n#### Common Causes\n\n- **Same module referenced in two ways**: The module is both synchronously imported in the main bundle or entry and dynamically `import()`ed elsewhere, so the bundler emits it in both initial and async chunks.\n- **A file is both an entry and an async chunk**: e.g. a utility module is configured as an entry and also `import()`ed in app code, so it appears in the entry's initial chunk and in a dynamically loaded async chunk.\n- **splitChunks overlapping with entry**: A path is split into an async chunk via `splitChunks` / `chunkSplit`, but that path is also an entry or a main-bundle dependency, leading to mixed chunk types.\n\n#### General Solution\n\n1. **Use a single import style**: Prefer one way to reference a module—either all synchronous imports (initial) or all dynamic `import()` (async). Avoid the same file being both synchronously imported in the main bundle and dynamically imported elsewhere.\n2. **Review entry vs dynamic loading**: If a file is both an entry and part of an async chunk, remove one of those usages or extract it into a single shared chunk via build config so both initial and async chunks reference it instead of duplicating it.\n3. **Adjust splitChunks**: Check rules for that module path in `optimization.splitChunks` (Rspack/Webpack) or `performance.chunkSplit` (Rsbuild), and avoid the same module being split into both initial and async chunks. Use `chunks: 'async'` or `chunks: 'initial'` where appropriate, or control which chunk type it goes into via `cacheGroups` and `test` / `chunks`.\n4. **Trace dependencies**: From the reported module path and chunk list, search the codebase for references to that module, distinguish sync vs dynamic imports, then converge to a single chunk type or extract a common chunk.\n"
412
412
  };
413
+ const E1007_code = 'E1007';
414
+ const E1007_message = {
415
+ code: E1007_code,
416
+ title: 'Tree Shaking Side Effects Only',
417
+ type: 'markdown',
418
+ category: 'bundle',
419
+ description: "\n#### Description\n\nThis rule detects modules that are pulled in and bundled solely due to side effects. This is often caused by unintended tree-shaking failures (e.g. missing or incorrect `\"sideEffects\"` field in `package.json`, or non-tree-shakeable import patterns), resulting in the entire module being bundled even though none of its exports are used.\n\n#### Common Causes\n\n- The package's `package.json` is missing `\"sideEffects\": false` (or incorrectly set to `true`), preventing the bundler from pruning unused exports.\n- An import statement like `import 'some-module'` or `import './styles.css'` is being treated as a side-effect-only import, but the intended use was to consume exports.\n- Barrel files (index files that re-export many things) cause the whole module to be kept alive when only a side-effect import is present.\n\n#### General Solution\n\n1. **Audit import statements**: Make sure you are actually importing and using named exports from this module. Replace bare side-effect imports with explicit named imports when you intend to use the module's exports.\n2. **Set `\"sideEffects\"` correctly**: In the module's `package.json`, set `\"sideEffects\": false` if the module has no global side effects, so the bundler can safely tree-shake unused exports.\n3. **Avoid unintended side-effect imports**: Remove or convert `import 'module'` patterns to explicit `import { foo } from 'module'` patterns where the exports are needed.\n"
420
+ };
421
+ const E1008_code = 'E1008';
422
+ const E1008_message = {
423
+ code: E1008_code,
424
+ title: 'CJS Require Cannot Tree-Shake',
425
+ type: 'markdown',
426
+ category: 'bundle',
427
+ description: "\n#### Description\n\nThis rule detects `require()` calls that use the **CJS Require** dependency type, which prevents tree-shaking of the required module. Unlike `require('module').property` (CJS Full Require), a bare `require('module')` call forces the entire module to be bundled because the bundler cannot statically determine which exports are used.\n\n#### Common Causes\n\n- Using `const mod = require('some-module')` instead of destructuring at the require site.\n- Dynamically accessing properties of the required module at runtime rather than statically.\n\n#### General Solution\n\n1. **Use destructured require**: Replace `const mod = require('A')` with `const { foo } = require('A')` (CJS Full Require) so the bundler can track which exports are used.\n2. **Migrate to ESM**: Use `import { foo } from 'A'` to enable full tree-shaking support.\n3. **Use require with property access**: Replace `const mod = require('A'); mod.foo()` with `const foo = require('A').foo` to allow partial tree-shaking.\n"
428
+ };
413
429
  var type_RuleMessageCodeEnumerated = /*#__PURE__*/ function(RuleMessageCodeEnumerated) {
414
430
  RuleMessageCodeEnumerated["Extend"] = "EXTEND";
415
431
  RuleMessageCodeEnumerated["Overlay"] = "OVERLAY";
@@ -427,7 +443,9 @@ const RuleErrorMap = {
427
443
  ["E1003"]: E1003_message,
428
444
  ["E1004"]: E1004_message,
429
445
  ["E1005"]: E1005_message,
430
- ["E1006"]: E1006_message
446
+ ["E1006"]: E1006_message,
447
+ ["E1007"]: E1007_message,
448
+ ["E1008"]: E1008_message
431
449
  };
432
450
  var code_RsdoctorRuleClientConstant = /*#__PURE__*/ function(RsdoctorRuleClientConstant) {
433
451
  RsdoctorRuleClientConstant["UrlQueryForErrorCode"] = "code";
package/dist/index.js CHANGED
@@ -1,80 +1,6 @@
1
- var __webpack_require__ = {};
2
- (()=>{
3
- __webpack_require__.d = (exports, definition)=>{
4
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
5
- enumerable: true,
6
- get: definition[key]
7
- });
8
- };
9
- })();
10
- (()=>{
11
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
12
- })();
13
- (()=>{
14
- __webpack_require__.r = (exports)=>{
15
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
16
- value: 'Module'
17
- });
18
- Object.defineProperty(exports, '__esModule', {
19
- value: true
20
- });
21
- };
22
- })();
23
- var manifest_namespaceObject = {};
24
- __webpack_require__.r(manifest_namespaceObject);
25
- __webpack_require__.d(manifest_namespaceObject, {
26
- RsdoctorManifestClientConstant: ()=>manifest_RsdoctorManifestClientConstant,
27
- RsdoctorManifestClientRoutes: ()=>manifest_RsdoctorManifestClientRoutes
28
- });
29
- var esbuild_namespaceObject = {};
30
- __webpack_require__.r(esbuild_namespaceObject);
1
+ import { __webpack_require__ } from "./rslib-runtime.js";
31
2
  var babel_namespaceObject = {};
32
3
  __webpack_require__.r(babel_namespaceObject);
33
- var common_namespaceObject = {};
34
- __webpack_require__.r(common_namespaceObject);
35
- var error_namespaceObject = {};
36
- __webpack_require__.r(error_namespaceObject);
37
- __webpack_require__.d(error_namespaceObject, {
38
- ErrorLevel: ()=>error_ErrorLevel
39
- });
40
- var logger_namespaceObject = {};
41
- __webpack_require__.r(logger_namespaceObject);
42
- __webpack_require__.d(logger_namespaceObject, {
43
- LogLevel: ()=>logger_LogLevel
44
- });
45
- var apis_namespaceObject = {};
46
- __webpack_require__.r(apis_namespaceObject);
47
- __webpack_require__.d(apis_namespaceObject, {
48
- API: ()=>apis_API,
49
- APIExtends: ()=>apis_APIExtends
50
- });
51
- var sdk_namespaceObject = {};
52
- __webpack_require__.r(sdk_namespaceObject);
53
- __webpack_require__.d(sdk_namespaceObject, {
54
- DependencyKind: ()=>module_DependencyKind,
55
- IMode: ()=>instance_IMode,
56
- ModuleKind: ()=>module_ModuleKind,
57
- ServerAPI: ()=>apis_namespaceObject,
58
- StatementKind: ()=>statement_StatementKind,
59
- ToDataType: ()=>module_ToDataType
60
- });
61
- var modules_namespaceObject = {};
62
- __webpack_require__.r(modules_namespaceObject);
63
- var linter_namespaceObject = {};
64
- __webpack_require__.r(linter_namespaceObject);
65
- __webpack_require__.d(linter_namespaceObject, {
66
- Severity: ()=>error_ErrorLevel
67
- });
68
- var src_rule_namespaceObject = {};
69
- __webpack_require__.r(src_rule_namespaceObject);
70
- __webpack_require__.d(src_rule_namespaceObject, {
71
- RsdoctorRuleClientConstant: ()=>code_RsdoctorRuleClientConstant,
72
- RuleErrorMap: ()=>RuleErrorMap,
73
- RuleMessageCategory: ()=>type_RuleMessageCategory,
74
- RuleMessageCodeEnumerated: ()=>type_RuleMessageCodeEnumerated
75
- });
76
- var thirdparty_namespaceObject = {};
77
- __webpack_require__.r(thirdparty_namespaceObject);
78
4
  var client_namespaceObject = {};
79
5
  __webpack_require__.r(client_namespaceObject);
80
6
  __webpack_require__.d(client_namespaceObject, {
@@ -82,6 +8,10 @@ __webpack_require__.d(client_namespaceObject, {
82
8
  RsdoctorClientRoutes: ()=>client_RsdoctorClientRoutes,
83
9
  RsdoctorClientUrlQuery: ()=>client_RsdoctorClientUrlQuery
84
10
  });
11
+ var common_namespaceObject = {};
12
+ __webpack_require__.r(common_namespaceObject);
13
+ var config_namespaceObject = {};
14
+ __webpack_require__.r(config_namespaceObject);
85
15
  var constants_namespaceObject = {};
86
16
  __webpack_require__.r(constants_namespaceObject);
87
17
  __webpack_require__.d(constants_namespaceObject, {
@@ -105,10 +35,59 @@ __webpack_require__.d(constants_namespaceObject, {
105
35
  StatsFilePath: ()=>StatsFilePath,
106
36
  WINDOW_RSDOCTOR_TAG: ()=>WINDOW_RSDOCTOR_TAG
107
37
  });
108
- var src_plugin_namespaceObject = {};
109
- __webpack_require__.r(src_plugin_namespaceObject);
110
- var src_config_namespaceObject = {};
111
- __webpack_require__.r(src_config_namespaceObject);
38
+ var error_namespaceObject = {};
39
+ __webpack_require__.r(error_namespaceObject);
40
+ __webpack_require__.d(error_namespaceObject, {
41
+ ErrorLevel: ()=>error_ErrorLevel
42
+ });
43
+ var esbuild_namespaceObject = {};
44
+ __webpack_require__.r(esbuild_namespaceObject);
45
+ var linter_namespaceObject = {};
46
+ __webpack_require__.r(linter_namespaceObject);
47
+ __webpack_require__.d(linter_namespaceObject, {
48
+ Severity: ()=>error_ErrorLevel
49
+ });
50
+ var logger_namespaceObject = {};
51
+ __webpack_require__.r(logger_namespaceObject);
52
+ __webpack_require__.d(logger_namespaceObject, {
53
+ LogLevel: ()=>logger_LogLevel
54
+ });
55
+ var manifest_namespaceObject = {};
56
+ __webpack_require__.r(manifest_namespaceObject);
57
+ __webpack_require__.d(manifest_namespaceObject, {
58
+ RsdoctorManifestClientConstant: ()=>manifest_RsdoctorManifestClientConstant,
59
+ RsdoctorManifestClientRoutes: ()=>manifest_RsdoctorManifestClientRoutes
60
+ });
61
+ var modules_namespaceObject = {};
62
+ __webpack_require__.r(modules_namespaceObject);
63
+ var plugin_namespaceObject = {};
64
+ __webpack_require__.r(plugin_namespaceObject);
65
+ var rule_namespaceObject = {};
66
+ __webpack_require__.r(rule_namespaceObject);
67
+ __webpack_require__.d(rule_namespaceObject, {
68
+ RsdoctorRuleClientConstant: ()=>code_RsdoctorRuleClientConstant,
69
+ RuleErrorMap: ()=>RuleErrorMap,
70
+ RuleMessageCategory: ()=>type_RuleMessageCategory,
71
+ RuleMessageCodeEnumerated: ()=>type_RuleMessageCodeEnumerated
72
+ });
73
+ var sdk_namespaceObject = {};
74
+ __webpack_require__.r(sdk_namespaceObject);
75
+ __webpack_require__.d(sdk_namespaceObject, {
76
+ DependencyKind: ()=>module_DependencyKind,
77
+ IMode: ()=>instance_IMode,
78
+ ModuleKind: ()=>module_ModuleKind,
79
+ ServerAPI: ()=>apis_namespaceObject,
80
+ StatementKind: ()=>statement_StatementKind,
81
+ ToDataType: ()=>module_ToDataType
82
+ });
83
+ var apis_namespaceObject = {};
84
+ __webpack_require__.r(apis_namespaceObject);
85
+ __webpack_require__.d(apis_namespaceObject, {
86
+ API: ()=>apis_API,
87
+ APIExtends: ()=>apis_APIExtends
88
+ });
89
+ var thirdparty_namespaceObject = {};
90
+ __webpack_require__.r(thirdparty_namespaceObject);
112
91
  var manifest_RsdoctorManifestClientRoutes = /*#__PURE__*/ function(RsdoctorManifestClientRoutes) {
113
92
  RsdoctorManifestClientRoutes["Overall"] = "Overall";
114
93
  RsdoctorManifestClientRoutes["WebpackLoaders"] = "Compile.WebpackLoaders";
@@ -244,7 +223,7 @@ var instance_IMode = /*#__PURE__*/ function(IMode) {
244
223
  }({});
245
224
  const code = 'E1001';
246
225
  const message = {
247
- code,
226
+ code: code,
248
227
  title: 'Duplicate Packages',
249
228
  type: 'markdown',
250
229
  category: 'bundle',
@@ -390,6 +369,22 @@ const E1006_message = {
390
369
  category: 'bundle',
391
370
  description: "\n#### Description\n\nWhen a module is included in both **initial chunks** and **async chunks**, the same module code is bundled into multiple chunks, increasing output size and potentially affecting first-screen load and cache efficiency.\n\n- **Initial chunks**: Chunks loaded with the main entry (e.g. entry points, synchronous `import` in the main bundle).\n- **Async chunks**: Chunks loaded on demand via dynamic `import()` or similar.\n\nIn the **Module Mixed Chunks** tab of Bundle Alerts, each entry shows the module path, **Initial Chunks** list, and **Async Chunks** list so you can locate duplicated modules.\n\n#### Common Causes\n\n- **Same module referenced in two ways**: The module is both synchronously imported in the main bundle or entry and dynamically `import()`ed elsewhere, so the bundler emits it in both initial and async chunks.\n- **A file is both an entry and an async chunk**: e.g. a utility module is configured as an entry and also `import()`ed in app code, so it appears in the entry's initial chunk and in a dynamically loaded async chunk.\n- **splitChunks overlapping with entry**: A path is split into an async chunk via `splitChunks` / `chunkSplit`, but that path is also an entry or a main-bundle dependency, leading to mixed chunk types.\n\n#### General Solution\n\n1. **Use a single import style**: Prefer one way to reference a module—either all synchronous imports (initial) or all dynamic `import()` (async). Avoid the same file being both synchronously imported in the main bundle and dynamically imported elsewhere.\n2. **Review entry vs dynamic loading**: If a file is both an entry and part of an async chunk, remove one of those usages or extract it into a single shared chunk via build config so both initial and async chunks reference it instead of duplicating it.\n3. **Adjust splitChunks**: Check rules for that module path in `optimization.splitChunks` (Rspack/Webpack) or `performance.chunkSplit` (Rsbuild), and avoid the same module being split into both initial and async chunks. Use `chunks: 'async'` or `chunks: 'initial'` where appropriate, or control which chunk type it goes into via `cacheGroups` and `test` / `chunks`.\n4. **Trace dependencies**: From the reported module path and chunk list, search the codebase for references to that module, distinguish sync vs dynamic imports, then converge to a single chunk type or extract a common chunk.\n"
392
371
  };
372
+ const E1007_code = 'E1007';
373
+ const E1007_message = {
374
+ code: E1007_code,
375
+ title: 'Tree Shaking Side Effects Only',
376
+ type: 'markdown',
377
+ category: 'bundle',
378
+ description: "\n#### Description\n\nThis rule detects modules that are pulled in and bundled solely due to side effects. This is often caused by unintended tree-shaking failures (e.g. missing or incorrect `\"sideEffects\"` field in `package.json`, or non-tree-shakeable import patterns), resulting in the entire module being bundled even though none of its exports are used.\n\n#### Common Causes\n\n- The package's `package.json` is missing `\"sideEffects\": false` (or incorrectly set to `true`), preventing the bundler from pruning unused exports.\n- An import statement like `import 'some-module'` or `import './styles.css'` is being treated as a side-effect-only import, but the intended use was to consume exports.\n- Barrel files (index files that re-export many things) cause the whole module to be kept alive when only a side-effect import is present.\n\n#### General Solution\n\n1. **Audit import statements**: Make sure you are actually importing and using named exports from this module. Replace bare side-effect imports with explicit named imports when you intend to use the module's exports.\n2. **Set `\"sideEffects\"` correctly**: In the module's `package.json`, set `\"sideEffects\": false` if the module has no global side effects, so the bundler can safely tree-shake unused exports.\n3. **Avoid unintended side-effect imports**: Remove or convert `import 'module'` patterns to explicit `import { foo } from 'module'` patterns where the exports are needed.\n"
379
+ };
380
+ const E1008_code = 'E1008';
381
+ const E1008_message = {
382
+ code: E1008_code,
383
+ title: 'CJS Require Cannot Tree-Shake',
384
+ type: 'markdown',
385
+ category: 'bundle',
386
+ description: "\n#### Description\n\nThis rule detects `require()` calls that use the **CJS Require** dependency type, which prevents tree-shaking of the required module. Unlike `require('module').property` (CJS Full Require), a bare `require('module')` call forces the entire module to be bundled because the bundler cannot statically determine which exports are used.\n\n#### Common Causes\n\n- Using `const mod = require('some-module')` instead of destructuring at the require site.\n- Dynamically accessing properties of the required module at runtime rather than statically.\n\n#### General Solution\n\n1. **Use destructured require**: Replace `const mod = require('A')` with `const { foo } = require('A')` (CJS Full Require) so the bundler can track which exports are used.\n2. **Migrate to ESM**: Use `import { foo } from 'A'` to enable full tree-shaking support.\n3. **Use require with property access**: Replace `const mod = require('A'); mod.foo()` with `const foo = require('A').foo` to allow partial tree-shaking.\n"
387
+ };
393
388
  var type_RuleMessageCodeEnumerated = /*#__PURE__*/ function(RuleMessageCodeEnumerated) {
394
389
  RuleMessageCodeEnumerated["Extend"] = "EXTEND";
395
390
  RuleMessageCodeEnumerated["Overlay"] = "OVERLAY";
@@ -407,7 +402,9 @@ const RuleErrorMap = {
407
402
  ["E1003"]: E1003_message,
408
403
  ["E1004"]: E1004_message,
409
404
  ["E1005"]: E1005_message,
410
- ["E1006"]: E1006_message
405
+ ["E1006"]: E1006_message,
406
+ ["E1007"]: E1007_message,
407
+ ["E1008"]: E1008_message
411
408
  };
412
409
  var code_RsdoctorRuleClientConstant = /*#__PURE__*/ function(RsdoctorRuleClientConstant) {
413
410
  RsdoctorRuleClientConstant["UrlQueryForErrorCode"] = "code";
@@ -492,4 +489,4 @@ const RsdoctorMonitorDocBId = 'Rsdoctor-Doc';
492
489
  const RsdoctorProcessEnvDebugKey = 'rsdoctor';
493
490
  const RsdoctorClientUrl = '';
494
491
  const WINDOW_RSDOCTOR_TAG = '__RSDOCTOR__';
495
- export { babel_namespaceObject as Babel, client_namespaceObject as Client, common_namespaceObject as Common, src_config_namespaceObject as Config, constants_namespaceObject as Constants, error_namespaceObject as Err, esbuild_namespaceObject as Esbuild, linter_namespaceObject as Linter, logger_namespaceObject as Logger, manifest_namespaceObject as Manifest, modules_namespaceObject as Modules, src_plugin_namespaceObject as Plugin, src_rule_namespaceObject as Rule, sdk_namespaceObject as SDK, thirdparty_namespaceObject as Thirdparty };
492
+ export { babel_namespaceObject as Babel, client_namespaceObject as Client, common_namespaceObject as Common, config_namespaceObject as Config, constants_namespaceObject as Constants, error_namespaceObject as Err, esbuild_namespaceObject as Esbuild, linter_namespaceObject as Linter, logger_namespaceObject as Logger, manifest_namespaceObject as Manifest, modules_namespaceObject as Modules, plugin_namespaceObject as Plugin, rule_namespaceObject as Rule, sdk_namespaceObject as SDK, thirdparty_namespaceObject as Thirdparty };
@@ -1,4 +1,4 @@
1
1
  import { Linter } from '../index';
2
2
  export type InternalRules = Linter.RuleData[];
3
- export type InternalRuleId = 'E1001' | 'E1002' | 'E1003' | 'E1004' | 'E1005' | 'E1006';
4
- export type InternalRuleName = 'duplicate-package' | 'cross-chunks-package' | 'default-import-check' | 'ecma-version-check' | 'loader-performance-optimization' | 'module-mixed-chunks';
3
+ export type InternalRuleId = 'E1001' | 'E1002' | 'E1003' | 'E1004' | 'E1005' | 'E1006' | 'E1007';
4
+ export type InternalRuleName = 'duplicate-package' | 'cross-chunks-package' | 'default-import-check' | 'ecma-version-check' | 'loader-performance-optimization' | 'module-mixed-chunks' | 'tree-shaking-side-effects-only';
@@ -0,0 +1,37 @@
1
+ var __webpack_module_cache__ = {};
2
+ function __webpack_require__(moduleId) {
3
+ var cachedModule = __webpack_module_cache__[moduleId];
4
+ if (void 0 !== cachedModule) return cachedModule.exports;
5
+ var module = __webpack_module_cache__[moduleId] = {
6
+ exports: {}
7
+ };
8
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
9
+ return module.exports;
10
+ }
11
+ (()=>{
12
+ __webpack_require__.d = (exports, definition)=>{
13
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
14
+ enumerable: true,
15
+ get: definition[key]
16
+ });
17
+ };
18
+ })();
19
+ (()=>{
20
+ __webpack_require__.add = function(modules) {
21
+ Object.assign(__webpack_require__.m, modules);
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.r = (exports)=>{
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
30
+ value: 'Module'
31
+ });
32
+ Object.defineProperty(exports, '__esModule', {
33
+ value: true
34
+ });
35
+ };
36
+ })();
37
+ export { __webpack_require__ };
@@ -0,0 +1,3 @@
1
+ import { RuleMessage } from './type';
2
+ export declare const code = "E1007";
3
+ export declare const message: RuleMessage;
@@ -0,0 +1,3 @@
1
+ import { RuleMessage } from './type';
2
+ export declare const code = "E1008";
3
+ export declare const message: RuleMessage;
@@ -5,6 +5,8 @@ import * as E1003 from './E1003';
5
5
  import * as E1004 from './E1004';
6
6
  import * as E1005 from './E1005';
7
7
  import * as E1006 from './E1006';
8
+ import * as E1007 from './E1007';
9
+ import * as E1008 from './E1008';
8
10
  export type RuleErrorCodes = {
9
11
  [E1001.code]: typeof E1001;
10
12
  [E1002.code]: typeof E1002;
@@ -12,6 +14,8 @@ export type RuleErrorCodes = {
12
14
  [E1004.code]: typeof E1004;
13
15
  [E1005.code]: typeof E1005;
14
16
  [E1006.code]: typeof E1006;
17
+ [E1007.code]: typeof E1007;
18
+ [E1008.code]: typeof E1008;
15
19
  };
16
20
  /**
17
21
  * The format is E + "4 digits".
@@ -149,5 +149,43 @@ export interface ModuleMixedChunksRuleStoreData extends BaseRuleStoreData {
149
149
  name: string;
150
150
  }>;
151
151
  }
152
- export type RuleStoreDataItem = LinkRuleStoreData | FileRelationRuleStoreData | CodeChangeRuleStoreData | PackageRelationDiffRuleStoreData | CodeViewRuleStoreData | CrossChunksPackageRuleStoreData | ModuleMixedChunksRuleStoreData;
152
+ /**
153
+ * Rule for detecting modules that are only imported for their side effects,
154
+ * which may indicate unintended tree-shaking failures.
155
+ */
156
+ export interface ConnectionsOnlyImportsRuleStoreData extends BaseRuleStoreData {
157
+ type: 'tree-shaking-side-effects-only';
158
+ module: {
159
+ id: number | string;
160
+ path: string;
161
+ webpackId?: string | number;
162
+ };
163
+ connections: Array<{
164
+ originModule: number;
165
+ dependencyType: string;
166
+ userRequest: string;
167
+ }>;
168
+ }
169
+ /**
170
+ * Rule for detecting modules imported via CJS require (bare require() call),
171
+ * which prevents tree-shaking of the required module.
172
+ */
173
+ export interface CjsRequireRuleStoreData extends BaseRuleStoreData {
174
+ type: 'cjs-require';
175
+ /** The module that contains the require() call */
176
+ issuerModule: {
177
+ id: number | string;
178
+ path: string;
179
+ webpackId?: string | number;
180
+ };
181
+ /** The module being required */
182
+ requiredModule: {
183
+ id: number | string;
184
+ path: string;
185
+ webpackId?: string | number;
186
+ };
187
+ /** The original require string (e.g. 'lodash') */
188
+ request: string;
189
+ }
190
+ export type RuleStoreDataItem = LinkRuleStoreData | FileRelationRuleStoreData | CodeChangeRuleStoreData | PackageRelationDiffRuleStoreData | CodeViewRuleStoreData | CrossChunksPackageRuleStoreData | ModuleMixedChunksRuleStoreData | ConnectionsOnlyImportsRuleStoreData | CjsRequireRuleStoreData;
153
191
  export type RuleStoreData = RuleStoreDataItem[];
@@ -32,6 +32,16 @@ export interface SideEffectLocationData {
32
32
  module: number;
33
33
  request: string;
34
34
  }
35
+ /** Pre-computed side-effects-only import result (from Rust analysis) */
36
+ export interface ConnectionsOnlyImportData {
37
+ moduleUkey: number;
38
+ modulePath: string;
39
+ connections: Array<{
40
+ originModule?: number;
41
+ dependencyType: string;
42
+ userRequest: string;
43
+ }>;
44
+ }
35
45
  /** Side effect code snippet data */
36
46
  export interface SideEffectCodeData {
37
47
  /** Module ID */
@@ -239,6 +249,10 @@ export interface DependencyInstance {
239
249
  * - string enumeration
240
250
  */
241
251
  readonly kindString: keyof typeof DependencyKind;
252
+ /**
253
+ * Original dependency type string from the bundler (e.g. 'cjs require', 'cjs full require', 'esm import')
254
+ */
255
+ typeString?: string;
242
256
  /** Whether to connect to the aggregation module */
243
257
  readonly resolveConcatenationModule: boolean;
244
258
  /** quote statement */
@@ -320,6 +334,8 @@ export interface ModuleGraphInstance {
320
334
  toCodeData(type?: ToDataType): ModuleCodeData;
321
335
  setModules(modules: ModuleInstance[]): void;
322
336
  setDependencies(dependencies: DependencyInstance[]): void;
337
+ setConnectionsOnlyImports(items: ConnectionsOnlyImportData[]): void;
338
+ getConnectionsOnlyImports(): ConnectionsOnlyImportData[];
323
339
  }
324
340
  export interface ModuleData extends Omit<NonFunctionProperties<ModuleInstance>, 'rootModule' | 'isEntry' | 'concatenationModules' | 'meta' | 'issuerPath'> {
325
341
  /** chunk identifier */
@@ -365,6 +381,18 @@ export interface DependencyData extends Omit<NonFunctionProperties<DependencyIns
365
381
  /** quote statement */
366
382
  statements: StatementData[];
367
383
  }
384
+ /** Module connection data from rspack module graph */
385
+ export interface ConnectionData {
386
+ ukey: number;
387
+ dependencyId: string;
388
+ module: number;
389
+ originModule?: number;
390
+ resolvedModule: number;
391
+ dependencyType: string;
392
+ userRequest: string;
393
+ loc?: string;
394
+ active: boolean;
395
+ }
368
396
  export interface ModuleGraphData {
369
397
  dependencies: DependencyData[];
370
398
  modules: ModuleData[];
@@ -373,4 +401,5 @@ export interface ModuleGraphData {
373
401
  sideEffects: SideEffectData[];
374
402
  variables: VariableData[];
375
403
  layers?: string[];
404
+ connections?: ConnectionData[];
376
405
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/types",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -23,11 +23,11 @@
23
23
  "dependencies": {
24
24
  "@types/connect": "3.4.38",
25
25
  "@types/estree": "1.0.5",
26
- "@types/tapable": "2.2.7",
26
+ "@types/tapable": "2.3.0",
27
27
  "source-map": "^0.7.6"
28
28
  },
29
29
  "devDependencies": {
30
- "@rspack/core": "2.0.0-beta.5",
30
+ "@rspack/core": "2.0.0-canary-20260116",
31
31
  "@types/node": "^22.8.1",
32
32
  "@types/react": "^18.3.28",
33
33
  "tslib": "2.8.1",