@rsdoctor/core 0.0.2-beta.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.
Files changed (139) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/dist/build-utils/build/chunks/assetsModules.d.ts +3 -0
  4. package/dist/build-utils/build/chunks/assetsModules.js +32 -0
  5. package/dist/build-utils/build/chunks/chunkTransform.d.ts +4 -0
  6. package/dist/build-utils/build/chunks/chunkTransform.js +31 -0
  7. package/dist/build-utils/build/chunks/generateTileGraph.d.ts +10 -0
  8. package/dist/build-utils/build/chunks/generateTileGraph.js +77 -0
  9. package/dist/build-utils/build/chunks/index.d.ts +3 -0
  10. package/dist/build-utils/build/chunks/index.js +26 -0
  11. package/dist/build-utils/build/index.d.ts +4 -0
  12. package/dist/build-utils/build/index.js +47 -0
  13. package/dist/build-utils/build/module-graph/index.d.ts +3 -0
  14. package/dist/build-utils/build/module-graph/index.js +26 -0
  15. package/dist/build-utils/build/module-graph/parser.d.ts +2 -0
  16. package/dist/build-utils/build/module-graph/parser.js +44 -0
  17. package/dist/build-utils/build/module-graph/transform.d.ts +4 -0
  18. package/dist/build-utils/build/module-graph/transform.js +37 -0
  19. package/dist/build-utils/build/module-graph/treeShaking.d.ts +3 -0
  20. package/dist/build-utils/build/module-graph/treeShaking.js +130 -0
  21. package/dist/build-utils/build/module-graph/utils.d.ts +3 -0
  22. package/dist/build-utils/build/module-graph/utils.js +113 -0
  23. package/dist/build-utils/build/module-graph/webpack/transform.d.ts +11 -0
  24. package/dist/build-utils/build/module-graph/webpack/transform.js +197 -0
  25. package/dist/build-utils/build/utils/index.d.ts +3 -0
  26. package/dist/build-utils/build/utils/index.js +26 -0
  27. package/dist/build-utils/build/utils/loader.d.ts +12 -0
  28. package/dist/build-utils/build/utils/loader.js +210 -0
  29. package/dist/build-utils/build/utils/parseBundle.d.ts +12 -0
  30. package/dist/build-utils/build/utils/parseBundle.js +277 -0
  31. package/dist/build-utils/build/utils/plugin.d.ts +5 -0
  32. package/dist/build-utils/build/utils/plugin.js +63 -0
  33. package/dist/build-utils/common/chunks/assetsContent.d.ts +4 -0
  34. package/dist/build-utils/common/chunks/assetsContent.js +34 -0
  35. package/dist/build-utils/common/chunks/assetsModules.d.ts +23 -0
  36. package/dist/build-utils/common/chunks/assetsModules.js +106 -0
  37. package/dist/build-utils/common/chunks/chunkTransform.d.ts +5 -0
  38. package/dist/build-utils/common/chunks/chunkTransform.js +73 -0
  39. package/dist/build-utils/common/chunks/index.d.ts +3 -0
  40. package/dist/build-utils/common/chunks/index.js +26 -0
  41. package/dist/build-utils/common/index.d.ts +5 -0
  42. package/dist/build-utils/common/index.js +50 -0
  43. package/dist/build-utils/common/module-graph/compatible.d.ts +9 -0
  44. package/dist/build-utils/common/module-graph/compatible.js +63 -0
  45. package/dist/build-utils/common/module-graph/index.d.ts +3 -0
  46. package/dist/build-utils/common/module-graph/index.js +26 -0
  47. package/dist/build-utils/common/module-graph/transform.d.ts +10 -0
  48. package/dist/build-utils/common/module-graph/transform.js +193 -0
  49. package/dist/build-utils/common/module-graph/utils.d.ts +17 -0
  50. package/dist/build-utils/common/module-graph/utils.js +62 -0
  51. package/dist/build-utils/common/trans-utils/index.d.ts +1 -0
  52. package/dist/build-utils/common/trans-utils/index.js +22 -0
  53. package/dist/build-utils/common/trans-utils/transStats.d.ts +6 -0
  54. package/dist/build-utils/common/trans-utils/transStats.js +35 -0
  55. package/dist/build-utils/common/webpack/compatible.d.ts +26 -0
  56. package/dist/build-utils/common/webpack/compatible.js +181 -0
  57. package/dist/build-utils/index.d.ts +2 -0
  58. package/dist/build-utils/index.js +41 -0
  59. package/dist/index.d.ts +3 -0
  60. package/dist/index.js +43 -0
  61. package/dist/inner-plugins/constants.d.ts +6 -0
  62. package/dist/inner-plugins/constants.js +52 -0
  63. package/dist/inner-plugins/index.d.ts +2 -0
  64. package/dist/inner-plugins/index.js +24 -0
  65. package/dist/inner-plugins/loaders/proxy.d.ts +4 -0
  66. package/dist/inner-plugins/loaders/proxy.js +115 -0
  67. package/dist/inner-plugins/plugins/base.d.ts +13 -0
  68. package/dist/inner-plugins/plugins/base.js +45 -0
  69. package/dist/inner-plugins/plugins/errors.d.ts +11 -0
  70. package/dist/inner-plugins/plugins/errors.js +85 -0
  71. package/dist/inner-plugins/plugins/index.d.ts +6 -0
  72. package/dist/inner-plugins/plugins/index.js +32 -0
  73. package/dist/inner-plugins/plugins/loader.d.ts +11 -0
  74. package/dist/inner-plugins/plugins/loader.js +157 -0
  75. package/dist/inner-plugins/plugins/plugins.d.ts +8 -0
  76. package/dist/inner-plugins/plugins/plugins.js +60 -0
  77. package/dist/inner-plugins/plugins/progress.d.ts +8 -0
  78. package/dist/inner-plugins/plugins/progress.js +59 -0
  79. package/dist/inner-plugins/plugins/summary.d.ts +14 -0
  80. package/dist/inner-plugins/plugins/summary.js +115 -0
  81. package/dist/inner-plugins/utils/circleDetect.d.ts +4 -0
  82. package/dist/inner-plugins/utils/circleDetect.js +42 -0
  83. package/dist/inner-plugins/utils/config.d.ts +7 -0
  84. package/dist/inner-plugins/utils/config.js +145 -0
  85. package/dist/inner-plugins/utils/index.d.ts +5 -0
  86. package/dist/inner-plugins/utils/index.js +30 -0
  87. package/dist/inner-plugins/utils/loader.d.ts +11 -0
  88. package/dist/inner-plugins/utils/loader.js +201 -0
  89. package/dist/inner-plugins/utils/plugin.d.ts +5 -0
  90. package/dist/inner-plugins/utils/plugin.js +126 -0
  91. package/dist/inner-plugins/utils/sdk.d.ts +3 -0
  92. package/dist/inner-plugins/utils/sdk.js +36 -0
  93. package/dist/rules/index.d.ts +3 -0
  94. package/dist/rules/index.js +33 -0
  95. package/dist/rules/linter.d.ts +13 -0
  96. package/dist/rules/linter.js +74 -0
  97. package/dist/rules/rule.d.ts +31 -0
  98. package/dist/rules/rule.js +140 -0
  99. package/dist/rules/rules/default-import-check/index.d.ts +4 -0
  100. package/dist/rules/rules/default-import-check/index.js +124 -0
  101. package/dist/rules/rules/default-import-check/types.d.ts +4 -0
  102. package/dist/rules/rules/default-import-check/types.js +16 -0
  103. package/dist/rules/rules/default-import-check/utils.d.ts +10 -0
  104. package/dist/rules/rules/default-import-check/utils.js +93 -0
  105. package/dist/rules/rules/duplicate-package/index.d.ts +4 -0
  106. package/dist/rules/rules/duplicate-package/index.js +71 -0
  107. package/dist/rules/rules/duplicate-package/types.d.ts +24 -0
  108. package/dist/rules/rules/duplicate-package/types.js +51 -0
  109. package/dist/rules/rules/duplicate-package/utils.d.ts +3 -0
  110. package/dist/rules/rules/duplicate-package/utils.js +89 -0
  111. package/dist/rules/rules/ecma-version-check/index.d.ts +4 -0
  112. package/dist/rules/rules/ecma-version-check/index.js +82 -0
  113. package/dist/rules/rules/ecma-version-check/types.d.ts +7 -0
  114. package/dist/rules/rules/ecma-version-check/types.js +16 -0
  115. package/dist/rules/rules/ecma-version-check/utils.d.ts +2 -0
  116. package/dist/rules/rules/ecma-version-check/utils.js +31 -0
  117. package/dist/rules/rules/index.d.ts +1 -0
  118. package/dist/rules/rules/index.js +37 -0
  119. package/dist/rules/rules/loader-performance-optimization/index.d.ts +4 -0
  120. package/dist/rules/rules/loader-performance-optimization/index.js +121 -0
  121. package/dist/rules/rules/loader-performance-optimization/types.d.ts +22 -0
  122. package/dist/rules/rules/loader-performance-optimization/types.js +16 -0
  123. package/dist/rules/rules/loader-performance-optimization/utils.d.ts +1 -0
  124. package/dist/rules/rules/loader-performance-optimization/utils.js +38 -0
  125. package/dist/rules/utils.d.ts +3 -0
  126. package/dist/rules/utils.js +44 -0
  127. package/dist/types/chunks.d.ts +11 -0
  128. package/dist/types/chunks.js +16 -0
  129. package/dist/types/index.d.ts +5 -0
  130. package/dist/types/index.js +30 -0
  131. package/dist/types/loader.d.ts +19 -0
  132. package/dist/types/loader.js +16 -0
  133. package/dist/types/plugin.d.ts +72 -0
  134. package/dist/types/plugin.js +16 -0
  135. package/dist/types/rules.d.ts +7 -0
  136. package/dist/types/rules.js +16 -0
  137. package/dist/types/webpack.d.ts +14 -0
  138. package/dist/types/webpack.js +16 -0
  139. package/package.json +87 -0
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var ecma_version_check_exports = {};
30
+ __export(ecma_version_check_exports, {
31
+ rule: () => rule
32
+ });
33
+ module.exports = __toCommonJS(ecma_version_check_exports);
34
+ var import_ruleUtils = require("@rsdoctor/utils/ruleUtils");
35
+ var import_path = __toESM(require("path"));
36
+ var import_rule = require("../../rule");
37
+ var import_utils = require("./utils");
38
+ var import_types2 = require("@rsdoctor/types");
39
+ const title = "ecma-version-check";
40
+ const rule = (0, import_rule.defineRule)(() => {
41
+ return {
42
+ meta: {
43
+ code: "E1004",
44
+ title,
45
+ category: "bundle",
46
+ severity: import_types2.Linter.Severity.Warn,
47
+ defaultConfig: {
48
+ highestVersion: import_ruleUtils.ECMAVersion.ES5,
49
+ ignore: []
50
+ }
51
+ },
52
+ check({ chunkGraph, report, ruleConfig }) {
53
+ for (const asset of chunkGraph.getAssets()) {
54
+ if (import_path.default.extname(asset.path) !== ".js") {
55
+ continue;
56
+ }
57
+ if (ruleConfig.ignore.includes(asset.path)) {
58
+ continue;
59
+ }
60
+ const currentVersion = import_ruleUtils.parser.utils.detectECMAVersion(asset.content);
61
+ const currentVersionNumber = (0, import_utils.getVersionNumber)(currentVersion);
62
+ const configVersionNumber = (0, import_utils.getVersionNumber)(ruleConfig.highestVersion);
63
+ if (!configVersionNumber || !currentVersionNumber) {
64
+ return;
65
+ }
66
+ if (currentVersionNumber > configVersionNumber) {
67
+ const assetsName = import_path.default.basename(asset.path);
68
+ report({
69
+ message: `The ECMA version of asset ${assetsName} is ${currentVersion}, which is bigger than ${ruleConfig.highestVersion}.`,
70
+ detail: {
71
+ type: "link"
72
+ }
73
+ });
74
+ }
75
+ }
76
+ }
77
+ };
78
+ });
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ rule
82
+ });
@@ -0,0 +1,7 @@
1
+ import type { ECMAVersion } from '@rsdoctor/utils/ruleUtils';
2
+ export interface Config {
3
+ /** Check the ecma version */
4
+ highestVersion: ECMAVersion;
5
+ /** Js files that need to be ignored */
6
+ ignore: string[];
7
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,2 @@
1
+ import type { ECMAVersion } from '@rsdoctor/utils/ruleUtils';
2
+ export declare function getVersionNumber(ECMAString: ECMAVersion): number | undefined;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var utils_exports = {};
20
+ __export(utils_exports, {
21
+ getVersionNumber: () => getVersionNumber
22
+ });
23
+ module.exports = __toCommonJS(utils_exports);
24
+ function getVersionNumber(ECMAString) {
25
+ const version = ECMAString.match(/\d/);
26
+ return version?.length ? Number(version[0]) : void 0;
27
+ }
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ getVersionNumber
31
+ });
@@ -0,0 +1 @@
1
+ export declare const rules: (import("@rsdoctor/types/dist/linter").RuleData<import("./duplicate-package").Config, "duplicate-package"> | import("@rsdoctor/types/dist/linter").RuleData<import("./default-import-check").Config, "default-import-check"> | import("@rsdoctor/types/dist/linter").RuleData<import("./loader-performance-optimization").Config, "loader-performance-optimization"> | import("@rsdoctor/types/dist/linter").RuleData<import("./ecma-version-check").Config, "ecma-version-check">)[];
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var rules_exports = {};
20
+ __export(rules_exports, {
21
+ rules: () => rules
22
+ });
23
+ module.exports = __toCommonJS(rules_exports);
24
+ var import_duplicate_package = require("./duplicate-package");
25
+ var import_default_import_check = require("./default-import-check");
26
+ var import_loader_performance_optimization = require("./loader-performance-optimization");
27
+ var import_ecma_version_check = require("./ecma-version-check");
28
+ const rules = [
29
+ import_duplicate_package.rule,
30
+ import_default_import_check.rule,
31
+ import_loader_performance_optimization.rule,
32
+ import_ecma_version_check.rule
33
+ ];
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ rules
37
+ });
@@ -0,0 +1,4 @@
1
+ import { Linter } from '@rsdoctor/types';
2
+ import { Config } from './types';
3
+ export type { Config } from './types';
4
+ export declare const rule: Linter.RuleData<Config, "loader-performance-optimization">;
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var loader_performance_optimization_exports = {};
20
+ __export(loader_performance_optimization_exports, {
21
+ rule: () => rule
22
+ });
23
+ module.exports = __toCommonJS(loader_performance_optimization_exports);
24
+ var import_types = require("@rsdoctor/types");
25
+ var import_common = require("@rsdoctor/utils/common");
26
+ var import_rule = require("../../rule");
27
+ var import_utils = require("./utils");
28
+ const title = "loader-performance-optimization";
29
+ const rule = (0, import_rule.defineRule)(() => {
30
+ return {
31
+ meta: {
32
+ code: "E1003",
33
+ title,
34
+ category: "compile",
35
+ severity: import_types.Linter.Severity.Warn,
36
+ defaultConfig: {
37
+ ignore: [],
38
+ threshold: 5e3,
39
+ extensions: ["js", "css", "jpg", "jpeg", "png", "gif", "webp", "svg"]
40
+ }
41
+ },
42
+ check({ loader, configs, root, ruleConfig, report }) {
43
+ const { extensions, ignore, threshold } = ruleConfig;
44
+ if (extensions.length === 0)
45
+ return;
46
+ if (loader.length === 0)
47
+ return;
48
+ const { config } = configs.find((e) => e.name === "webpack");
49
+ const cwd = config.context || root;
50
+ const nodeModulesPathRegexp = /\/node_modules\//;
51
+ const resultMap = /* @__PURE__ */ new Map();
52
+ const loaders = loader.map((el) => el.loaders).reduce((t, c) => t.concat(c));
53
+ for (const item of loader) {
54
+ const { path, ext } = item.resource;
55
+ if (!(0, import_utils.match)(ext, extensions))
56
+ continue;
57
+ if (nodeModulesPathRegexp.test(path) || !path.startsWith(cwd)) {
58
+ item.loaders.forEach((el) => {
59
+ if ((0, import_utils.match)(el.loader, ignore))
60
+ return;
61
+ const costs = import_common.Loader.getLoaderCosts(el, loaders);
62
+ const v = {
63
+ ...el,
64
+ __resource__: item.resource,
65
+ __costs__: costs
66
+ };
67
+ if (resultMap.has(el.loader)) {
68
+ resultMap.get(el.loader).push(v);
69
+ } else {
70
+ resultMap.set(el.loader, [v]);
71
+ }
72
+ });
73
+ }
74
+ }
75
+ const sum = (arr) => {
76
+ const v1 = arr.reduce((t, c) => t + c.__costs__, 0);
77
+ const v2 = Math.max.apply(
78
+ null,
79
+ arr.map((e) => e.endAt)
80
+ ) - Math.min.apply(arr.map((e) => e.startAt));
81
+ if (v2 >= v1)
82
+ return v1;
83
+ return v2;
84
+ };
85
+ for (const [loaderName, v] of resultMap.entries()) {
86
+ const nodeModulesFiles = v.filter(
87
+ (e) => nodeModulesPathRegexp.test(e.__resource__.path)
88
+ );
89
+ const nodeModulesFilesCosts = sum(nodeModulesFiles);
90
+ const outofCwdFiles = v.filter(
91
+ (e) => !e.__resource__.path.startsWith(cwd)
92
+ );
93
+ const outofCwdFilesCosts = sum(outofCwdFiles);
94
+ const msg = [
95
+ nodeModulesFilesCosts >= threshold && `<b>${nodeModulesFiles.length}</b> node_modules files(costs: <b>${import_common.Time.formatCosts(
96
+ nodeModulesFilesCosts
97
+ )}</b>)`,
98
+ outofCwdFilesCosts >= threshold && `<b>${outofCwdFiles.length}</b> outof project files(costs: <b>${import_common.Time.formatCosts(
99
+ outofCwdFilesCosts
100
+ )}</b>)`
101
+ ].filter(Boolean).join(" and ");
102
+ if (msg) {
103
+ const message = `<b>${loaderName}</b> has process ${msg}.`;
104
+ report({
105
+ message,
106
+ detail: {
107
+ description: message,
108
+ type: "link"
109
+ // nodeModulesFiles,
110
+ // outofCwdFiles,
111
+ }
112
+ });
113
+ }
114
+ }
115
+ }
116
+ };
117
+ });
118
+ // Annotate the CommonJS export names for ESM import in node:
119
+ 0 && (module.exports = {
120
+ rule
121
+ });
@@ -0,0 +1,22 @@
1
+ import type { SDK } from '@rsdoctor/types';
2
+ export interface Config {
3
+ /**
4
+ * loaders which should be ignore.
5
+ */
6
+ ignore: (string | RegExp)[];
7
+ /**
8
+ * threshold which the loader total costs.
9
+ * @unit millisecond
10
+ * @default 5000
11
+ */
12
+ threshold: number;
13
+ /**
14
+ * the file extensions which will be match in rule check.
15
+ * @default ["js", "css", "jpg", "jpeg", "png", "gif", "webp", "svg"]
16
+ */
17
+ extensions: (string | RegExp)[];
18
+ }
19
+ export interface LoaderMapValue extends SDK.LoaderTransformData {
20
+ __resource__: SDK.ResourceData;
21
+ __costs__: number;
22
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1 @@
1
+ export declare function match(str: string, partterns: (string | RegExp)[]): boolean;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var utils_exports = {};
20
+ __export(utils_exports, {
21
+ match: () => match
22
+ });
23
+ module.exports = __toCommonJS(utils_exports);
24
+ function match(str, partterns) {
25
+ if (partterns.length === 0)
26
+ return false;
27
+ return partterns.some((p) => {
28
+ if (typeof p === "string")
29
+ return str === p;
30
+ if (p instanceof RegExp)
31
+ return p.test(str);
32
+ return false;
33
+ });
34
+ }
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ match
38
+ });
@@ -0,0 +1,3 @@
1
+ import { Linter } from '@rsdoctor/types';
2
+ export declare function toSeverity(input: Linter.SeverityInput, defaultLevel: Linter.Severity): Linter.Severity;
3
+ export declare function noop(): void;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var utils_exports = {};
20
+ __export(utils_exports, {
21
+ noop: () => noop,
22
+ toSeverity: () => toSeverity
23
+ });
24
+ module.exports = __toCommonJS(utils_exports);
25
+ var import_types = require("@rsdoctor/types");
26
+ function toSeverity(input, defaultLevel) {
27
+ if (input === "off") {
28
+ return import_types.Linter.Severity.Ignore;
29
+ }
30
+ if (input === "on") {
31
+ return defaultLevel;
32
+ }
33
+ const key = `${input[0].toUpperCase()}${input.slice(
34
+ 1
35
+ )}`;
36
+ return import_types.Linter.Severity[key];
37
+ }
38
+ function noop() {
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ noop,
43
+ toSeverity
44
+ });
@@ -0,0 +1,11 @@
1
+ import { Plugin } from '@rsdoctor/types';
2
+ export type AssetsModules = {
3
+ label?: string;
4
+ isAsset?: boolean;
5
+ modules?: Plugin.StatsModule[];
6
+ };
7
+ export type ParseBundle = (assetFile: string, modules: Plugin.StatsModule[]) => {
8
+ modules?: Record<string, any>;
9
+ src?: string;
10
+ runtimeSrc?: string;
11
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var chunks_exports = {};
16
+ module.exports = __toCommonJS(chunks_exports);
@@ -0,0 +1,5 @@
1
+ export * from './chunks';
2
+ export * from './rules';
3
+ export * from './webpack';
4
+ export * from './loader';
5
+ export * from './plugin';
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var types_exports = {};
17
+ module.exports = __toCommonJS(types_exports);
18
+ __reExport(types_exports, require("./chunks"), module.exports);
19
+ __reExport(types_exports, require("./rules"), module.exports);
20
+ __reExport(types_exports, require("./webpack"), module.exports);
21
+ __reExport(types_exports, require("./loader"), module.exports);
22
+ __reExport(types_exports, require("./plugin"), module.exports);
23
+ // Annotate the CommonJS export names for ESM import in node:
24
+ 0 && (module.exports = {
25
+ ...require("./chunks"),
26
+ ...require("./rules"),
27
+ ...require("./webpack"),
28
+ ...require("./loader"),
29
+ ...require("./plugin")
30
+ });
@@ -0,0 +1,19 @@
1
+ import { Loader } from '@rsdoctor/utils/common';
2
+ export interface ProxyLoaderInternalOptions {
3
+ cwd: string;
4
+ /**
5
+ * the url host of http server(which used to collect data).
6
+ */
7
+ host: string;
8
+ /**
9
+ * correct loader path.
10
+ */
11
+ loader: string;
12
+ /** include the loader option */
13
+ hasOptions: boolean;
14
+ skipLoaders: string[];
15
+ }
16
+ export interface ProxyLoaderOptions {
17
+ [key: string]: any;
18
+ [Loader.LoaderInternalPropertyName]: ProxyLoaderInternalOptions;
19
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var loader_exports = {};
16
+ module.exports = __toCommonJS(loader_exports);
@@ -0,0 +1,72 @@
1
+ import type { Linter as LinterType, Common, Plugin, SDK } from '@rsdoctor/types';
2
+ import type { DoctorSlaveSDK, DoctorWebpackSDK } from '@rsdoctor/sdk';
3
+ import { ModuleGraph } from '@rsdoctor/graph';
4
+ type InternalRules = any;
5
+ export interface DoctorWebpackPluginOptions<Rules extends LinterType.ExtendRuleData[]> {
6
+ /** Checker configuration */
7
+ linter?: LinterType.Options<Rules, InternalRules>;
8
+ /**
9
+ * the switch for the Rsdoctor features.
10
+ */
11
+ features?: Plugin.DoctorWebpackPluginFeatures | Array<keyof Plugin.DoctorWebpackPluginFeatures>;
12
+ /**
13
+ * configuration of the interceptor for webpack loaders.
14
+ * @description worked when the `features.loader === true`.
15
+ */
16
+ loaderInterceptorOptions?: {
17
+ /**
18
+ * loaders which you want to skip it (will not report the target loader data when webpack compile).
19
+ */
20
+ skipLoaders?: string[];
21
+ };
22
+ /**
23
+ * turn on it if you don't need to see profile in browser.
24
+ * @default false
25
+ */
26
+ disableClientServer?: boolean;
27
+ /**
28
+ * sdk instance of outside
29
+ */
30
+ sdkInstance?: DoctorWebpackSDK;
31
+ /**
32
+ * control the Rsdoctor reporter codes records.
33
+ */
34
+ reportCodeType?: {
35
+ noModuleSource?: boolean;
36
+ noAssetsAndModuleSource?: boolean;
37
+ } | undefined;
38
+ /**
39
+ * control the Rsdoctor upload data to TOS.
40
+ * @default false
41
+ */
42
+ disableTOSUpload?: boolean;
43
+ }
44
+ export interface DoctorWebpackMultiplePluginOptions<Rules extends LinterType.ExtendRuleData[] = LinterType.ExtendRuleData[]> extends Omit<DoctorWebpackPluginOptions<Rules>, 'sdkInstance'>, Pick<ConstructorParameters<typeof DoctorSlaveSDK>[0], 'stage'> {
45
+ /**
46
+ * name of builder
47
+ */
48
+ name?: string;
49
+ }
50
+ export interface DoctorPluginOptionsNormalized<Rules extends LinterType.ExtendRuleData[] = []> extends Common.DeepRequired<Omit<DoctorWebpackPluginOptions<Rules>, 'sdkInstance' | 'linter' | 'reportCodeType'>> {
51
+ features: Common.DeepRequired<Plugin.DoctorWebpackPluginFeatures>;
52
+ linter: Required<LinterType.Options<Rules, InternalRules>>;
53
+ sdkInstance?: DoctorWebpackSDK;
54
+ reportCodeType?: SDK.ToDataType;
55
+ }
56
+ export interface BasePluginInstance<T extends Plugin.BaseCompiler> {
57
+ apply: (compiler: T) => void;
58
+ [k: string]: any;
59
+ }
60
+ export interface InternalPlugin<T extends Plugin.BaseCompiler, Rules extends LinterType.ExtendRuleData[] = []> extends BasePluginInstance<T> {
61
+ readonly name: string;
62
+ readonly scheduler: DoctorPluginInstance<T, Rules>;
63
+ }
64
+ export interface DoctorPluginInstance<T extends Plugin.BaseCompiler, Rules extends LinterType.ExtendRuleData[] = []> extends BasePluginInstance<T> {
65
+ readonly name: string;
66
+ readonly options: DoctorPluginOptionsNormalized<Rules>;
67
+ readonly sdk: DoctorWebpackSDK;
68
+ modulesGraph: ModuleGraph;
69
+ ensureModulesChunksGraphApplied(compiler: T): void;
70
+ }
71
+ export interface DoctorRspackPluginOptions<Rules extends LinterType.ExtendRuleData[]> extends DoctorWebpackPluginOptions<Rules> {}
72
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var plugin_exports = {};
16
+ module.exports = __toCommonJS(plugin_exports);
@@ -0,0 +1,7 @@
1
+ import { RuleSetRule } from 'webpack';
2
+ export interface Rule extends RuleSetRule {
3
+ /**
4
+ * https://webpack.js.org/configuration/module/#ruleloaders
5
+ */
6
+ loaders: RuleSetRule['use'];
7
+ }