@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,181 @@
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 compatible_exports = {};
20
+ __export(compatible_exports, {
21
+ getAllModules: () => getAllModules,
22
+ getDependencyPosition: () => getDependencyPosition,
23
+ getEntryModule: () => getEntryModule,
24
+ getExportDependency: () => getExportDependency,
25
+ getExportStatement: () => getExportStatement,
26
+ getLastExportInfo: () => getLastExportInfo,
27
+ getModuleExportsType: () => getModuleExportsType,
28
+ getModuleSource: () => getModuleSource,
29
+ getResolveModule: () => getResolveModule,
30
+ getResolveRequest: () => getResolveRequest,
31
+ getSdkDependencyByWebpackDependency: () => getSdkDependencyByWebpackDependency,
32
+ getWebpackDependencyRequest: () => getWebpackDependencyRequest,
33
+ getWebpackModuleId: () => getWebpackModuleId,
34
+ getWebpackModulePath: () => getWebpackModulePath,
35
+ isExternalModule: () => isExternalModule,
36
+ isNormalModule: () => isNormalModule
37
+ });
38
+ module.exports = __toCommonJS(compatible_exports);
39
+ var import_lodash = require("lodash");
40
+ var import_graph = require("@rsdoctor/graph");
41
+ function isNormalModule(mod) {
42
+ return "request" in mod && "rawRequest" in mod && "resource" in mod;
43
+ }
44
+ function getWebpackModuleId(mod) {
45
+ return mod.identifier();
46
+ }
47
+ function getWebpackModulePath(mod) {
48
+ return mod.resource ?? mod.nameForCondition?.() ?? getWebpackModuleId(mod);
49
+ }
50
+ function getWebpackDependencyRequest(dep, module2) {
51
+ return dep.request ?? dep.userRequest ?? module2?.rawRequest;
52
+ }
53
+ function getResolveRequest(dep, graph) {
54
+ return getWebpackModulePath(graph.getResolvedModule(dep));
55
+ }
56
+ function isExternalModule(mod) {
57
+ return Boolean(mod.externalType);
58
+ }
59
+ function getModuleSource(mod) {
60
+ return isExternalModule(mod) ? "" : mod.originalSource?.()?.source().toString() ?? "";
61
+ }
62
+ function getResolveModule(dep, graph) {
63
+ if (graph) {
64
+ return graph.getResolvedModule(dep);
65
+ }
66
+ return dep.module ?? void 0;
67
+ }
68
+ function getEntryModule(entryMap) {
69
+ return Array.from(entryMap.values()).map((entry) => entry.getRuntimeChunk()).map((chunk) => chunk ? chunk.entryModule : null).filter(Boolean).map((mod) => isNormalModule(mod) ? mod : mod.rootModule);
70
+ }
71
+ function getModuleExportsType(module2, moduleGraph, strict = false) {
72
+ if (moduleGraph) {
73
+ return module2.getExportsType(moduleGraph, strict);
74
+ }
75
+ const exportsType = module2.buildMeta && module2.buildMeta.exportsType;
76
+ if (!exportsType && !strict) {
77
+ return "dynamic";
78
+ }
79
+ if (exportsType === "named") {
80
+ return "namespace";
81
+ }
82
+ return strict ? "default-with-named" : "dynamic";
83
+ }
84
+ function getDependencyPosition(dep, module2, getSource = true) {
85
+ const { loc: depLoc } = dep;
86
+ if (!("start" in depLoc)) {
87
+ return;
88
+ }
89
+ const transformed = {
90
+ start: {
91
+ line: depLoc.start.line,
92
+ column: depLoc.start.column
93
+ },
94
+ end: depLoc.end ? {
95
+ line: depLoc.end.line,
96
+ column: depLoc.end.column
97
+ } : void 0
98
+ };
99
+ const statement = new import_graph.Statement(module2, {
100
+ source: getSource ? module2.getSourceRange(transformed) : void 0,
101
+ transformed
102
+ });
103
+ return statement;
104
+ }
105
+ function getExportDependency(info, module2) {
106
+ let dep = module2.dependencies.find((dep2) => {
107
+ return dep2.name === info.name && (dep2.type === "harmony export imported specifier" || dep2.type === "harmony export specifier");
108
+ });
109
+ if (!dep && info._target && info._target.size > 0) {
110
+ dep = info._getMaxTarget().values().next().value.connection.dependency;
111
+ }
112
+ return dep;
113
+ }
114
+ function getSdkDependencyByWebpackDependency(dep, module2, graph) {
115
+ const modulePath = getWebpackModulePath(module2);
116
+ const request = getWebpackDependencyRequest(dep);
117
+ return graph.getDependencies().find(
118
+ (item) => item.module.path === modulePath && item.request === request
119
+ );
120
+ }
121
+ function getExportStatement(info, normalModule, graph) {
122
+ const webpackDependency = getExportDependency(info, normalModule);
123
+ if (!webpackDependency) {
124
+ return;
125
+ }
126
+ const modulePath = getWebpackModulePath(normalModule);
127
+ const request = getWebpackDependencyRequest(webpackDependency);
128
+ const sdkDependency = graph.getDependencies().find(
129
+ (item) => item.module.path === modulePath && item.request === request
130
+ );
131
+ if (sdkDependency && sdkDependency.statements.length === 1) {
132
+ return sdkDependency.statements[0];
133
+ }
134
+ const sdkModule = graph.getModuleByWebpackId(
135
+ getWebpackModuleId(normalModule)
136
+ );
137
+ if (sdkModule) {
138
+ return getDependencyPosition(webpackDependency, sdkModule);
139
+ }
140
+ }
141
+ function getLastExportInfo(info, webpackGraph) {
142
+ const target = info.findTarget(webpackGraph, () => true);
143
+ if (!target || !target.export) {
144
+ return;
145
+ }
146
+ const exportsInfo = webpackGraph.getExportsInfo(target.module);
147
+ const lastInfo = exportsInfo.getExportInfo(target.export[0]);
148
+ return lastInfo;
149
+ }
150
+ function getAllModules(compilation) {
151
+ const modules = [];
152
+ for (const mod of compilation.modules) {
153
+ modules.push(...mod.modules ?? []);
154
+ modules.push(mod);
155
+ }
156
+ return (0, import_lodash.unionBy)(
157
+ modules.filter(
158
+ (mod) => !getWebpackModuleId(mod).startsWith("webpack/runtime")
159
+ ),
160
+ (mod) => getWebpackModuleId(mod)
161
+ );
162
+ }
163
+ // Annotate the CommonJS export names for ESM import in node:
164
+ 0 && (module.exports = {
165
+ getAllModules,
166
+ getDependencyPosition,
167
+ getEntryModule,
168
+ getExportDependency,
169
+ getExportStatement,
170
+ getLastExportInfo,
171
+ getModuleExportsType,
172
+ getModuleSource,
173
+ getResolveModule,
174
+ getResolveRequest,
175
+ getSdkDependencyByWebpackDependency,
176
+ getWebpackDependencyRequest,
177
+ getWebpackModuleId,
178
+ getWebpackModulePath,
179
+ isExternalModule,
180
+ isNormalModule
181
+ });
@@ -0,0 +1,2 @@
1
+ export * as Build from './build';
2
+ export * as Common from './common';
@@ -0,0 +1,41 @@
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 build_utils_exports = {};
30
+ __export(build_utils_exports, {
31
+ Build: () => Build,
32
+ Common: () => Common
33
+ });
34
+ module.exports = __toCommonJS(build_utils_exports);
35
+ var Build = __toESM(require("./build"));
36
+ var Common = __toESM(require("./common"));
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ Build,
40
+ Common
41
+ });
@@ -0,0 +1,3 @@
1
+ export * from './build-utils';
2
+ export * as InnerPlugins from './inner-plugins';
3
+ export * from './types';
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var src_exports = {};
31
+ __export(src_exports, {
32
+ InnerPlugins: () => InnerPlugins
33
+ });
34
+ module.exports = __toCommonJS(src_exports);
35
+ __reExport(src_exports, require("./build-utils"), module.exports);
36
+ var InnerPlugins = __toESM(require("./inner-plugins"));
37
+ __reExport(src_exports, require("./types"), module.exports);
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ InnerPlugins,
41
+ ...require("./build-utils"),
42
+ ...require("./types")
43
+ });
@@ -0,0 +1,6 @@
1
+ import type { Tap } from 'tapable';
2
+ export declare const pluginTapName = "RsdoctorWebpackPlugin";
3
+ export declare const pluginTapPostOptions: Tap;
4
+ export declare const pluginTapPreOptions: Tap;
5
+ export declare const internalPluginTapPreOptions: (namespace: string) => Tap;
6
+ export declare const internalPluginTapPostOptions: (namespace: string) => Tap;
@@ -0,0 +1,52 @@
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 constants_exports = {};
20
+ __export(constants_exports, {
21
+ internalPluginTapPostOptions: () => internalPluginTapPostOptions,
22
+ internalPluginTapPreOptions: () => internalPluginTapPreOptions,
23
+ pluginTapName: () => pluginTapName,
24
+ pluginTapPostOptions: () => pluginTapPostOptions,
25
+ pluginTapPreOptions: () => pluginTapPreOptions
26
+ });
27
+ module.exports = __toCommonJS(constants_exports);
28
+ const pluginTapName = "RsdoctorWebpackPlugin";
29
+ const pluginTapPostOptions = {
30
+ name: pluginTapName,
31
+ stage: 999
32
+ };
33
+ const pluginTapPreOptions = {
34
+ name: pluginTapName,
35
+ stage: -999
36
+ };
37
+ const internalPluginTapPreOptions = (namespace) => ({
38
+ name: `${pluginTapName}:${namespace}`,
39
+ stage: -998
40
+ });
41
+ const internalPluginTapPostOptions = (namespace) => ({
42
+ name: `${pluginTapName}:${namespace}`,
43
+ stage: 1e3
44
+ });
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ internalPluginTapPostOptions,
48
+ internalPluginTapPreOptions,
49
+ pluginTapName,
50
+ pluginTapPostOptions,
51
+ pluginTapPreOptions
52
+ });
@@ -0,0 +1,2 @@
1
+ export * from './plugins';
2
+ export * from './utils';
@@ -0,0 +1,24 @@
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 inner_plugins_exports = {};
17
+ module.exports = __toCommonJS(inner_plugins_exports);
18
+ __reExport(inner_plugins_exports, require("./plugins"), module.exports);
19
+ __reExport(inner_plugins_exports, require("./utils"), module.exports);
20
+ // Annotate the CommonJS export names for ESM import in node:
21
+ 0 && (module.exports = {
22
+ ...require("./plugins"),
23
+ ...require("./utils")
24
+ });
@@ -0,0 +1,4 @@
1
+ import { Plugin } from '@rsdoctor/types';
2
+ import type { ProxyLoaderOptions } from "../../types";
3
+ declare const loaderModule: Plugin.LoaderDefinition<ProxyLoaderOptions, {}>;
4
+ export = loaderModule;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var import_build = require("../../build-utils/build");
3
+ var import_utils = require("../utils");
4
+ const loaderModule = function(...args) {
5
+ if ((0, import_utils.shouldSkipLoader)(this)) {
6
+ this.callback(null, ...args);
7
+ return;
8
+ }
9
+ this.cacheable(false);
10
+ const mod = (0, import_utils.getOriginLoaderModule)(this);
11
+ if (mod.default) {
12
+ if (mod.raw === false && Buffer.isBuffer(args[0])) {
13
+ args[0] = args[0].toString();
14
+ }
15
+ let start;
16
+ let startHRTime;
17
+ const trap = import_build.Utils.createLoaderContextTrap.call(
18
+ this,
19
+ (err, res, sourceMap) => {
20
+ (0, import_utils.reportLoader)(
21
+ this,
22
+ start,
23
+ startHRTime,
24
+ false,
25
+ false,
26
+ args[0].toString(),
27
+ err,
28
+ res,
29
+ sourceMap
30
+ );
31
+ }
32
+ );
33
+ start = Date.now();
34
+ startHRTime = process.hrtime();
35
+ try {
36
+ const result = mod.default.apply(trap, args);
37
+ if (result) {
38
+ if (!(result instanceof Promise)) {
39
+ (0, import_utils.reportLoader)(
40
+ this,
41
+ start,
42
+ startHRTime,
43
+ false,
44
+ true,
45
+ args[0].toString(),
46
+ null,
47
+ result
48
+ );
49
+ }
50
+ }
51
+ return result;
52
+ } catch (error) {
53
+ (0, import_utils.reportLoader)(
54
+ this,
55
+ start,
56
+ startHRTime,
57
+ false,
58
+ true,
59
+ args[0].toString(),
60
+ error,
61
+ null
62
+ );
63
+ throw error;
64
+ }
65
+ }
66
+ this.callback(null, ...args);
67
+ };
68
+ loaderModule.pitch = function() {
69
+ if ((0, import_utils.shouldSkipLoader)(this)) {
70
+ return;
71
+ }
72
+ this.cacheable(false);
73
+ const mod = (0, import_utils.getOriginLoaderModule)(this);
74
+ if (mod.pitch && typeof mod.pitch === "function") {
75
+ let start;
76
+ let startHRTime;
77
+ const trap = import_build.Utils.createLoaderContextTrap.call(this, (err, res) => {
78
+ (0, import_utils.reportLoader)(
79
+ this,
80
+ start,
81
+ startHRTime,
82
+ true,
83
+ false,
84
+ err ? "Loader Pitch Async Error" : "",
85
+ err,
86
+ res
87
+ );
88
+ });
89
+ start = Date.now();
90
+ startHRTime = process.hrtime();
91
+ try {
92
+ const res = mod.pitch.apply(trap, arguments);
93
+ if (res) {
94
+ if (!(res instanceof Promise)) {
95
+ (0, import_utils.reportLoader)(this, start, startHRTime, true, true, "", null, res);
96
+ }
97
+ }
98
+ return res;
99
+ } catch (error) {
100
+ (0, import_utils.reportLoader)(
101
+ this,
102
+ start,
103
+ startHRTime,
104
+ true,
105
+ true,
106
+ "Loader Pitch Sync Error",
107
+ error,
108
+ null
109
+ );
110
+ throw error;
111
+ }
112
+ }
113
+ };
114
+ loaderModule.raw = true;
115
+ module.exports = loaderModule;
@@ -0,0 +1,13 @@
1
+ import type { DoctorWebpackSDK } from '@rsdoctor/sdk';
2
+ import type { Linter, Plugin } from '@rsdoctor/types';
3
+ import type { InternalPlugin, DoctorPluginInstance } from "../../types";
4
+ export declare abstract class InternalBasePlugin<T extends Plugin.BaseCompiler> implements InternalPlugin<T, Linter.ExtendRuleData[]> {
5
+ readonly scheduler: DoctorPluginInstance<Plugin.BaseCompiler, Linter.ExtendRuleData[]>;
6
+ abstract name: string;
7
+ constructor(scheduler: DoctorPluginInstance<Plugin.BaseCompiler, Linter.ExtendRuleData[]>);
8
+ abstract apply(compiler: T): void;
9
+ get options(): import("@/types").DoctorPluginOptionsNormalized<Linter.ExtendRuleData<any, string>[]>;
10
+ get sdk(): DoctorWebpackSDK;
11
+ get tapPostOptions(): import("tapable").Tap;
12
+ get tapPreOptions(): import("tapable").Tap;
13
+ }
@@ -0,0 +1,45 @@
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 base_exports = {};
20
+ __export(base_exports, {
21
+ InternalBasePlugin: () => InternalBasePlugin
22
+ });
23
+ module.exports = __toCommonJS(base_exports);
24
+ var import_constants = require("../constants");
25
+ class InternalBasePlugin {
26
+ constructor(scheduler) {
27
+ this.scheduler = scheduler;
28
+ }
29
+ get options() {
30
+ return this.scheduler.options;
31
+ }
32
+ get sdk() {
33
+ return this.scheduler.sdk;
34
+ }
35
+ get tapPostOptions() {
36
+ return (0, import_constants.internalPluginTapPostOptions)(this.name);
37
+ }
38
+ get tapPreOptions() {
39
+ return (0, import_constants.internalPluginTapPreOptions)(this.name);
40
+ }
41
+ }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ InternalBasePlugin
45
+ });
@@ -0,0 +1,11 @@
1
+ import { Rule, Err, Plugin } from '@rsdoctor/types';
2
+ import { InternalBasePlugin } from './base';
3
+ import { DevToolError } from '@rsdoctor/utils/error';
4
+ export declare class InternalErrorReporterPlugin<T extends Plugin.BaseCompiler> extends InternalBasePlugin<T> {
5
+ readonly name = "error-reporter";
6
+ apply(compiler: T): void;
7
+ done: (stats: Plugin.BaseStats) => Promise<void>;
8
+ handleWebpackError(err: Plugin.BuildError, category: Rule.RuleMessageCategory, level: keyof typeof Err.ErrorLevel): DevToolError;
9
+ reportWarnings(warnings: Plugin.BuildError[]): Promise<void>;
10
+ reportErrors(errors: Plugin.BuildWarning[]): Promise<void>;
11
+ }
@@ -0,0 +1,85 @@
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 errors_exports = {};
20
+ __export(errors_exports, {
21
+ InternalErrorReporterPlugin: () => InternalErrorReporterPlugin
22
+ });
23
+ module.exports = __toCommonJS(errors_exports);
24
+ var import_types = require("@rsdoctor/types");
25
+ var import_base = require("./base");
26
+ var import_error = require("@rsdoctor/utils/error");
27
+ class InternalErrorReporterPlugin extends import_base.InternalBasePlugin {
28
+ constructor() {
29
+ super(...arguments);
30
+ this.name = "error-reporter";
31
+ this.done = async (stats) => {
32
+ const tasks = [];
33
+ const statsData = stats.toJson({
34
+ all: false,
35
+ errors: true,
36
+ warnings: true
37
+ });
38
+ if (stats.hasErrors()) {
39
+ tasks.push(this.reportErrors(statsData.errors || []));
40
+ }
41
+ if (stats.hasWarnings()) {
42
+ tasks.push(this.reportWarnings(statsData.warnings || []));
43
+ }
44
+ await Promise.all(tasks);
45
+ };
46
+ }
47
+ apply(compiler) {
48
+ compiler.hooks.done.tapPromise(this.tapPreOptions, this.done);
49
+ }
50
+ handleWebpackError(err, category, level) {
51
+ return import_error.DevToolError.from(err, {
52
+ category,
53
+ code: import_types.Rule.RuleMessageCodeEnumerated.Overlay,
54
+ controller: { noStack: false },
55
+ detail: {
56
+ stack: "stack" in err ? err.stack : err.message
57
+ },
58
+ level
59
+ });
60
+ }
61
+ async reportWarnings(warnings) {
62
+ const arr = warnings.map((warning) => {
63
+ return this.handleWebpackError(
64
+ warning,
65
+ import_types.Rule.RuleMessageCategory.Compile,
66
+ "Warn"
67
+ );
68
+ });
69
+ this.sdk.reportError(arr);
70
+ }
71
+ async reportErrors(errors) {
72
+ const arr = errors.map((err) => {
73
+ return this.handleWebpackError(
74
+ err,
75
+ import_types.Rule.RuleMessageCategory.Bundle,
76
+ "Error"
77
+ );
78
+ });
79
+ this.sdk.reportError(arr);
80
+ }
81
+ }
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ InternalErrorReporterPlugin
85
+ });
@@ -0,0 +1,6 @@
1
+ export * from './loader';
2
+ export * from './plugins';
3
+ export * from './errors';
4
+ export * from './progress';
5
+ export * from './summary';
6
+ export * from './base';