@rsdoctor/core 0.1.0 → 0.1.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/README.md +10 -3
- package/dist/build-utils/build/chunks/assetsModules.d.ts +2 -2
- package/dist/build-utils/build/chunks/chunkTransform.d.ts +2 -2
- package/dist/build-utils/build/chunks/generateTileGraph.d.ts +5 -5
- package/dist/build-utils/build/chunks/generateTileGraph.js +3 -9
- package/dist/build-utils/build/chunks/index.d.ts +1 -1
- package/dist/build-utils/build/index.d.ts +1 -1
- package/dist/build-utils/build/module-graph/index.d.ts +1 -1
- package/dist/build-utils/build/module-graph/parser.d.ts +1 -1
- package/dist/build-utils/build/module-graph/transform.d.ts +1 -1
- package/dist/build-utils/build/module-graph/treeShaking.d.ts +1 -1
- package/dist/build-utils/build/module-graph/utils.d.ts +1 -1
- package/dist/build-utils/build/module-graph/webpack/transform.d.ts +4 -4
- package/dist/build-utils/build/utils/index.d.ts +1 -1
- package/dist/build-utils/build/utils/loader.d.ts +11 -5
- package/dist/build-utils/build/utils/loader.js +94 -5
- package/dist/build-utils/build/utils/parseBundle.d.ts +2 -2
- package/dist/build-utils/build/utils/plugin.d.ts +1 -1
- package/dist/build-utils/common/chunks/assetsContent.d.ts +2 -2
- package/dist/build-utils/common/chunks/assetsModules.d.ts +8 -8
- package/dist/build-utils/common/chunks/assetsModules.js +2 -3
- package/dist/build-utils/common/chunks/chunkTransform.d.ts +2 -2
- package/dist/build-utils/common/chunks/index.d.ts +1 -1
- package/dist/build-utils/common/index.d.ts +1 -1
- package/dist/build-utils/common/module-graph/compatible.d.ts +1 -1
- package/dist/build-utils/common/module-graph/index.d.ts +1 -1
- package/dist/build-utils/common/module-graph/transform.d.ts +1 -4
- package/dist/build-utils/common/module-graph/utils.d.ts +3 -5
- package/dist/build-utils/common/trans-utils/index.d.ts +1 -1
- package/dist/build-utils/common/trans-utils/transStats.d.ts +3 -3
- package/dist/build-utils/common/webpack/compatible.d.ts +2 -2
- package/dist/build-utils/index.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/inner-plugins/constants.d.ts +1 -1
- package/dist/inner-plugins/index.d.ts +1 -1
- package/dist/inner-plugins/loaders/proxy.d.ts +2 -2
- package/dist/inner-plugins/plugins/base.d.ts +10 -10
- package/dist/inner-plugins/plugins/bundle.d.ts +11 -11
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.ts +2 -2
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +9 -8
- package/dist/inner-plugins/plugins/errors.d.ts +7 -7
- package/dist/inner-plugins/plugins/index.d.ts +1 -1
- package/dist/inner-plugins/plugins/loader.d.ts +7 -7
- package/dist/inner-plugins/plugins/plugins.d.ts +5 -5
- package/dist/inner-plugins/plugins/progress.d.ts +4 -4
- package/dist/inner-plugins/plugins/rules.d.ts +5 -5
- package/dist/inner-plugins/plugins/summary.d.ts +11 -11
- package/dist/inner-plugins/utils/circleDetect.d.ts +3 -3
- package/dist/inner-plugins/utils/config.d.ts +2 -2
- package/dist/inner-plugins/utils/index.d.ts +1 -1
- package/dist/inner-plugins/utils/loader.d.ts +3 -3
- package/dist/inner-plugins/utils/plugin.d.ts +1 -1
- package/dist/inner-plugins/utils/sdk.d.ts +1 -1
- package/dist/rules/index.d.ts +1 -1
- package/dist/rules/linter.d.ts +6 -10
- package/dist/rules/rule.d.ts +20 -24
- package/dist/rules/rules/default-import-check/index.d.ts +1 -1
- package/dist/rules/rules/default-import-check/types.d.ts +3 -3
- package/dist/rules/rules/default-import-check/utils.d.ts +1 -1
- package/dist/rules/rules/duplicate-package/index.d.ts +1 -1
- package/dist/rules/rules/duplicate-package/types.d.ts +19 -19
- package/dist/rules/rules/duplicate-package/utils.d.ts +1 -1
- package/dist/rules/rules/ecma-version-check/index.d.ts +1 -1
- package/dist/rules/rules/ecma-version-check/types.d.ts +5 -5
- package/dist/rules/rules/ecma-version-check/utils.d.ts +1 -1
- package/dist/rules/rules/index.d.ts +1 -1
- package/dist/rules/rules/loader-performance-optimization/index.d.ts +1 -1
- package/dist/rules/rules/loader-performance-optimization/types.d.ts +18 -18
- package/dist/rules/rules/loader-performance-optimization/utils.d.ts +1 -1
- package/dist/rules/utils.d.ts +1 -1
- package/dist/types/chunks.d.ts +7 -7
- package/dist/types/index.d.ts +1 -1
- package/dist/types/loader.d.ts +15 -15
- package/dist/types/plugin.d.ts +58 -57
- package/dist/types/rules.d.ts +5 -5
- package/dist/types/webpack.d.ts +4 -4
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
# Rsdoctor
|
|
1
|
+
# Rsdoctor Core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is the core package of Rsdoctor, providing core tools and analysis capabilities for Rsdoctor plugins.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## features
|
|
6
|
+
|
|
7
|
+
- Rsdoctor is a one-stop tool for diagnosing and analyzing the build process and build artifacts.
|
|
8
|
+
- Rsdoctor is a tool that supports Webpack and Rspack build analysis.
|
|
9
|
+
- Rsdoctor is an analysis tool that can display the time-consuming and behavioral details of the compilation.
|
|
10
|
+
- Rsdoctor is a tool that provides bundle Diff and other anti-degradation capabilities simultaneously.
|
|
6
11
|
|
|
7
12
|
## Documentation
|
|
8
13
|
|
|
14
|
+
https://rsdoctor.dev/
|
|
15
|
+
|
|
9
16
|
## Contributing
|
|
10
17
|
|
|
11
18
|
Please read the [Contributing Guide](https://github.com/web-infra-dev/rsdoctor/blob/main/CONTRIBUTING.md).
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Plugin } from '@rsdoctor/types';
|
|
2
|
-
import { ParsedModuleSizeData } from
|
|
3
|
-
export declare function getAssetsModulesData(bundleStats: Plugin.StatsCompilation, bundleDir: string): Promise<ParsedModuleSizeData | null>;
|
|
2
|
+
import { ParsedModuleSizeData } from '../../common/chunks';
|
|
3
|
+
export declare function getAssetsModulesData(bundleStats: Plugin.StatsCompilation, bundleDir: string): Promise<ParsedModuleSizeData | null>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Plugin } from '@rsdoctor/types';
|
|
2
2
|
export declare function chunkTransform(assetMap: Map<string, {
|
|
3
|
-
|
|
4
|
-
}>, bundleStats: Plugin.StatsCompilation): import("@rsdoctor/graph").ChunkGraph;
|
|
3
|
+
content: string;
|
|
4
|
+
}>, bundleStats: Plugin.StatsCompilation): import("@rsdoctor/graph").ChunkGraph;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Plugin } from '@rsdoctor/types';
|
|
2
2
|
export declare const TileGraphReportName = "rsdoctor-tile-graph.html";
|
|
3
3
|
type IGenerateReportOpts = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
reportFilename: string;
|
|
5
|
+
reportTitle?: string;
|
|
6
|
+
bundleDir?: string;
|
|
7
|
+
openBrowser?: boolean;
|
|
8
8
|
};
|
|
9
9
|
export declare function generateTileGraph(bundleStats: Plugin.BaseStats, opts: IGenerateReportOpts, buildOutputPath: string): Promise<string | null>;
|
|
10
|
-
export {};
|
|
10
|
+
export {};
|
|
@@ -33,10 +33,8 @@ __export(generateTileGraph_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(generateTileGraph_exports);
|
|
35
35
|
var import_path = __toESM(require("path"));
|
|
36
|
-
var import_fs = __toESM(require("fs"));
|
|
37
36
|
var import_logger = require("@rsdoctor/utils/logger");
|
|
38
37
|
var import_viewer = require("webpack-bundle-analyzer/lib/viewer");
|
|
39
|
-
var import_constants = require("@rsdoctor/types/dist/constants");
|
|
40
38
|
const TileGraphReportName = "rsdoctor-tile-graph.html";
|
|
41
39
|
async function generateJSONReportUtil(bundleStats, opts) {
|
|
42
40
|
await (0, import_viewer.generateReport)(bundleStats, {
|
|
@@ -47,24 +45,20 @@ async function generateJSONReportUtil(bundleStats, opts) {
|
|
|
47
45
|
info: () => {
|
|
48
46
|
},
|
|
49
47
|
error: (e) => {
|
|
50
|
-
|
|
48
|
+
import_logger.logger.info(`webpack-bundle-analyzer generateReport has error ${e}`);
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
});
|
|
54
52
|
}
|
|
55
53
|
async function generateTileGraph(bundleStats, opts, buildOutputPath) {
|
|
56
54
|
try {
|
|
57
|
-
const tileReportHtmlDir = import_path.default.join(buildOutputPath, import_constants.RsdoctorOutputFolder);
|
|
58
|
-
if (!import_fs.default.existsSync(tileReportHtmlDir)) {
|
|
59
|
-
import_fs.default.mkdirSync(tileReportHtmlDir);
|
|
60
|
-
}
|
|
61
55
|
const { reportFilename } = opts;
|
|
62
56
|
await generateJSONReportUtil(bundleStats, {
|
|
63
57
|
...opts,
|
|
64
58
|
openBrowser: false,
|
|
65
|
-
bundleDir:
|
|
59
|
+
bundleDir: buildOutputPath
|
|
66
60
|
});
|
|
67
|
-
return import_path.default.join(
|
|
61
|
+
return import_path.default.join(buildOutputPath, `${reportFilename}`);
|
|
68
62
|
} catch (e) {
|
|
69
63
|
(0, import_logger.debug)(() => `Generate webpack-bundle-analyzer tile graph has error:${e}`);
|
|
70
64
|
return null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Node } from '@rsdoctor/utils/ruleUtils';
|
|
2
|
-
export declare function hasSetEsModuleStatement(program: Node.Program): boolean;
|
|
2
|
+
export declare function hasSetEsModuleStatement(program: Node.Program): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Plugin } from '@rsdoctor/types';
|
|
2
2
|
import { TransformContext } from '.';
|
|
3
3
|
import { ChunkGraph } from '@rsdoctor/graph';
|
|
4
|
-
export declare function getModuleGraphByStats(compilation: Plugin.BaseCompilation, stats: Plugin.StatsCompilation, root: string, chunkGraph: ChunkGraph, features?: Plugin.RsdoctorWebpackPluginFeatures, context?: TransformContext): Promise<import("@rsdoctor/graph").ModuleGraph>;
|
|
4
|
+
export declare function getModuleGraphByStats(compilation: Plugin.BaseCompilation, stats: Plugin.StatsCompilation, root: string, chunkGraph: ChunkGraph, features?: Plugin.RsdoctorWebpackPluginFeatures, context?: TransformContext): Promise<import("@rsdoctor/graph").ModuleGraph>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ModuleGraph } from '@rsdoctor/graph';
|
|
2
2
|
import type { Compilation } from 'webpack';
|
|
3
|
-
export declare function appendTreeShaking(moduleGraph: ModuleGraph, compilation: Compilation): ModuleGraph;
|
|
3
|
+
export declare function appendTreeShaking(moduleGraph: ModuleGraph, compilation: Compilation): ModuleGraph;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as SDK from '@rsdoctor/graph';
|
|
2
2
|
export declare function getExportIdentifierStatement(name: string, module: SDK.Module): SDK.Statement | undefined;
|
|
3
|
-
export declare function getDeclarationIdentifier(name: string, module: SDK.Module): SDK.Statement | undefined;
|
|
3
|
+
export declare function getDeclarationIdentifier(name: string, module: SDK.Module): SDK.Statement | undefined;
|
|
@@ -4,8 +4,8 @@ import { Node } from '@rsdoctor/utils/ruleUtils';
|
|
|
4
4
|
import { Plugin } from '@rsdoctor/types';
|
|
5
5
|
import { ModuleGraph } from '@rsdoctor/graph';
|
|
6
6
|
export interface TransformContext {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
astCache?: Map<Webpack.NormalModule, Node.Program>;
|
|
8
|
+
packagePathMap?: Map<string, string>;
|
|
9
|
+
getSourceMap?(module: string): Promise<SourceMapConsumer | undefined>;
|
|
10
10
|
}
|
|
11
|
-
export declare function appendModuleGraphByCompilation(compilation: Plugin.BaseCompilation, graph: ModuleGraph, features?: Plugin.RsdoctorWebpackPluginFeatures, context?: TransformContext): Promise<ModuleGraph>;
|
|
11
|
+
export declare function appendModuleGraphByCompilation(compilation: Plugin.BaseCompilation, graph: ModuleGraph, features?: Plugin.RsdoctorWebpackPluginFeatures, context?: TransformContext): Promise<ModuleGraph>;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Common, Plugin } from '@rsdoctor/types';
|
|
3
3
|
import { SourceMapInput as WebpackSourceMapInput } from '../../../types';
|
|
4
|
-
export declare function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export declare function parsePathQueryFragment(str: string): {
|
|
5
|
+
path: string;
|
|
6
|
+
query: string;
|
|
7
|
+
fragment: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function loadLoaderModule(loaderPath: string, cwd?: string): {
|
|
10
|
+
default: Plugin.LoaderDefinition<Common.PlainObject, {}>;
|
|
11
|
+
pitch: Plugin.PitchLoaderDefinitionFunction;
|
|
12
|
+
raw: boolean | void;
|
|
8
13
|
};
|
|
9
14
|
export declare function getLoaderOptions<T>(loaderContext: Plugin.LoaderContext<T>): T;
|
|
10
15
|
export declare function extractLoaderName(loaderPath: string, cwd?: string): string;
|
|
11
16
|
export declare function mapEachRules<T extends Plugin.BuildRuleSetRule>(rules: T[], callback: (rule: T) => T): T[];
|
|
12
|
-
export declare function
|
|
17
|
+
export declare function changeBuiltinLoader<T extends Plugin.BuildRuleSetRule>(rules: T[], loaderName: string, appendRules: (rule: T, index: number) => T): T[];
|
|
18
|
+
export declare function createLoaderContextTrap(this: Plugin.LoaderContext<Common.PlainObject>, final: (err: Error | null | undefined, res: string | Buffer | null, sourceMap?: WebpackSourceMapInput) => void): Plugin.LoaderContext<Common.PlainObject<any>>;
|
|
@@ -28,19 +28,31 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var loader_exports = {};
|
|
30
30
|
__export(loader_exports, {
|
|
31
|
+
changeBuiltinLoader: () => changeBuiltinLoader,
|
|
31
32
|
createLoaderContextTrap: () => createLoaderContextTrap,
|
|
32
33
|
extractLoaderName: () => extractLoaderName,
|
|
33
34
|
getLoaderOptions: () => getLoaderOptions,
|
|
34
35
|
loadLoaderModule: () => loadLoaderModule,
|
|
35
|
-
mapEachRules: () => mapEachRules
|
|
36
|
+
mapEachRules: () => mapEachRules,
|
|
37
|
+
parsePathQueryFragment: () => parsePathQueryFragment
|
|
36
38
|
});
|
|
37
39
|
module.exports = __toCommonJS(loader_exports);
|
|
38
40
|
var import_loader_utils = require("loader-utils");
|
|
39
41
|
var import_path = __toESM(require("path"));
|
|
40
42
|
var import_lodash = require("lodash");
|
|
41
43
|
var import_common = require("@rsdoctor/utils/common");
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/;
|
|
45
|
+
function parsePathQueryFragment(str) {
|
|
46
|
+
const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
|
|
47
|
+
return {
|
|
48
|
+
path: match?.[1].replace(/\0(.)/g, "$1") || "",
|
|
49
|
+
query: match?.[2] ? match[2].replace(/\0(.)/g, "$1") : "",
|
|
50
|
+
fragment: match?.[3] || ""
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function loadLoaderModule(loaderPath, cwd = process.cwd()) {
|
|
54
|
+
const cleanLoaderPath = parsePathQueryFragment(loaderPath).path;
|
|
55
|
+
const mod = process.env.DOCTOR_TEST ? require(import_path.default.resolve(cwd, cleanLoaderPath)) : require(require.resolve(cleanLoaderPath, {
|
|
44
56
|
paths: [cwd, import_path.default.resolve(cwd, "node_modules")]
|
|
45
57
|
}));
|
|
46
58
|
const isESM = mod.__esModule && typeof mod.default === "function";
|
|
@@ -104,6 +116,17 @@ function mapEachRules(rules, callback) {
|
|
|
104
116
|
)
|
|
105
117
|
};
|
|
106
118
|
}
|
|
119
|
+
if (typeof rule.use === "function") {
|
|
120
|
+
const funcUse = rule.use;
|
|
121
|
+
const newRule = {
|
|
122
|
+
...rule,
|
|
123
|
+
use: (...args) => {
|
|
124
|
+
const rules2 = funcUse.apply(null, args);
|
|
125
|
+
return mapEachRules(rules2, callback);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
return newRule;
|
|
129
|
+
}
|
|
107
130
|
if (Array.isArray(rule.use)) {
|
|
108
131
|
return {
|
|
109
132
|
...rule,
|
|
@@ -130,6 +153,68 @@ function mapEachRules(rules, callback) {
|
|
|
130
153
|
return rule;
|
|
131
154
|
});
|
|
132
155
|
}
|
|
156
|
+
function getLoaderNameMatch(_r, loaderName) {
|
|
157
|
+
return typeof _r === "object" && typeof _r?.loader === "string" && _r.loader === loaderName || typeof _r === "string" && _r === loaderName;
|
|
158
|
+
}
|
|
159
|
+
function changeBuiltinLoader(rules, loaderName, appendRules) {
|
|
160
|
+
return rules.map((rule) => {
|
|
161
|
+
if (!rule || typeof rule === "string")
|
|
162
|
+
return rule;
|
|
163
|
+
if (getLoaderNameMatch(rule, loaderName)) {
|
|
164
|
+
const _rule = {
|
|
165
|
+
...rule,
|
|
166
|
+
use: [
|
|
167
|
+
{
|
|
168
|
+
loader: rule.loader,
|
|
169
|
+
options: rule.options
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
loader: void 0,
|
|
173
|
+
options: void 0
|
|
174
|
+
};
|
|
175
|
+
return appendRules(_rule, 0);
|
|
176
|
+
}
|
|
177
|
+
if (rule.use) {
|
|
178
|
+
if (Array.isArray(rule.use)) {
|
|
179
|
+
const _index = (0, import_lodash.findIndex)(
|
|
180
|
+
rule.use,
|
|
181
|
+
(_r) => getLoaderNameMatch(_r, loaderName)
|
|
182
|
+
);
|
|
183
|
+
if (_index > -1) {
|
|
184
|
+
return appendRules(rule, _index);
|
|
185
|
+
}
|
|
186
|
+
} else if (typeof rule.use === "object" && !Array.isArray(rule.use) && typeof rule.use !== "function") {
|
|
187
|
+
rule.use = [
|
|
188
|
+
{
|
|
189
|
+
...rule.use
|
|
190
|
+
}
|
|
191
|
+
];
|
|
192
|
+
return appendRules(rule, 0);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if ("oneOf" in rule && rule.oneOf) {
|
|
196
|
+
return {
|
|
197
|
+
...rule,
|
|
198
|
+
oneOf: changeBuiltinLoader(
|
|
199
|
+
rule.oneOf,
|
|
200
|
+
loaderName,
|
|
201
|
+
appendRules
|
|
202
|
+
)
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
if ("rules" in rule && rule.rules) {
|
|
206
|
+
return {
|
|
207
|
+
...rule,
|
|
208
|
+
rules: changeBuiltinLoader(
|
|
209
|
+
rule.rules,
|
|
210
|
+
loaderName,
|
|
211
|
+
appendRules
|
|
212
|
+
)
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
return rule;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
133
218
|
function createLoaderContextTrap(final) {
|
|
134
219
|
const cb = this.callback;
|
|
135
220
|
let callback = (...args) => {
|
|
@@ -168,7 +253,9 @@ function createLoaderContextTrap(final) {
|
|
|
168
253
|
if (options.hasOptions) {
|
|
169
254
|
return (0, import_lodash.omit)(target.query, [import_common.Loader.LoaderInternalPropertyName]);
|
|
170
255
|
}
|
|
171
|
-
|
|
256
|
+
const innerLoaderPath = options?.loader;
|
|
257
|
+
const loaderQuery = parsePathQueryFragment(innerLoaderPath).query;
|
|
258
|
+
return loaderQuery;
|
|
172
259
|
}
|
|
173
260
|
}
|
|
174
261
|
return Reflect.get(target, key, receiver);
|
|
@@ -199,9 +286,11 @@ function createLoaderContextTrap(final) {
|
|
|
199
286
|
}
|
|
200
287
|
// Annotate the CommonJS export names for ESM import in node:
|
|
201
288
|
0 && (module.exports = {
|
|
289
|
+
changeBuiltinLoader,
|
|
202
290
|
createLoaderContextTrap,
|
|
203
291
|
extractLoaderName,
|
|
204
292
|
getLoaderOptions,
|
|
205
293
|
loadLoaderModule,
|
|
206
|
-
mapEachRules
|
|
294
|
+
mapEachRules,
|
|
295
|
+
parsePathQueryFragment
|
|
207
296
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParseBundle } from
|
|
1
|
+
import { ParseBundle } from '../../../types';
|
|
2
2
|
/**
|
|
3
3
|
* The following code is based on
|
|
4
4
|
* https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/44bd8d0f9aa3b098e271af220096ea70cc44bc9e/src/parseUtils.js#L10
|
|
@@ -9,4 +9,4 @@ import { ParseBundle } from "../../../types";
|
|
|
9
9
|
* Copyright JS Foundation and other contributors.
|
|
10
10
|
* https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/44bd8d0f9aa3b098e271af220096ea70cc44bc9e/LICENSE
|
|
11
11
|
*/
|
|
12
|
-
export declare const parseBundle: ParseBundle;
|
|
12
|
+
export declare const parseBundle: ParseBundle;
|
|
@@ -2,4 +2,4 @@ import type { Hook } from 'tapable';
|
|
|
2
2
|
import { Plugin } from '@rsdoctor/types';
|
|
3
3
|
export declare function shouldInterceptPluginHook<T extends Hook<any, any>>(hook: T): boolean;
|
|
4
4
|
export declare function interceptCompilerHooks(compiler: Plugin.BaseCompiler, interceptor: (name: string, hook: Hook<any, any>, scope: 'compiler') => void): void;
|
|
5
|
-
export declare function interceptCompilationHooks(compilation: Plugin.BaseCompilation, interceptor: (name: string, hook: Hook<any, any>, scope: 'compilation') => void): void;
|
|
5
|
+
export declare function interceptCompilationHooks(compilation: Plugin.BaseCompilation, interceptor: (name: string, hook: Hook<any, any>, scope: 'compilation') => void): void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Plugin } from '@rsdoctor/types';
|
|
2
2
|
import type { ModuleGraph } from '@rsdoctor/graph';
|
|
3
|
-
import { ParseBundle } from
|
|
3
|
+
import { ParseBundle } from '../../../types';
|
|
4
4
|
export type ParsedModuleSizeData = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
[x: string]: {
|
|
6
|
+
size: number;
|
|
7
|
+
sizeConvert: string;
|
|
8
|
+
content: string;
|
|
9
|
+
};
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* The following code is modified based on
|
|
@@ -18,6 +18,6 @@ export type ParsedModuleSizeData = {
|
|
|
18
18
|
* https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/44bd8d0f9aa3b098e271af220096ea70cc44bc9e/LICENSE
|
|
19
19
|
*/
|
|
20
20
|
export declare function getAssetsModulesData(bundleStats: Plugin.StatsCompilation, bundleDir: string, opts: {
|
|
21
|
-
|
|
21
|
+
parseBundle?: ParseBundle;
|
|
22
22
|
}): Promise<ParsedModuleSizeData | null>;
|
|
23
|
-
export declare function transformAssetsModulesData(parsedModulesData: ParsedModuleSizeData, moduleGraph: ModuleGraph): void;
|
|
23
|
+
export declare function transformAssetsModulesData(parsedModulesData: ParsedModuleSizeData, moduleGraph: ModuleGraph): void;
|
|
@@ -36,7 +36,6 @@ var import_lodash = require("lodash");
|
|
|
36
36
|
var import_path = __toESM(require("path"));
|
|
37
37
|
var import_logger = require("@rsdoctor/utils/logger");
|
|
38
38
|
var import_module_graph = require("../module-graph");
|
|
39
|
-
const logger = (0, import_logger.createLogger)();
|
|
40
39
|
async function getAssetsModulesData(bundleStats, bundleDir, opts) {
|
|
41
40
|
const { parseBundle = () => ({}) } = opts || {};
|
|
42
41
|
if ((0, import_lodash.isEmpty)(bundleStats.assets) && !(0, import_lodash.isEmpty)(bundleStats.children)) {
|
|
@@ -72,7 +71,7 @@ async function getAssetsModulesData(bundleStats, bundleDir, opts) {
|
|
|
72
71
|
} catch (err) {
|
|
73
72
|
const { code = "", message } = err;
|
|
74
73
|
const msg = code === "ENOENT" ? "no such file" : message;
|
|
75
|
-
process.env.DEVTOOLS_NODE_DEV === "1" && logger.warn(`Error parsing bundle asset "${assetFile}": ${msg}`);
|
|
74
|
+
process.env.DEVTOOLS_NODE_DEV === "1" && import_logger.logger.warn(`Error parsing bundle asset "${assetFile}": ${msg}`);
|
|
76
75
|
continue;
|
|
77
76
|
}
|
|
78
77
|
bundlesSources[statAsset.name] = (0, import_lodash.pick)(bundleInfo, "src", "runtimeSrc");
|
|
@@ -81,7 +80,7 @@ async function getAssetsModulesData(bundleStats, bundleDir, opts) {
|
|
|
81
80
|
if ((0, import_lodash.isEmpty)(bundlesSources)) {
|
|
82
81
|
bundlesSources = null;
|
|
83
82
|
parsedModules = null;
|
|
84
|
-
process.env.DEVTOOLS_DEV && logger.warn(
|
|
83
|
+
process.env.DEVTOOLS_DEV && import_logger.logger.warn(
|
|
85
84
|
"\nNo bundles were parsed. Analyzer will show only original module sizes from stats file.\n"
|
|
86
85
|
);
|
|
87
86
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChunkGraph } from '@rsdoctor/graph';
|
|
2
2
|
import { Plugin } from '@rsdoctor/types';
|
|
3
3
|
export declare function chunkTransform(assetMap: Map<string, {
|
|
4
|
-
|
|
5
|
-
}>, bundleStats: Plugin.StatsCompilation): ChunkGraph;
|
|
4
|
+
content: string;
|
|
5
|
+
}>, bundleStats: Plugin.StatsCompilation): ChunkGraph;
|
|
@@ -6,4 +6,4 @@ import { Plugin, SDK } from '@rsdoctor/types';
|
|
|
6
6
|
* @link https://github.com/webpack/webpack/blob/main/lib/formatLocation.js#L30-L66
|
|
7
7
|
*/
|
|
8
8
|
export declare function getPositionByStatsLocation(loc: string): SDK.SourceRange | undefined;
|
|
9
|
-
export declare function isWebpack5orRspack(compilation: Plugin.BaseCompilation): Boolean;
|
|
9
|
+
export declare function isWebpack5orRspack(compilation: Plugin.BaseCompilation): Boolean;
|
|
@@ -4,7 +4,4 @@ export declare function getModulesFromArray(modules: Plugin.StatsModule[], colle
|
|
|
4
4
|
/**
|
|
5
5
|
* this function can run in browser & node.
|
|
6
6
|
*/
|
|
7
|
-
export declare function getModuleGraphByStats({
|
|
8
|
-
modules,
|
|
9
|
-
chunks
|
|
10
|
-
}: Plugin.StatsCompilation, root: string, chunkGraph: ChunkGraph): ModuleGraph;
|
|
7
|
+
export declare function getModuleGraphByStats({ modules, chunks }: Plugin.StatsCompilation, root: string, chunkGraph: ChunkGraph): ModuleGraph;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import type { ModuleGraph } from '@rsdoctor/graph';
|
|
3
3
|
interface DependencyData {
|
|
4
|
-
|
|
4
|
+
type?: string;
|
|
5
5
|
}
|
|
6
6
|
/** Determine whether it is the import statement itself */
|
|
7
|
-
export declare function isImportDependency({
|
|
8
|
-
type
|
|
9
|
-
}: DependencyData): boolean;
|
|
7
|
+
export declare function isImportDependency({ type }: DependencyData): boolean;
|
|
10
8
|
export declare function getImportKind(dep: DependencyData): SDK.DependencyKind;
|
|
11
9
|
/**
|
|
12
10
|
* Remove the css module without connection
|
|
@@ -14,4 +12,4 @@ export declare function getImportKind(dep: DependencyData): SDK.DependencyKind;
|
|
|
14
12
|
*/
|
|
15
13
|
export declare function removeNoImportStyle(graph: ModuleGraph): void;
|
|
16
14
|
export declare function isStyleExt(path: string): boolean;
|
|
17
|
-
export {};
|
|
15
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './transStats';
|
|
1
|
+
export * from './transStats';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChunkGraph } from '@rsdoctor/graph';
|
|
2
2
|
import { Plugin } from '@rsdoctor/types';
|
|
3
3
|
export declare function transStats(json: Plugin.StatsCompilation): Promise<{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}>;
|
|
4
|
+
chunkGraph: ChunkGraph;
|
|
5
|
+
moduleGraph: import("@rsdoctor/graph").ModuleGraph;
|
|
6
|
+
}>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SDK } from '@rsdoctor/types';
|
|
2
2
|
import { ModuleGraph as SdkModuleGraph, Module as SdkModule, Statement } from '@rsdoctor/graph';
|
|
3
3
|
import { Compilation, Dependency, ExternalModule, Module, ModuleGraph, NormalModule } from 'webpack';
|
|
4
|
-
import type { EntryPoint, ExportInfo } from
|
|
4
|
+
import type { EntryPoint, ExportInfo } from '../../../types/index';
|
|
5
5
|
export declare function isNormalModule(mod: Module): mod is NormalModule;
|
|
6
6
|
export declare function getWebpackModuleId(mod: Module): string;
|
|
7
7
|
export declare function getWebpackModulePath(mod: NormalModule): string;
|
|
@@ -23,4 +23,4 @@ export declare function getExportDependency(info: ExportInfo, module: NormalModu
|
|
|
23
23
|
export declare function getSdkDependencyByWebpackDependency(dep: Dependency, module: NormalModule, graph: SdkModuleGraph): import("@rsdoctor/graph").Dependency | undefined;
|
|
24
24
|
export declare function getExportStatement(info: ExportInfo, normalModule: NormalModule, graph: SdkModuleGraph): Statement | undefined;
|
|
25
25
|
export declare function getLastExportInfo(info: ExportInfo, webpackGraph: ModuleGraph): ExportInfo | undefined;
|
|
26
|
-
export declare function getAllModules(compilation: Compilation): NormalModule[];
|
|
26
|
+
export declare function getAllModules(compilation: Compilation): NormalModule[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * as Build from './build';
|
|
2
|
-
export * as Common from './common';
|
|
2
|
+
export * as Common from './common';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export declare const pluginTapName = "RsdoctorWebpackPlugin";
|
|
|
3
3
|
export declare const pluginTapPostOptions: Tap;
|
|
4
4
|
export declare const pluginTapPreOptions: Tap;
|
|
5
5
|
export declare const internalPluginTapPreOptions: (namespace: string) => Tap;
|
|
6
|
-
export declare const internalPluginTapPostOptions: (namespace: string) => Tap;
|
|
6
|
+
export declare const internalPluginTapPostOptions: (namespace: string) => Tap;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './plugins';
|
|
2
|
-
export * from './utils';
|
|
2
|
+
export * from './utils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Plugin } from '@rsdoctor/types';
|
|
2
|
-
import type { ProxyLoaderOptions } from
|
|
2
|
+
import type { ProxyLoaderOptions } from '../../types';
|
|
3
3
|
declare const loaderModule: Plugin.LoaderDefinition<ProxyLoaderOptions, {}>;
|
|
4
|
-
export = loaderModule;
|
|
4
|
+
export = loaderModule;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { RsdoctorWebpackSDK } from '@rsdoctor/sdk';
|
|
2
2
|
import type { Linter, Plugin } from '@rsdoctor/types';
|
|
3
|
-
import type { InternalPlugin, RsdoctorPluginInstance } from
|
|
3
|
+
import type { InternalPlugin, RsdoctorPluginInstance } from '../../types';
|
|
4
4
|
export declare abstract class InternalBasePlugin<T extends Plugin.BaseCompiler> implements InternalPlugin<T, Linter.ExtendRuleData[]> {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
5
|
+
readonly scheduler: RsdoctorPluginInstance<Plugin.BaseCompiler, Linter.ExtendRuleData[]>;
|
|
6
|
+
abstract name: string;
|
|
7
|
+
constructor(scheduler: RsdoctorPluginInstance<Plugin.BaseCompiler, Linter.ExtendRuleData[]>);
|
|
8
|
+
abstract apply(compiler: T): void;
|
|
9
|
+
get options(): import("@/types").RsdoctorPluginOptionsNormalized<Linter.ExtendRuleData<any, string>[]>;
|
|
10
|
+
get sdk(): RsdoctorWebpackSDK;
|
|
11
|
+
get tapPostOptions(): import("tapable").Tap;
|
|
12
|
+
get tapPreOptions(): import("tapable").Tap;
|
|
13
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Plugin } from '@rsdoctor/types';
|
|
2
2
|
import { InternalBasePlugin } from './base';
|
|
3
3
|
export declare class InternalBundlePlugin<T extends Plugin.BaseCompiler> extends InternalBasePlugin<T> {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
4
|
+
readonly name = "bundle";
|
|
5
|
+
map: Map<string, {
|
|
6
|
+
content: string;
|
|
7
|
+
}>;
|
|
8
|
+
apply(compiler: T): void;
|
|
9
|
+
ensureAssetContent(name: string): {
|
|
10
|
+
content: string;
|
|
11
|
+
};
|
|
12
|
+
thisCompilation: (compilation: Plugin.BaseCompilation) => void;
|
|
13
|
+
done: () => Promise<void>;
|
|
14
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { RsdoctorPluginInstance } from '../../types';
|
|
1
2
|
import { Linter, Plugin } from '@rsdoctor/types';
|
|
2
|
-
import { RsdoctorPluginInstance } from "../../types";
|
|
3
3
|
/**
|
|
4
4
|
* @description Generate ModuleGraph and ChunkGraph from stats and webpack module apis;
|
|
5
5
|
* @param {Compiler} compiler
|
|
6
6
|
* @return {*}
|
|
7
7
|
* @memberof RsdoctorWebpackPlugin
|
|
8
8
|
*/
|
|
9
|
-
export declare const ensureModulesChunksGraphFn: (compiler: Plugin.BaseCompiler, _this: RsdoctorPluginInstance<Plugin.BaseCompiler, Linter.ExtendRuleData[]>) => void;
|
|
9
|
+
export declare const ensureModulesChunksGraphFn: (compiler: Plugin.BaseCompiler, _this: RsdoctorPluginInstance<Plugin.BaseCompiler, Linter.ExtendRuleData[]>) => void;
|