@rsdoctor/core 0.1.10 → 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.
@@ -1,3 +1,3 @@
1
1
  import { ModuleGraph } from '@rsdoctor/graph';
2
- import type { Compilation } from 'webpack';
3
- export declare function appendTreeShaking(moduleGraph: ModuleGraph, compilation: Compilation): ModuleGraph;
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
- const exportData = /* @__PURE__ */ new Map();
115
- const { moduleGraph: webpackGraph } = compilation;
116
- const allModules = (0, import_compatible.getAllModules)(compilation);
117
- allModules.forEach(
118
- (origin) => transformMgm(origin, webpackGraph, moduleGraph, exportData)
119
- );
120
- allModules.forEach(
121
- (origin) => appendExportConnection(origin, webpackGraph, moduleGraph, exportData)
122
- );
123
- allModules.forEach((origin) => appendImportConnection(origin, moduleGraph));
124
- exportData.clear();
125
- return moduleGraph;
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 = {
@@ -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 of asset ${assetsName} is ${currentVersion}, which is bigger than ${ruleConfig.highestVersion}.`,
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.1.10",
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.1.10",
54
- "@rsdoctor/sdk": "0.1.10",
55
- "@rsdoctor/utils": "0.1.10"
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.1.10",
97
+ "@rsdoctor/types": "0.2.0",
76
98
  "@scripts/test-helper": "0.1.1"
77
99
  },
78
100
  "publishConfig": {