@rsdoctor/core 0.0.2-beta.2 → 0.1.0
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/utils/loader.js +1 -4
- package/dist/build-utils/build/utils/parseBundle.js +1 -1
- package/dist/build-utils/common/chunks/assetsModules.js +1 -1
- package/dist/build-utils/common/webpack/compatible.js +1 -1
- package/dist/inner-plugins/plugins/bundle.js +3 -1
- package/dist/inner-plugins/plugins/loader.js +1 -1
- package/dist/inner-plugins/plugins/summary.d.ts +2 -2
- package/dist/inner-plugins/utils/loader.js +2 -2
- package/dist/rules/rule.d.ts +1 -1
- package/dist/types/plugin.d.ts +6 -2
- package/package.json +6 -6
|
@@ -73,7 +73,7 @@ function extractLoaderName(loaderPath, cwd = "") {
|
|
|
73
73
|
return res;
|
|
74
74
|
}
|
|
75
75
|
function mapEachRules(rules, callback) {
|
|
76
|
-
return rules.map((rule
|
|
76
|
+
return rules.map((rule) => {
|
|
77
77
|
if (typeof rule === "string") {
|
|
78
78
|
return callback({
|
|
79
79
|
loader: rule
|
|
@@ -114,9 +114,6 @@ function mapEachRules(rules, callback) {
|
|
|
114
114
|
...rule,
|
|
115
115
|
use: mapEachRules([rule.use], callback)
|
|
116
116
|
};
|
|
117
|
-
throw new Error(
|
|
118
|
-
`webpack.module.rules.use[${i}] parse error: ${rule.use}`
|
|
119
|
-
);
|
|
120
117
|
}
|
|
121
118
|
if ("rules" in rule && Array.isArray(rule.rules)) {
|
|
122
119
|
return {
|
|
@@ -92,7 +92,7 @@ const parseBundle = (bundlePath, modulesData) => {
|
|
|
92
92
|
if (state.locations)
|
|
93
93
|
return;
|
|
94
94
|
const { left, right } = node;
|
|
95
|
-
if (left
|
|
95
|
+
if (left?.object && left.object.name === "exports" && left.property && left.property.name === "modules" && isModulesHash(right)) {
|
|
96
96
|
state.locations = getModulesLocations(right);
|
|
97
97
|
}
|
|
98
98
|
},
|
|
@@ -62,7 +62,7 @@ async function getAssetsModulesData(bundleStats, bundleDir, opts) {
|
|
|
62
62
|
if (bundleDir && bundleStats?.assets) {
|
|
63
63
|
bundlesSources = {};
|
|
64
64
|
parsedModules = {};
|
|
65
|
-
for (const statAsset of bundleStats
|
|
65
|
+
for (const statAsset of bundleStats.assets) {
|
|
66
66
|
const assetFile = import_path.default.join(bundleDir, statAsset.name);
|
|
67
67
|
let bundleInfo;
|
|
68
68
|
const collectedModules = [];
|
|
@@ -72,7 +72,7 @@ function getModuleExportsType(module2, moduleGraph, strict = false) {
|
|
|
72
72
|
if (moduleGraph) {
|
|
73
73
|
return module2.getExportsType(moduleGraph, strict);
|
|
74
74
|
}
|
|
75
|
-
const exportsType = module2.buildMeta
|
|
75
|
+
const exportsType = module2.buildMeta?.exportsType;
|
|
76
76
|
if (!exportsType && !strict) {
|
|
77
77
|
return "dynamic";
|
|
78
78
|
}
|
|
@@ -63,7 +63,9 @@ class InternalBundlePlugin extends import_base.InternalBasePlugin {
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
this.done = async () => {
|
|
66
|
-
|
|
66
|
+
if (this.scheduler.chunkGraph) {
|
|
67
|
+
import_common.Chunks.assetsContents(this.map, this.scheduler.chunkGraph);
|
|
68
|
+
}
|
|
67
69
|
this.sdk.addClientRoutes([
|
|
68
70
|
import_types.Manifest.RsdoctorManifestClientRoutes.ModuleGraph,
|
|
69
71
|
import_types.Manifest.RsdoctorManifestClientRoutes.BundleSize
|
|
@@ -128,7 +128,7 @@ class InternalLoaderPlugin extends import_base.InternalBasePlugin {
|
|
|
128
128
|
return tap;
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
|
-
if (compiler.webpack
|
|
131
|
+
if (compiler.webpack?.NormalModule?.getCompilationHooks) {
|
|
132
132
|
compiler.webpack.NormalModule.getCompilationHooks(
|
|
133
133
|
compilation
|
|
134
134
|
).loader.intercept(interceptor);
|
|
@@ -5,10 +5,10 @@ export declare class InternalSummaryPlugin<T extends Plugin.BaseCompiler> extend
|
|
|
5
5
|
private times;
|
|
6
6
|
private preTimes;
|
|
7
7
|
private postTimes;
|
|
8
|
-
apply(compiler:
|
|
8
|
+
apply(compiler: T): void;
|
|
9
9
|
private mark;
|
|
10
10
|
beforeCompile: () => Promise<void>;
|
|
11
11
|
afterCompile: (compilation: Plugin.BaseCompilation) => Promise<void>;
|
|
12
|
-
done: (compiler:
|
|
12
|
+
done: (compiler: T) => Promise<void>;
|
|
13
13
|
private report;
|
|
14
14
|
}
|
|
@@ -107,7 +107,7 @@ function interceptLoader(rules, loaderPath, options, cwd = process.cwd(), resolv
|
|
|
107
107
|
return target;
|
|
108
108
|
};
|
|
109
109
|
return import_build.Utils.mapEachRules(rules, (rule) => {
|
|
110
|
-
if (rule
|
|
110
|
+
if (rule.loader?.startsWith("builtin:")) {
|
|
111
111
|
return rule;
|
|
112
112
|
}
|
|
113
113
|
const opts = {
|
|
@@ -171,7 +171,7 @@ async function reportLoader(ctx, start, startHRTime, isPitch, sync, code, err, r
|
|
|
171
171
|
file: loaderData[0].resource.path
|
|
172
172
|
};
|
|
173
173
|
const sdk = (0, import_sdk.getSDK)();
|
|
174
|
-
if (sdk
|
|
174
|
+
if (sdk?.reportLoader) {
|
|
175
175
|
sdk.reportLoader(loaderData);
|
|
176
176
|
sdk.reportSourceMap(sourceMapData);
|
|
177
177
|
return loaderData;
|
package/dist/rules/rule.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare class Rule<Config = DefaultRuleConfig> implements Linter.RuleMeta
|
|
|
16
16
|
get title(): string;
|
|
17
17
|
get severity(): Linter.Severity;
|
|
18
18
|
get config(): Config | undefined;
|
|
19
|
-
get category(): "bundle" |
|
|
19
|
+
get category(): "bundle" | RuleTypes.RuleMessageCategory | "compile" | "emo";
|
|
20
20
|
setOption(opt: Linter.RuleConfigItem): void;
|
|
21
21
|
match(level: Linter.Severity): boolean;
|
|
22
22
|
validate(context: SDK.RuntimeContext): Promise<Linter.ValidateResult>;
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Linter as LinterType, Common, Plugin, SDK } from '@rsdoctor/types';
|
|
2
2
|
import type { RsdoctorSlaveSDK, RsdoctorWebpackSDK } from '@rsdoctor/sdk';
|
|
3
|
-
import { ModuleGraph } from '@rsdoctor/graph';
|
|
4
|
-
|
|
3
|
+
import { ChunkGraph, ModuleGraph } from '@rsdoctor/graph';
|
|
4
|
+
import { rules } from "../rules/rules";
|
|
5
|
+
import { RuleData } from '@rsdoctor/types/dist/linter';
|
|
6
|
+
type InternalRules = typeof rules[number] & RuleData[];
|
|
5
7
|
export interface RsdoctorWebpackPluginOptions<Rules extends LinterType.ExtendRuleData[]> {
|
|
6
8
|
/** Checker configuration */
|
|
7
9
|
linter?: LinterType.Options<Rules, InternalRules>;
|
|
@@ -65,6 +67,8 @@ export interface RsdoctorPluginInstance<T extends Plugin.BaseCompiler, Rules ext
|
|
|
65
67
|
readonly name: string;
|
|
66
68
|
readonly options: RsdoctorPluginOptionsNormalized<Rules>;
|
|
67
69
|
readonly sdk: RsdoctorWebpackSDK;
|
|
70
|
+
_modulesGraphApplied?: boolean;
|
|
71
|
+
chunkGraph?: ChunkGraph;
|
|
68
72
|
modulesGraph: ModuleGraph;
|
|
69
73
|
ensureModulesChunksGraphApplied(compiler: T): void;
|
|
70
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"semver": "^7.5.4",
|
|
52
52
|
"source-map": "^0.7.4",
|
|
53
53
|
"webpack-bundle-analyzer": "^4.9.1",
|
|
54
|
-
"@rsdoctor/graph": "0.0
|
|
55
|
-
"@rsdoctor/
|
|
56
|
-
"@rsdoctor/
|
|
57
|
-
"@rsdoctor/
|
|
54
|
+
"@rsdoctor/graph": "0.1.0",
|
|
55
|
+
"@rsdoctor/types": "0.1.0",
|
|
56
|
+
"@rsdoctor/sdk": "0.1.0",
|
|
57
|
+
"@rsdoctor/utils": "0.1.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/bytes": "3.1.1",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"tslib": "2.4.1",
|
|
74
74
|
"typescript": "^5.2.2",
|
|
75
75
|
"webpack": "^5.89.0",
|
|
76
|
-
"@rsdoctor/test-helper": "0.0
|
|
76
|
+
"@rsdoctor/test-helper": "0.1.0"
|
|
77
77
|
},
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public",
|