@rsdoctor/types 1.5.1 → 1.5.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/constants.d.ts +2 -0
- package/dist/constants.js +3 -1
- package/dist/plugin/internal-rules.d.ts +2 -2
- package/dist/rule/code/E1006.d.ts +3 -0
- package/dist/rule/code/E1006.js +33 -0
- package/dist/rule/code/index.d.ts +2 -0
- package/dist/rule/code/index.js +2 -0
- package/dist/rule/data.d.ts +20 -1
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare const JSExtension = ".js";
|
|
2
|
+
export declare const BundleExtension = ".bundle";
|
|
3
|
+
export declare const JSExtensions: string[];
|
|
2
4
|
export declare const CSSExtension = ".css";
|
|
3
5
|
export declare const HtmlExtension = ".html";
|
|
4
6
|
export declare const ImgExtensions: string[];
|
package/dist/constants.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WINDOW_RSDOCTOR_TAG = exports.RsdoctorClientUrl = exports.RsdoctorProcessEnvDebugKey = exports.RsdoctorMonitorDocBId = exports.RsdoctorMonitorWebBId = exports.RsdoctorMonitorNodeBId = exports.StatsFilePath = exports.RsdoctorOutputManifestPath = exports.RsdoctorOutputManifest = exports.RsdoctorOutputFolder = exports.MapExtensions = exports.FontExtensions = exports.MediaExtensions = exports.ImgExtensions = exports.HtmlExtension = exports.CSSExtension = exports.JSExtension = void 0;
|
|
3
|
+
exports.WINDOW_RSDOCTOR_TAG = exports.RsdoctorClientUrl = exports.RsdoctorProcessEnvDebugKey = exports.RsdoctorMonitorDocBId = exports.RsdoctorMonitorWebBId = exports.RsdoctorMonitorNodeBId = exports.StatsFilePath = exports.RsdoctorOutputManifestPath = exports.RsdoctorOutputManifest = exports.RsdoctorOutputFolder = exports.MapExtensions = exports.FontExtensions = exports.MediaExtensions = exports.ImgExtensions = exports.HtmlExtension = exports.CSSExtension = exports.JSExtensions = exports.BundleExtension = exports.JSExtension = void 0;
|
|
4
4
|
exports.JSExtension = '.js';
|
|
5
|
+
exports.BundleExtension = '.bundle';
|
|
6
|
+
exports.JSExtensions = [exports.JSExtension, exports.BundleExtension];
|
|
5
7
|
exports.CSSExtension = '.css';
|
|
6
8
|
exports.HtmlExtension = '.html';
|
|
7
9
|
exports.ImgExtensions = [
|
|
@@ -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';
|
|
4
|
-
export type InternalRuleName = 'duplicate-package' | 'cross-chunks-package' | 'default-import-check' | 'ecma-version-check' | 'loader-performance-optimization';
|
|
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';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.message = exports.code = void 0;
|
|
4
|
+
exports.code = 'E1006';
|
|
5
|
+
exports.message = {
|
|
6
|
+
code: exports.code,
|
|
7
|
+
title: 'Module Mixed Chunks',
|
|
8
|
+
type: 'markdown',
|
|
9
|
+
category: 'bundle',
|
|
10
|
+
description: `
|
|
11
|
+
#### Description
|
|
12
|
+
|
|
13
|
+
When 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.
|
|
14
|
+
|
|
15
|
+
- **Initial chunks**: Chunks loaded with the main entry (e.g. entry points, synchronous \`import\` in the main bundle).
|
|
16
|
+
- **Async chunks**: Chunks loaded on demand via dynamic \`import()\` or similar.
|
|
17
|
+
|
|
18
|
+
In 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.
|
|
19
|
+
|
|
20
|
+
#### Common Causes
|
|
21
|
+
|
|
22
|
+
- **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.
|
|
23
|
+
- **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.
|
|
24
|
+
- **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.
|
|
25
|
+
|
|
26
|
+
#### General Solution
|
|
27
|
+
|
|
28
|
+
1. **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.
|
|
29
|
+
2. **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.
|
|
30
|
+
3. **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\`.
|
|
31
|
+
4. **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.
|
|
32
|
+
`,
|
|
33
|
+
};
|
|
@@ -4,12 +4,14 @@ import * as E1002 from './E1002';
|
|
|
4
4
|
import * as E1003 from './E1003';
|
|
5
5
|
import * as E1004 from './E1004';
|
|
6
6
|
import * as E1005 from './E1005';
|
|
7
|
+
import * as E1006 from './E1006';
|
|
7
8
|
export type RuleErrorCodes = {
|
|
8
9
|
[E1001.code]: typeof E1001;
|
|
9
10
|
[E1002.code]: typeof E1002;
|
|
10
11
|
[E1003.code]: typeof E1003;
|
|
11
12
|
[E1004.code]: typeof E1004;
|
|
12
13
|
[E1005.code]: typeof E1005;
|
|
14
|
+
[E1006.code]: typeof E1006;
|
|
13
15
|
};
|
|
14
16
|
/**
|
|
15
17
|
* The format is E + "4 digits".
|
package/dist/rule/code/index.js
CHANGED
|
@@ -42,6 +42,7 @@ const E1002 = __importStar(require("./E1002"));
|
|
|
42
42
|
const E1003 = __importStar(require("./E1003"));
|
|
43
43
|
const E1004 = __importStar(require("./E1004"));
|
|
44
44
|
const E1005 = __importStar(require("./E1005"));
|
|
45
|
+
const E1006 = __importStar(require("./E1006"));
|
|
45
46
|
/**
|
|
46
47
|
* The format is E + "4 digits".
|
|
47
48
|
* - The first number represents the category:
|
|
@@ -55,6 +56,7 @@ exports.RuleErrorMap = {
|
|
|
55
56
|
[E1003.code]: E1003.message,
|
|
56
57
|
[E1004.code]: E1004.message,
|
|
57
58
|
[E1005.code]: E1005.message,
|
|
59
|
+
[E1006.code]: E1006.message,
|
|
58
60
|
};
|
|
59
61
|
var RsdoctorRuleClientConstant;
|
|
60
62
|
(function (RsdoctorRuleClientConstant) {
|
package/dist/rule/data.d.ts
CHANGED
|
@@ -130,5 +130,24 @@ export interface OverlayRuleStoreData extends BaseRuleStoreData {
|
|
|
130
130
|
code: RuleMessageCodeEnumerated.Overlay;
|
|
131
131
|
stack?: string;
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Rule for detecting modules that are included in both initial and async chunks.
|
|
135
|
+
*/
|
|
136
|
+
export interface ModuleMixedChunksRuleStoreData extends BaseRuleStoreData {
|
|
137
|
+
type: 'module-mixed-chunks';
|
|
138
|
+
module: {
|
|
139
|
+
id: number | string;
|
|
140
|
+
path: string;
|
|
141
|
+
webpackId?: string | number;
|
|
142
|
+
};
|
|
143
|
+
initialChunks: Array<{
|
|
144
|
+
id: string;
|
|
145
|
+
name: string;
|
|
146
|
+
}>;
|
|
147
|
+
asyncChunks: Array<{
|
|
148
|
+
id: string;
|
|
149
|
+
name: string;
|
|
150
|
+
}>;
|
|
151
|
+
}
|
|
152
|
+
export type RuleStoreDataItem = LinkRuleStoreData | FileRelationRuleStoreData | CodeChangeRuleStoreData | PackageRelationDiffRuleStoreData | CodeViewRuleStoreData | CrossChunksPackageRuleStoreData | ModuleMixedChunksRuleStoreData;
|
|
134
153
|
export type RuleStoreData = RuleStoreDataItem[];
|