@rsdoctor/core 0.1.9 → 0.2.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/module-graph/treeShaking.d.ts +2 -2
- package/dist/build-utils/build/module-graph/treeShaking.js +14 -12
- package/dist/build-utils/common/module-graph/transform.js +11 -4
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +13 -0
- package/dist/rules/rules/ecma-version-check/index.js +1 -1
- package/package.json +27 -5
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ModuleGraph } from '@rsdoctor/graph';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function appendTreeShaking(moduleGraph: ModuleGraph, compilation:
|
|
2
|
+
import type { Plugin } from '@rsdoctor/types';
|
|
3
|
+
export declare function appendTreeShaking(moduleGraph: ModuleGraph, compilation: Plugin.BaseCompilation): ModuleGraph | undefined;
|
|
@@ -111,18 +111,20 @@ function appendTreeShaking(moduleGraph, compilation) {
|
|
|
111
111
|
if (!(0, import_module_graph.isWebpack5orRspack)(compilation)) {
|
|
112
112
|
return moduleGraph;
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
114
|
+
if ("moduleGraph" in compilation) {
|
|
115
|
+
const exportData = /* @__PURE__ */ new Map();
|
|
116
|
+
const { moduleGraph: webpackGraph } = compilation;
|
|
117
|
+
const allModules = (0, import_compatible.getAllModules)(compilation);
|
|
118
|
+
allModules.forEach(
|
|
119
|
+
(origin) => transformMgm(origin, webpackGraph, moduleGraph, exportData)
|
|
120
|
+
);
|
|
121
|
+
allModules.forEach(
|
|
122
|
+
(origin) => appendExportConnection(origin, webpackGraph, moduleGraph, exportData)
|
|
123
|
+
);
|
|
124
|
+
allModules.forEach((origin) => appendImportConnection(origin, moduleGraph));
|
|
125
|
+
exportData.clear();
|
|
126
|
+
return moduleGraph;
|
|
127
|
+
}
|
|
126
128
|
}
|
|
127
129
|
// Annotate the CommonJS export names for ESM import in node:
|
|
128
130
|
0 && (module.exports = {
|
|
@@ -121,10 +121,17 @@ function getModuleGraphByStats({ modules, chunks }, root, chunkGraph) {
|
|
|
121
121
|
normal.depth === 0,
|
|
122
122
|
import_types.SDK.ModuleKind.Normal
|
|
123
123
|
);
|
|
124
|
-
normal.chunks?.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
if (normal.chunks?.length) {
|
|
125
|
+
normal.chunks?.forEach((_chunkId) => {
|
|
126
|
+
const chunk = chunkGraph.getChunkById(String(_chunkId));
|
|
127
|
+
chunk && normalModule.addChunk(chunk);
|
|
128
|
+
});
|
|
129
|
+
} else {
|
|
130
|
+
data.chunks?.forEach((_chunkId) => {
|
|
131
|
+
const chunk = chunkGraph.getChunkById(String(_chunkId));
|
|
132
|
+
chunk && normalModule.addChunk(chunk);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
128
135
|
if (normal.source) {
|
|
129
136
|
normalModule.setSource({
|
|
130
137
|
transformed: Buffer.isBuffer(normal.source) ? normal.source.toString() : normal.source
|
|
@@ -66,6 +66,19 @@ const ensureModulesChunksGraphFn = (compiler, _this) => {
|
|
|
66
66
|
context
|
|
67
67
|
);
|
|
68
68
|
(0, import_logger.debug)(import_build.Process.getMemoryUsageMessage, "[After Generate ModuleGraph]");
|
|
69
|
+
if (_this.options.features.treeShaking) {
|
|
70
|
+
_this.modulesGraph = import_build2.ModuleGraph.appendTreeShaking(
|
|
71
|
+
_this.modulesGraph,
|
|
72
|
+
stats.compilation
|
|
73
|
+
) || _this.modulesGraph;
|
|
74
|
+
_this.sdk.addClientRoutes([
|
|
75
|
+
import_types2.Manifest.RsdoctorManifestClientRoutes.TreeShaking
|
|
76
|
+
]);
|
|
77
|
+
(0, import_logger.debug)(
|
|
78
|
+
import_build.Process.getMemoryUsageMessage,
|
|
79
|
+
"[After AppendTreeShaking to ModuleGraph]"
|
|
80
|
+
);
|
|
81
|
+
}
|
|
69
82
|
await getModulesInfosByStats(compiler, statsJson, _this.modulesGraph);
|
|
70
83
|
(0, import_logger.debug)(import_build.Process.getMemoryUsageMessage, "[After Transform ModuleGraph]");
|
|
71
84
|
_this.modulesGraph && await _this.sdk.reportModuleGraph(_this.modulesGraph);
|
|
@@ -66,7 +66,7 @@ const rule = (0, import_rule.defineRule)(() => {
|
|
|
66
66
|
if (currentVersionNumber > configVersionNumber) {
|
|
67
67
|
const assetsName = import_path.default.basename(asset.path);
|
|
68
68
|
report({
|
|
69
|
-
message: `The ECMA version
|
|
69
|
+
message: `The ECMA version used in "${assetsName}" is ${currentVersion}, which exceeds the ${ruleConfig.highestVersion} standard.`,
|
|
70
70
|
detail: {
|
|
71
71
|
type: "link"
|
|
72
72
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -39,6 +39,28 @@
|
|
|
39
39
|
"default": "./dist/types/index.js"
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
|
+
"typesVersions": {
|
|
43
|
+
"*": {
|
|
44
|
+
".": [
|
|
45
|
+
"./dist/index.d.ts"
|
|
46
|
+
],
|
|
47
|
+
"./build-utils": [
|
|
48
|
+
"./dist/build-utils/build/index.d.ts"
|
|
49
|
+
],
|
|
50
|
+
"./common-utils": [
|
|
51
|
+
"./dist/build-utils/common/index.d.ts"
|
|
52
|
+
],
|
|
53
|
+
"./plugins": [
|
|
54
|
+
"./dist/inner-plugins/index.d.ts"
|
|
55
|
+
],
|
|
56
|
+
"./rules": [
|
|
57
|
+
"./dist/rules/index.d.ts"
|
|
58
|
+
],
|
|
59
|
+
"types": [
|
|
60
|
+
"./dist/types/types.d.ts"
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
42
64
|
"dependencies": {
|
|
43
65
|
"axios": "^1.6.1",
|
|
44
66
|
"bytes": "3.1.2",
|
|
@@ -50,9 +72,9 @@
|
|
|
50
72
|
"semver": "^7.5.4",
|
|
51
73
|
"source-map": "^0.7.4",
|
|
52
74
|
"webpack-bundle-analyzer": "^4.9.1",
|
|
53
|
-
"@rsdoctor/graph": "0.
|
|
54
|
-
"@rsdoctor/sdk": "0.
|
|
55
|
-
"@rsdoctor/utils": "0.
|
|
75
|
+
"@rsdoctor/graph": "0.2.0",
|
|
76
|
+
"@rsdoctor/sdk": "0.2.0",
|
|
77
|
+
"@rsdoctor/utils": "0.2.0"
|
|
56
78
|
},
|
|
57
79
|
"devDependencies": {
|
|
58
80
|
"@rspack/core": "0.5.1",
|
|
@@ -72,7 +94,7 @@
|
|
|
72
94
|
"tslib": "2.4.1",
|
|
73
95
|
"typescript": "^5.2.2",
|
|
74
96
|
"webpack": "^5.89.0",
|
|
75
|
-
"@rsdoctor/types": "0.
|
|
97
|
+
"@rsdoctor/types": "0.2.0",
|
|
76
98
|
"@scripts/test-helper": "0.1.1"
|
|
77
99
|
},
|
|
78
100
|
"publishConfig": {
|