@rsdoctor/core 1.6.1 → 1.6.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/build-utils/build/chunks/assetsModules.cjs +8 -4
- package/dist/build-utils/build/chunks/assetsModules.d.cts +7 -1
- package/dist/build-utils/build/chunks/assetsModules.d.ts +7 -1
- package/dist/build-utils/build/chunks/assetsModules.js +8 -4
- package/dist/inner-plugins/plugins/bundle.cjs +1 -1
- package/dist/inner-plugins/plugins/bundle.js +1 -1
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +9 -3
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +9 -3
- package/dist/inner-plugins/utils/config.cjs +16 -3
- package/dist/inner-plugins/utils/config.js +16 -3
- package/package.json +5 -5
|
@@ -32,10 +32,14 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
32
32
|
});
|
|
33
33
|
const graph_namespaceObject = require("@rsdoctor/graph");
|
|
34
34
|
const index_cjs_namespaceObject = require("../utils/index.cjs");
|
|
35
|
-
async function getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, sourceMapSets, hasParseBundle = true, assetsWithoutSourceMap) {
|
|
36
|
-
return graph_namespaceObject.Chunks.getAssetsModulesData(moduleGraph, chunkGraph, bundleDir,
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
async function getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, sourceMapSets, hasParseBundle = true, assetsWithoutSourceMap, gzipOptions) {
|
|
36
|
+
return graph_namespaceObject.Chunks.getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, {
|
|
37
|
+
...hasParseBundle ? {
|
|
38
|
+
parseBundle: index_cjs_namespaceObject.parseBundle
|
|
39
|
+
} : {},
|
|
40
|
+
gzip: gzipOptions?.enabled,
|
|
41
|
+
gzipLevel: gzipOptions?.enabled ? gzipOptions.level : void 0
|
|
42
|
+
}, sourceMapSets, assetsWithoutSourceMap);
|
|
39
43
|
}
|
|
40
44
|
exports.getAssetsModulesData = __webpack_exports__.getAssetsModulesData;
|
|
41
45
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
export type GzipOptions = {
|
|
3
|
+
enabled: false;
|
|
4
|
+
} | {
|
|
5
|
+
enabled: true;
|
|
6
|
+
level: number;
|
|
7
|
+
};
|
|
2
8
|
/**
|
|
3
9
|
* Collects module size data from bundle assets, using source maps when available
|
|
4
10
|
* and falling back to AST parsing for assets without source maps.
|
|
@@ -14,4 +20,4 @@ import { SDK } from '@rsdoctor/types';
|
|
|
14
20
|
* If not provided and no source maps exist (sourceMapSets is empty), all assets will be parsed via AST.
|
|
15
21
|
* @returns Promise that resolves when module data collection is complete
|
|
16
22
|
*/
|
|
17
|
-
export declare function getAssetsModulesData(moduleGraph: SDK.ModuleGraphInstance, chunkGraph: SDK.ChunkGraphInstance, bundleDir: string, sourceMapSets: Map<string, string>, hasParseBundle?: boolean, assetsWithoutSourceMap?: Set<string
|
|
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>;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
export type GzipOptions = {
|
|
3
|
+
enabled: false;
|
|
4
|
+
} | {
|
|
5
|
+
enabled: true;
|
|
6
|
+
level: number;
|
|
7
|
+
};
|
|
2
8
|
/**
|
|
3
9
|
* Collects module size data from bundle assets, using source maps when available
|
|
4
10
|
* and falling back to AST parsing for assets without source maps.
|
|
@@ -14,4 +20,4 @@ import { SDK } from '@rsdoctor/types';
|
|
|
14
20
|
* If not provided and no source maps exist (sourceMapSets is empty), all assets will be parsed via AST.
|
|
15
21
|
* @returns Promise that resolves when module data collection is complete
|
|
16
22
|
*/
|
|
17
|
-
export declare function getAssetsModulesData(moduleGraph: SDK.ModuleGraphInstance, chunkGraph: SDK.ChunkGraphInstance, bundleDir: string, sourceMapSets: Map<string, string>, hasParseBundle?: boolean, assetsWithoutSourceMap?: Set<string
|
|
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>;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { Chunks } from "@rsdoctor/graph";
|
|
3
3
|
import { parseBundle } from "../utils/index.js";
|
|
4
|
-
async function getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, sourceMapSets, hasParseBundle = true, assetsWithoutSourceMap) {
|
|
5
|
-
return Chunks.getAssetsModulesData(moduleGraph, chunkGraph, bundleDir,
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
async function getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, sourceMapSets, hasParseBundle = true, assetsWithoutSourceMap, gzipOptions) {
|
|
5
|
+
return Chunks.getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, {
|
|
6
|
+
...hasParseBundle ? {
|
|
7
|
+
parseBundle: parseBundle
|
|
8
|
+
} : {},
|
|
9
|
+
gzip: gzipOptions?.enabled,
|
|
10
|
+
gzipLevel: gzipOptions?.enabled ? gzipOptions.level : void 0
|
|
11
|
+
}, sourceMapSets, assetsWithoutSourceMap);
|
|
8
12
|
}
|
|
9
13
|
export { getAssetsModulesData };
|
|
@@ -96,7 +96,7 @@ class InternalBundlePlugin extends external_base_cjs_namespaceObject.InternalBas
|
|
|
96
96
|
}, this.done = async ()=>{
|
|
97
97
|
(0, logger_namespaceObject.time)('InternalBundlePlugin.done');
|
|
98
98
|
try {
|
|
99
|
-
if (this.scheduler.chunkGraph) graph_namespaceObject.Chunks.assetsContents(this.map, this.scheduler.chunkGraph, this.scheduler.options
|
|
99
|
+
if (this.scheduler.chunkGraph) graph_namespaceObject.Chunks.assetsContents(this.map, this.scheduler.chunkGraph, this.scheduler.options.supports.gzip);
|
|
100
100
|
this.sdk.addClientRoutes([
|
|
101
101
|
types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.ModuleGraph,
|
|
102
102
|
types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.BundleSize
|
|
@@ -65,7 +65,7 @@ class InternalBundlePlugin extends InternalBasePlugin {
|
|
|
65
65
|
}, this.done = async ()=>{
|
|
66
66
|
time('InternalBundlePlugin.done');
|
|
67
67
|
try {
|
|
68
|
-
if (this.scheduler.chunkGraph) Chunks.assetsContents(this.map, this.scheduler.chunkGraph, this.scheduler.options
|
|
68
|
+
if (this.scheduler.chunkGraph) Chunks.assetsContents(this.map, this.scheduler.chunkGraph, this.scheduler.options.supports.gzip);
|
|
69
69
|
this.sdk.addClientRoutes([
|
|
70
70
|
Manifest.RsdoctorManifestClientRoutes.ModuleGraph,
|
|
71
71
|
Manifest.RsdoctorManifestClientRoutes.BundleSize
|
|
@@ -112,7 +112,13 @@ async function doneHandler(_stats, _this, context, compiler) {
|
|
|
112
112
|
logger_namespaceObject.logger.debug(`${(build_namespaceObject.Process.getMemoryUsageMessage(), '[After AppendTreeShaking to ModuleGraph]')}`);
|
|
113
113
|
}
|
|
114
114
|
const shouldParseBundle = false !== _this.options.supports.parseBundle;
|
|
115
|
-
|
|
115
|
+
const gzip = _this.options.supports.gzip;
|
|
116
|
+
await getModulesInfos(compiler, _this.modulesGraph, _this.chunkGraph, shouldParseBundle, _this.sourceMapSets, _this.assetsWithoutSourceMap, false === gzip ? {
|
|
117
|
+
enabled: false
|
|
118
|
+
} : {
|
|
119
|
+
enabled: true,
|
|
120
|
+
level: gzip.gzipLevel
|
|
121
|
+
});
|
|
116
122
|
logger_namespaceObject.logger.debug(`${build_namespaceObject.Process.getMemoryUsageMessage()}, '[After Transform ModuleGraph]'`);
|
|
117
123
|
logger_namespaceObject.logger.debug('reportModuleGraph start');
|
|
118
124
|
if (_this.modulesGraph) await _this.sdk.reportModuleGraph(_this.modulesGraph);
|
|
@@ -138,10 +144,10 @@ const ensureDevtools = (compiler)=>{
|
|
|
138
144
|
}
|
|
139
145
|
return true;
|
|
140
146
|
};
|
|
141
|
-
async function getModulesInfos(compiler, moduleGraph, chunkGraph, parseBundle, sourceMapSets, assetsWithoutSourceMap) {
|
|
147
|
+
async function getModulesInfos(compiler, moduleGraph, chunkGraph, parseBundle, sourceMapSets, assetsWithoutSourceMap, gzipOptions) {
|
|
142
148
|
if (!moduleGraph) return;
|
|
143
149
|
try {
|
|
144
|
-
await index_cjs_namespaceObject.Chunks.getAssetsModulesData(moduleGraph, chunkGraph, compiler.outputPath, sourceMapSets, parseBundle, assetsWithoutSourceMap);
|
|
150
|
+
await index_cjs_namespaceObject.Chunks.getAssetsModulesData(moduleGraph, chunkGraph, compiler.outputPath, sourceMapSets, parseBundle, assetsWithoutSourceMap, gzipOptions);
|
|
145
151
|
} catch {}
|
|
146
152
|
}
|
|
147
153
|
function escapeRegExp(str) {
|
|
@@ -79,7 +79,13 @@ async function doneHandler(_stats, _this, context, compiler) {
|
|
|
79
79
|
logger.debug(`${(Process.getMemoryUsageMessage(), '[After AppendTreeShaking to ModuleGraph]')}`);
|
|
80
80
|
}
|
|
81
81
|
const shouldParseBundle = false !== _this.options.supports.parseBundle;
|
|
82
|
-
|
|
82
|
+
const gzip = _this.options.supports.gzip;
|
|
83
|
+
await getModulesInfos(compiler, _this.modulesGraph, _this.chunkGraph, shouldParseBundle, _this.sourceMapSets, _this.assetsWithoutSourceMap, false === gzip ? {
|
|
84
|
+
enabled: false
|
|
85
|
+
} : {
|
|
86
|
+
enabled: true,
|
|
87
|
+
level: gzip.gzipLevel
|
|
88
|
+
});
|
|
83
89
|
logger.debug(`${Process.getMemoryUsageMessage()}, '[After Transform ModuleGraph]'`);
|
|
84
90
|
logger.debug('reportModuleGraph start');
|
|
85
91
|
if (_this.modulesGraph) await _this.sdk.reportModuleGraph(_this.modulesGraph);
|
|
@@ -105,10 +111,10 @@ const ensureDevtools = (compiler)=>{
|
|
|
105
111
|
}
|
|
106
112
|
return true;
|
|
107
113
|
};
|
|
108
|
-
async function getModulesInfos(compiler, moduleGraph, chunkGraph, parseBundle, sourceMapSets, assetsWithoutSourceMap) {
|
|
114
|
+
async function getModulesInfos(compiler, moduleGraph, chunkGraph, parseBundle, sourceMapSets, assetsWithoutSourceMap, gzipOptions) {
|
|
109
115
|
if (!moduleGraph) return;
|
|
110
116
|
try {
|
|
111
|
-
await Chunks.getAssetsModulesData(moduleGraph, chunkGraph, compiler.outputPath, sourceMapSets, parseBundle, assetsWithoutSourceMap);
|
|
117
|
+
await Chunks.getAssetsModulesData(moduleGraph, chunkGraph, compiler.outputPath, sourceMapSets, parseBundle, assetsWithoutSourceMap, gzipOptions);
|
|
112
118
|
} catch {}
|
|
113
119
|
}
|
|
114
120
|
function escapeRegExp(str) {
|
|
@@ -65,13 +65,25 @@ function getDefaultOutput() {
|
|
|
65
65
|
function getDefaultSupports() {
|
|
66
66
|
return {
|
|
67
67
|
parseBundle: true,
|
|
68
|
-
banner: void 0
|
|
69
|
-
gzip: true
|
|
68
|
+
banner: void 0
|
|
70
69
|
};
|
|
71
70
|
}
|
|
72
71
|
function isJsonOutputEnv(value) {
|
|
73
72
|
return 'json' === value;
|
|
74
73
|
}
|
|
74
|
+
function normalizeGzipLevel(value) {
|
|
75
|
+
const gzipLevel = void 0 === value ? 6 : value;
|
|
76
|
+
external_assert_default()('number' == typeof gzipLevel && Number.isInteger(gzipLevel) && gzipLevel >= 0 && gzipLevel <= 9, '`supports.gzip.gzipLevel` must be an integer between 0 and 9.');
|
|
77
|
+
return gzipLevel;
|
|
78
|
+
}
|
|
79
|
+
function normalizeGzip(value) {
|
|
80
|
+
external_assert_default()(void 0 === value || 'boolean' == typeof value || 'object' == typeof value && null !== value && !Array.isArray(value), '`supports.gzip` must be a boolean or an object.');
|
|
81
|
+
if (false === value) return false;
|
|
82
|
+
const gzipLevel = 'object' == typeof value && null !== value ? value.gzipLevel : void 0;
|
|
83
|
+
return {
|
|
84
|
+
gzipLevel: normalizeGzipLevel(gzipLevel)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
75
87
|
function normalizeFeatures(features, mode) {
|
|
76
88
|
if (Array.isArray(features)) return {
|
|
77
89
|
loader: features.includes('loader'),
|
|
@@ -127,7 +139,8 @@ function normalizeUserConfig(config = {}) {
|
|
|
127
139
|
}, mode, brief } = normalizedConfig;
|
|
128
140
|
const supports = {
|
|
129
141
|
...getDefaultSupports(),
|
|
130
|
-
...userSupports
|
|
142
|
+
...userSupports,
|
|
143
|
+
gzip: normalizeGzip(userSupports.gzip)
|
|
131
144
|
};
|
|
132
145
|
const disableClientServer = 'true' === process.env.RSTEST ? false : process.env.CI ? true : userDisableClientServer;
|
|
133
146
|
external_assert_default()('object' == typeof linter);
|
|
@@ -22,13 +22,25 @@ function getDefaultOutput() {
|
|
|
22
22
|
function getDefaultSupports() {
|
|
23
23
|
return {
|
|
24
24
|
parseBundle: true,
|
|
25
|
-
banner: void 0
|
|
26
|
-
gzip: true
|
|
25
|
+
banner: void 0
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
28
|
function isJsonOutputEnv(value) {
|
|
30
29
|
return 'json' === value;
|
|
31
30
|
}
|
|
31
|
+
function normalizeGzipLevel(value) {
|
|
32
|
+
const gzipLevel = void 0 === value ? 6 : value;
|
|
33
|
+
assert('number' == typeof gzipLevel && Number.isInteger(gzipLevel) && gzipLevel >= 0 && gzipLevel <= 9, '`supports.gzip.gzipLevel` must be an integer between 0 and 9.');
|
|
34
|
+
return gzipLevel;
|
|
35
|
+
}
|
|
36
|
+
function normalizeGzip(value) {
|
|
37
|
+
assert(void 0 === value || 'boolean' == typeof value || 'object' == typeof value && null !== value && !Array.isArray(value), '`supports.gzip` must be a boolean or an object.');
|
|
38
|
+
if (false === value) return false;
|
|
39
|
+
const gzipLevel = 'object' == typeof value && null !== value ? value.gzipLevel : void 0;
|
|
40
|
+
return {
|
|
41
|
+
gzipLevel: normalizeGzipLevel(gzipLevel)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
32
44
|
function normalizeFeatures(features, mode) {
|
|
33
45
|
if (Array.isArray(features)) return {
|
|
34
46
|
loader: features.includes('loader'),
|
|
@@ -84,7 +96,8 @@ function normalizeUserConfig(config = {}) {
|
|
|
84
96
|
}, mode, brief } = normalizedConfig;
|
|
85
97
|
const supports = {
|
|
86
98
|
...getDefaultSupports(),
|
|
87
|
-
...userSupports
|
|
99
|
+
...userSupports,
|
|
100
|
+
gzip: normalizeGzip(userSupports.gzip)
|
|
88
101
|
};
|
|
89
102
|
const disableClientServer = 'true' === process.env.RSTEST ? false : process.env.CI ? true : userDisableClientServer;
|
|
90
103
|
assert('object' == typeof linter);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/core",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -94,10 +94,10 @@
|
|
|
94
94
|
"fs-extra": "^11.1.1",
|
|
95
95
|
"semver": "^7.8.5",
|
|
96
96
|
"source-map": "^0.7.6",
|
|
97
|
-
"@rsdoctor/graph": "1.6.
|
|
98
|
-
"@rsdoctor/sdk": "1.6.
|
|
99
|
-
"@rsdoctor/types": "1.6.
|
|
100
|
-
"@rsdoctor/utils": "1.6.
|
|
97
|
+
"@rsdoctor/graph": "1.6.2",
|
|
98
|
+
"@rsdoctor/sdk": "1.6.2",
|
|
99
|
+
"@rsdoctor/types": "1.6.2",
|
|
100
|
+
"@rsdoctor/utils": "1.6.2"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"@rspack/core": "^2.0.5",
|