@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.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/build-utils/build/chunks/assetsModules.d.ts +3 -0
- package/dist/build-utils/build/chunks/assetsModules.js +32 -0
- package/dist/build-utils/build/chunks/chunkTransform.d.ts +4 -0
- package/dist/build-utils/build/chunks/chunkTransform.js +31 -0
- package/dist/build-utils/build/chunks/generateTileGraph.d.ts +10 -0
- package/dist/build-utils/build/chunks/generateTileGraph.js +77 -0
- package/dist/build-utils/build/chunks/index.d.ts +3 -0
- package/dist/build-utils/build/chunks/index.js +26 -0
- package/dist/build-utils/build/index.d.ts +4 -0
- package/dist/build-utils/build/index.js +47 -0
- package/dist/build-utils/build/module-graph/index.d.ts +3 -0
- package/dist/build-utils/build/module-graph/index.js +26 -0
- package/dist/build-utils/build/module-graph/parser.d.ts +2 -0
- package/dist/build-utils/build/module-graph/parser.js +44 -0
- package/dist/build-utils/build/module-graph/transform.d.ts +4 -0
- package/dist/build-utils/build/module-graph/transform.js +37 -0
- package/dist/build-utils/build/module-graph/treeShaking.d.ts +3 -0
- package/dist/build-utils/build/module-graph/treeShaking.js +130 -0
- package/dist/build-utils/build/module-graph/utils.d.ts +3 -0
- package/dist/build-utils/build/module-graph/utils.js +113 -0
- package/dist/build-utils/build/module-graph/webpack/transform.d.ts +11 -0
- package/dist/build-utils/build/module-graph/webpack/transform.js +197 -0
- package/dist/build-utils/build/utils/index.d.ts +3 -0
- package/dist/build-utils/build/utils/index.js +26 -0
- package/dist/build-utils/build/utils/loader.d.ts +12 -0
- package/dist/build-utils/build/utils/loader.js +210 -0
- package/dist/build-utils/build/utils/parseBundle.d.ts +12 -0
- package/dist/build-utils/build/utils/parseBundle.js +277 -0
- package/dist/build-utils/build/utils/plugin.d.ts +5 -0
- package/dist/build-utils/build/utils/plugin.js +63 -0
- package/dist/build-utils/common/chunks/assetsContent.d.ts +4 -0
- package/dist/build-utils/common/chunks/assetsContent.js +34 -0
- package/dist/build-utils/common/chunks/assetsModules.d.ts +23 -0
- package/dist/build-utils/common/chunks/assetsModules.js +106 -0
- package/dist/build-utils/common/chunks/chunkTransform.d.ts +5 -0
- package/dist/build-utils/common/chunks/chunkTransform.js +73 -0
- package/dist/build-utils/common/chunks/index.d.ts +3 -0
- package/dist/build-utils/common/chunks/index.js +26 -0
- package/dist/build-utils/common/index.d.ts +5 -0
- package/dist/build-utils/common/index.js +50 -0
- package/dist/build-utils/common/module-graph/compatible.d.ts +9 -0
- package/dist/build-utils/common/module-graph/compatible.js +63 -0
- package/dist/build-utils/common/module-graph/index.d.ts +3 -0
- package/dist/build-utils/common/module-graph/index.js +26 -0
- package/dist/build-utils/common/module-graph/transform.d.ts +10 -0
- package/dist/build-utils/common/module-graph/transform.js +193 -0
- package/dist/build-utils/common/module-graph/utils.d.ts +17 -0
- package/dist/build-utils/common/module-graph/utils.js +62 -0
- package/dist/build-utils/common/trans-utils/index.d.ts +1 -0
- package/dist/build-utils/common/trans-utils/index.js +22 -0
- package/dist/build-utils/common/trans-utils/transStats.d.ts +6 -0
- package/dist/build-utils/common/trans-utils/transStats.js +35 -0
- package/dist/build-utils/common/webpack/compatible.d.ts +26 -0
- package/dist/build-utils/common/webpack/compatible.js +181 -0
- package/dist/build-utils/index.d.ts +2 -0
- package/dist/build-utils/index.js +41 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +43 -0
- package/dist/inner-plugins/constants.d.ts +6 -0
- package/dist/inner-plugins/constants.js +52 -0
- package/dist/inner-plugins/index.d.ts +2 -0
- package/dist/inner-plugins/index.js +24 -0
- package/dist/inner-plugins/loaders/proxy.d.ts +4 -0
- package/dist/inner-plugins/loaders/proxy.js +115 -0
- package/dist/inner-plugins/plugins/base.d.ts +13 -0
- package/dist/inner-plugins/plugins/base.js +45 -0
- package/dist/inner-plugins/plugins/errors.d.ts +11 -0
- package/dist/inner-plugins/plugins/errors.js +85 -0
- package/dist/inner-plugins/plugins/index.d.ts +6 -0
- package/dist/inner-plugins/plugins/index.js +32 -0
- package/dist/inner-plugins/plugins/loader.d.ts +11 -0
- package/dist/inner-plugins/plugins/loader.js +157 -0
- package/dist/inner-plugins/plugins/plugins.d.ts +8 -0
- package/dist/inner-plugins/plugins/plugins.js +60 -0
- package/dist/inner-plugins/plugins/progress.d.ts +8 -0
- package/dist/inner-plugins/plugins/progress.js +59 -0
- package/dist/inner-plugins/plugins/summary.d.ts +14 -0
- package/dist/inner-plugins/plugins/summary.js +115 -0
- package/dist/inner-plugins/utils/circleDetect.d.ts +4 -0
- package/dist/inner-plugins/utils/circleDetect.js +42 -0
- package/dist/inner-plugins/utils/config.d.ts +7 -0
- package/dist/inner-plugins/utils/config.js +145 -0
- package/dist/inner-plugins/utils/index.d.ts +5 -0
- package/dist/inner-plugins/utils/index.js +30 -0
- package/dist/inner-plugins/utils/loader.d.ts +11 -0
- package/dist/inner-plugins/utils/loader.js +201 -0
- package/dist/inner-plugins/utils/plugin.d.ts +5 -0
- package/dist/inner-plugins/utils/plugin.js +126 -0
- package/dist/inner-plugins/utils/sdk.d.ts +3 -0
- package/dist/inner-plugins/utils/sdk.js +36 -0
- package/dist/rules/index.d.ts +3 -0
- package/dist/rules/index.js +33 -0
- package/dist/rules/linter.d.ts +13 -0
- package/dist/rules/linter.js +74 -0
- package/dist/rules/rule.d.ts +31 -0
- package/dist/rules/rule.js +140 -0
- package/dist/rules/rules/default-import-check/index.d.ts +4 -0
- package/dist/rules/rules/default-import-check/index.js +124 -0
- package/dist/rules/rules/default-import-check/types.d.ts +4 -0
- package/dist/rules/rules/default-import-check/types.js +16 -0
- package/dist/rules/rules/default-import-check/utils.d.ts +10 -0
- package/dist/rules/rules/default-import-check/utils.js +93 -0
- package/dist/rules/rules/duplicate-package/index.d.ts +4 -0
- package/dist/rules/rules/duplicate-package/index.js +71 -0
- package/dist/rules/rules/duplicate-package/types.d.ts +24 -0
- package/dist/rules/rules/duplicate-package/types.js +51 -0
- package/dist/rules/rules/duplicate-package/utils.d.ts +3 -0
- package/dist/rules/rules/duplicate-package/utils.js +89 -0
- package/dist/rules/rules/ecma-version-check/index.d.ts +4 -0
- package/dist/rules/rules/ecma-version-check/index.js +82 -0
- package/dist/rules/rules/ecma-version-check/types.d.ts +7 -0
- package/dist/rules/rules/ecma-version-check/types.js +16 -0
- package/dist/rules/rules/ecma-version-check/utils.d.ts +2 -0
- package/dist/rules/rules/ecma-version-check/utils.js +31 -0
- package/dist/rules/rules/index.d.ts +1 -0
- package/dist/rules/rules/index.js +37 -0
- package/dist/rules/rules/loader-performance-optimization/index.d.ts +4 -0
- package/dist/rules/rules/loader-performance-optimization/index.js +121 -0
- package/dist/rules/rules/loader-performance-optimization/types.d.ts +22 -0
- package/dist/rules/rules/loader-performance-optimization/types.js +16 -0
- package/dist/rules/rules/loader-performance-optimization/utils.d.ts +1 -0
- package/dist/rules/rules/loader-performance-optimization/utils.js +38 -0
- package/dist/rules/utils.d.ts +3 -0
- package/dist/rules/utils.js +44 -0
- package/dist/types/chunks.d.ts +11 -0
- package/dist/types/chunks.js +16 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +30 -0
- package/dist/types/loader.d.ts +19 -0
- package/dist/types/loader.js +16 -0
- package/dist/types/plugin.d.ts +72 -0
- package/dist/types/plugin.js +16 -0
- package/dist/types/rules.d.ts +7 -0
- package/dist/types/rules.js +16 -0
- package/dist/types/webpack.d.ts +14 -0
- package/dist/types/webpack.js +16 -0
- package/package.json +87 -0
|
@@ -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 utils_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(utils_exports);
|
|
18
|
+
__reExport(utils_exports, require("./loader"), module.exports);
|
|
19
|
+
__reExport(utils_exports, require("./plugin"), module.exports);
|
|
20
|
+
__reExport(utils_exports, require("./sdk"), module.exports);
|
|
21
|
+
__reExport(utils_exports, require("./config"), module.exports);
|
|
22
|
+
__reExport(utils_exports, require("./circleDetect"), module.exports);
|
|
23
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
24
|
+
0 && (module.exports = {
|
|
25
|
+
...require("./loader"),
|
|
26
|
+
...require("./plugin"),
|
|
27
|
+
...require("./sdk"),
|
|
28
|
+
...require("./config"),
|
|
29
|
+
...require("./circleDetect")
|
|
30
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { SDK, Plugin } from '@rsdoctor/types';
|
|
4
|
+
import { ProxyLoaderInternalOptions, ProxyLoaderOptions } from "../../types";
|
|
5
|
+
import { Utils as BuildUtils, Types } from "../../build-utils/build";
|
|
6
|
+
export declare function getInternalLoaderOptions(loaderContext: Plugin.LoaderContext<ProxyLoaderOptions>): ProxyLoaderInternalOptions;
|
|
7
|
+
export declare function getLoaderOptionsWithoutInternalKeys(loaderContext: Plugin.LoaderContext<ProxyLoaderOptions>): import("lodash").Omit<ProxyLoaderOptions, "__l__">;
|
|
8
|
+
export declare function getOriginLoaderModule(loaderContext: Plugin.LoaderContext<ProxyLoaderOptions>): ReturnType<typeof BuildUtils.loadLoaderModule>;
|
|
9
|
+
export declare function shouldSkipLoader(loaderContext: Plugin.LoaderContext<ProxyLoaderOptions>): boolean;
|
|
10
|
+
export declare function interceptLoader<T extends Plugin.BuildRuleSetRule>(rules: T[], loaderPath: string, options: Omit<ProxyLoaderInternalOptions, 'loader' | 'hasOptions'>, cwd?: string, resolveLoader?: Plugin.Configuration['resolve']): T[];
|
|
11
|
+
export declare function reportLoader(ctx: Plugin.LoaderContext<ProxyLoaderOptions>, start: number, startHRTime: [number, number], isPitch: boolean, sync: boolean, code: string, err: Error | null | undefined, res: string | Buffer | null, sourceMap?: Types.SourceMapInput): Promise<SDK.LoaderData>;
|
|
@@ -0,0 +1,201 @@
|
|
|
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 loader_exports = {};
|
|
30
|
+
__export(loader_exports, {
|
|
31
|
+
getInternalLoaderOptions: () => getInternalLoaderOptions,
|
|
32
|
+
getLoaderOptionsWithoutInternalKeys: () => getLoaderOptionsWithoutInternalKeys,
|
|
33
|
+
getOriginLoaderModule: () => getOriginLoaderModule,
|
|
34
|
+
interceptLoader: () => interceptLoader,
|
|
35
|
+
reportLoader: () => reportLoader,
|
|
36
|
+
shouldSkipLoader: () => shouldSkipLoader
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(loader_exports);
|
|
39
|
+
var import_axios = __toESM(require("axios"));
|
|
40
|
+
var import_enhanced_resolve = require("enhanced-resolve");
|
|
41
|
+
var import_fs = __toESM(require("fs"));
|
|
42
|
+
var import_loader_utils = require("loader-utils");
|
|
43
|
+
var import_lodash = require("lodash");
|
|
44
|
+
var import_path = __toESM(require("path"));
|
|
45
|
+
var import_logger = require("@rsdoctor/utils/logger");
|
|
46
|
+
var import_common = require("@rsdoctor/utils/common");
|
|
47
|
+
var import_common2 = require("@rsdoctor/utils/common");
|
|
48
|
+
var import_types = require("@rsdoctor/types");
|
|
49
|
+
var import_error = require("@rsdoctor/utils/error");
|
|
50
|
+
var import_sdk = require("./sdk");
|
|
51
|
+
var import_circleDetect = require("./circleDetect");
|
|
52
|
+
var import_build = require("../../build-utils/build");
|
|
53
|
+
function getInternalLoaderOptions(loaderContext) {
|
|
54
|
+
const options = import_build.Utils.getLoaderOptions(loaderContext);
|
|
55
|
+
return options[import_common.Loader.LoaderInternalPropertyName];
|
|
56
|
+
}
|
|
57
|
+
function getLoaderOptionsWithoutInternalKeys(loaderContext) {
|
|
58
|
+
const options = import_build.Utils.getLoaderOptions(loaderContext);
|
|
59
|
+
const circlePaths = [];
|
|
60
|
+
const loaderOptions = (0, import_lodash.omit)(options, [import_common.Loader.LoaderInternalPropertyName]);
|
|
61
|
+
(0, import_circleDetect.checkCirclePath)(loaderOptions, [], circlePaths, 0);
|
|
62
|
+
if (circlePaths.length > 0) {
|
|
63
|
+
circlePaths.forEach((_path) => {
|
|
64
|
+
if (_path?.length > 0 && loaderOptions[_path[0]] !== "[Circular]") {
|
|
65
|
+
loaderOptions[_path[0]] = "[Circular]";
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return loaderOptions;
|
|
70
|
+
}
|
|
71
|
+
function getOriginLoaderModule(loaderContext) {
|
|
72
|
+
const { loader, cwd } = getInternalLoaderOptions(loaderContext);
|
|
73
|
+
return import_build.Utils.loadLoaderModule(loader, cwd);
|
|
74
|
+
}
|
|
75
|
+
function shouldSkipLoader(loaderContext) {
|
|
76
|
+
const { skipLoaders, cwd, loader } = getInternalLoaderOptions(loaderContext) || {};
|
|
77
|
+
if (!loader)
|
|
78
|
+
return true;
|
|
79
|
+
if (Array.isArray(skipLoaders) && skipLoaders.length) {
|
|
80
|
+
if (skipLoaders.includes(loader))
|
|
81
|
+
return true;
|
|
82
|
+
const loaderName = import_build.Utils.extractLoaderName(loader, cwd);
|
|
83
|
+
if (skipLoaders.includes(loaderName))
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
function interceptLoader(rules, loaderPath, options, cwd = process.cwd(), resolveLoader) {
|
|
89
|
+
const loaderResolver = import_enhanced_resolve.create.sync({
|
|
90
|
+
fileSystem: new import_enhanced_resolve.CachedInputFileSystem(import_fs.default, 4e3),
|
|
91
|
+
conditionNames: ["loader", "require", "node"],
|
|
92
|
+
exportsFields: ["exports"],
|
|
93
|
+
mainFiles: ["index"],
|
|
94
|
+
mainFields: ["loader", "main"],
|
|
95
|
+
extensions: ["js", ".json"],
|
|
96
|
+
modules: ["node_modules"],
|
|
97
|
+
...resolveLoader
|
|
98
|
+
});
|
|
99
|
+
const resolve = (target) => {
|
|
100
|
+
try {
|
|
101
|
+
const result = loaderResolver({}, cwd, target);
|
|
102
|
+
if (typeof result === "string") {
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
} catch (e) {
|
|
106
|
+
}
|
|
107
|
+
return target;
|
|
108
|
+
};
|
|
109
|
+
return import_build.Utils.mapEachRules(rules, (rule) => {
|
|
110
|
+
if (rule?.loader && rule.loader.startsWith("builtin:")) {
|
|
111
|
+
return rule;
|
|
112
|
+
}
|
|
113
|
+
const opts = {
|
|
114
|
+
..."options" in rule ? typeof rule.options === "string" ? JSON.parse(rule.options) : rule.options : {}
|
|
115
|
+
};
|
|
116
|
+
opts[import_common.Loader.LoaderInternalPropertyName] = {
|
|
117
|
+
...options,
|
|
118
|
+
hasOptions: "options" in rule && Boolean(rule.options),
|
|
119
|
+
loader: "loader" in rule ? resolve(rule.loader) : ""
|
|
120
|
+
};
|
|
121
|
+
return {
|
|
122
|
+
...rule,
|
|
123
|
+
loader: loaderPath,
|
|
124
|
+
options: opts
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async function reportLoader(ctx, start, startHRTime, isPitch, sync, code, err, res, sourceMap) {
|
|
129
|
+
const end = import_common2.Time.getCurrentTimestamp(start, startHRTime);
|
|
130
|
+
const { loader, host } = getInternalLoaderOptions(ctx);
|
|
131
|
+
const loaderData = [
|
|
132
|
+
{
|
|
133
|
+
resource: {
|
|
134
|
+
path: ctx.resourcePath,
|
|
135
|
+
query: (0, import_loader_utils.parseQuery)(ctx.resourceQuery || "?"),
|
|
136
|
+
queryRaw: ctx.resourceQuery,
|
|
137
|
+
ext: import_path.default.extname(ctx.resourcePath).slice(1)
|
|
138
|
+
},
|
|
139
|
+
loaders: [
|
|
140
|
+
{
|
|
141
|
+
loader: import_build.Utils.extractLoaderName(loader),
|
|
142
|
+
loaderIndex: ctx.loaderIndex,
|
|
143
|
+
path: loader,
|
|
144
|
+
input: code,
|
|
145
|
+
result: typeof res === "string" || Buffer.isBuffer(res) ? res.toString() : res,
|
|
146
|
+
startAt: start,
|
|
147
|
+
endAt: end,
|
|
148
|
+
options: getLoaderOptionsWithoutInternalKeys(ctx),
|
|
149
|
+
isPitch,
|
|
150
|
+
sync,
|
|
151
|
+
errors: err ? [
|
|
152
|
+
new import_error.DevToolError(code, err.message, {
|
|
153
|
+
controller: { noStack: false, noColor: true },
|
|
154
|
+
stack: err.stack
|
|
155
|
+
})
|
|
156
|
+
] : [],
|
|
157
|
+
pid: process.pid,
|
|
158
|
+
ppid: process.ppid
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
];
|
|
163
|
+
const data = !sourceMap ? {} : (0, import_lodash.isString)(sourceMap) ? JSON.parse(sourceMap) : sourceMap;
|
|
164
|
+
const sourceMapData = {
|
|
165
|
+
version: data.version ?? -1,
|
|
166
|
+
sources: data.sources ?? [],
|
|
167
|
+
names: data.names ?? [],
|
|
168
|
+
sourceRoot: data.sourceRoot,
|
|
169
|
+
sourcesContent: data.sourcesContent,
|
|
170
|
+
mappings: data.mappings,
|
|
171
|
+
file: loaderData[0].resource.path
|
|
172
|
+
};
|
|
173
|
+
const sdk = (0, import_sdk.getSDK)();
|
|
174
|
+
if (sdk && sdk.reportLoader) {
|
|
175
|
+
sdk.reportLoader(loaderData);
|
|
176
|
+
sdk.reportSourceMap(sourceMapData);
|
|
177
|
+
return loaderData;
|
|
178
|
+
}
|
|
179
|
+
await Promise.all([
|
|
180
|
+
import_axios.default.post(`${host}${import_types.SDK.ServerAPI.API.ReportLoader}`, loaderData, {
|
|
181
|
+
timeout: 8888
|
|
182
|
+
}).catch((err2) => {
|
|
183
|
+
(0, import_logger.debug)(() => `${err2.message}`, "[WebpackPlugin.ReportLoader][error]");
|
|
184
|
+
}),
|
|
185
|
+
import_axios.default.post(`${host}${import_types.SDK.ServerAPI.API.ReportSourceMap}`, sourceMapData, {
|
|
186
|
+
timeout: 8888
|
|
187
|
+
}).catch((err2) => {
|
|
188
|
+
(0, import_logger.debug)(() => `${err2.message}`, "[WebpackPlugin.ReportSourceMap][error]");
|
|
189
|
+
})
|
|
190
|
+
]);
|
|
191
|
+
return loaderData;
|
|
192
|
+
}
|
|
193
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
194
|
+
0 && (module.exports = {
|
|
195
|
+
getInternalLoaderOptions,
|
|
196
|
+
getLoaderOptionsWithoutInternalKeys,
|
|
197
|
+
getOriginLoaderModule,
|
|
198
|
+
interceptLoader,
|
|
199
|
+
reportLoader,
|
|
200
|
+
shouldSkipLoader
|
|
201
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Hook } from 'tapable';
|
|
2
|
+
import type { SDK } from '@rsdoctor/types';
|
|
3
|
+
import type { DoctorWebpackSDK } from '@rsdoctor/sdk';
|
|
4
|
+
export declare function reportPluginData(sdk: DoctorWebpackSDK, hook: string, tapName: string, start: number, type: SDK.PluginHookData['type'], _res: unknown, err?: Error): void;
|
|
5
|
+
export declare function interceptPluginHook(sdk: DoctorWebpackSDK, name: string, hook: Hook<any, any>): void;
|
|
@@ -0,0 +1,126 @@
|
|
|
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 plugin_exports = {};
|
|
20
|
+
__export(plugin_exports, {
|
|
21
|
+
interceptPluginHook: () => interceptPluginHook,
|
|
22
|
+
reportPluginData: () => reportPluginData
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
25
|
+
var import_error = require("@rsdoctor/utils/error");
|
|
26
|
+
function reportPluginData(sdk, hook, tapName, start, type, _res, err) {
|
|
27
|
+
const end = Date.now();
|
|
28
|
+
sdk.reportPlugin({
|
|
29
|
+
[hook]: [
|
|
30
|
+
{
|
|
31
|
+
tapName,
|
|
32
|
+
costs: end - start,
|
|
33
|
+
startAt: start,
|
|
34
|
+
endAt: end,
|
|
35
|
+
type,
|
|
36
|
+
result: null,
|
|
37
|
+
// there are circular structure in json
|
|
38
|
+
error: err ? [
|
|
39
|
+
new import_error.DevToolError(`${tapName} ${hook} Error`, err.message, {
|
|
40
|
+
controller: { noStack: false, noColor: true },
|
|
41
|
+
stack: err.stack
|
|
42
|
+
})
|
|
43
|
+
] : []
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function interceptPluginHook(sdk, name, hook) {
|
|
49
|
+
if (!hook.intercept) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
hook.intercept({
|
|
53
|
+
register(tap) {
|
|
54
|
+
const o = tap.fn;
|
|
55
|
+
if (tap.type === "sync") {
|
|
56
|
+
tap.fn = function() {
|
|
57
|
+
const start = Date.now();
|
|
58
|
+
try {
|
|
59
|
+
const res = o.apply(this, arguments);
|
|
60
|
+
reportPluginData(sdk, name, tap.name, start, tap.type, res);
|
|
61
|
+
return res;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
reportPluginData(
|
|
64
|
+
sdk,
|
|
65
|
+
name,
|
|
66
|
+
tap.name,
|
|
67
|
+
start,
|
|
68
|
+
tap.type,
|
|
69
|
+
null,
|
|
70
|
+
error
|
|
71
|
+
);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
} else if (tap.type === "async") {
|
|
76
|
+
tap.fn = async function() {
|
|
77
|
+
const start = Date.now();
|
|
78
|
+
try {
|
|
79
|
+
const res = await o.apply(this, arguments);
|
|
80
|
+
reportPluginData(sdk, name, tap.name, start, tap.type, res);
|
|
81
|
+
return res;
|
|
82
|
+
} catch (error) {
|
|
83
|
+
reportPluginData(
|
|
84
|
+
sdk,
|
|
85
|
+
name,
|
|
86
|
+
tap.name,
|
|
87
|
+
start,
|
|
88
|
+
tap.type,
|
|
89
|
+
null,
|
|
90
|
+
error
|
|
91
|
+
);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
} else if (tap.type === "promise") {
|
|
96
|
+
tap.fn = function() {
|
|
97
|
+
const start = Date.now();
|
|
98
|
+
const isChild = arguments?.[0]?.compiler?.isChild();
|
|
99
|
+
return o.apply(this, arguments).then((res) => {
|
|
100
|
+
if (isChild)
|
|
101
|
+
return res;
|
|
102
|
+
reportPluginData(sdk, name, tap.name, start, tap.type, res);
|
|
103
|
+
return res;
|
|
104
|
+
}).catch((error) => {
|
|
105
|
+
reportPluginData(
|
|
106
|
+
sdk,
|
|
107
|
+
name,
|
|
108
|
+
tap.name,
|
|
109
|
+
start,
|
|
110
|
+
tap.type,
|
|
111
|
+
null,
|
|
112
|
+
error
|
|
113
|
+
);
|
|
114
|
+
throw error;
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
return tap;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
123
|
+
0 && (module.exports = {
|
|
124
|
+
interceptPluginHook,
|
|
125
|
+
reportPluginData
|
|
126
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
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 sdk_exports = {};
|
|
20
|
+
__export(sdk_exports, {
|
|
21
|
+
getSDK: () => getSDK,
|
|
22
|
+
setSDK: () => setSDK
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(sdk_exports);
|
|
25
|
+
let sdk;
|
|
26
|
+
function setSDK(t) {
|
|
27
|
+
sdk = t;
|
|
28
|
+
}
|
|
29
|
+
function getSDK() {
|
|
30
|
+
return sdk;
|
|
31
|
+
}
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
getSDK,
|
|
35
|
+
setSDK
|
|
36
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var rules_exports = {};
|
|
21
|
+
__export(rules_exports, {
|
|
22
|
+
rules: () => import_rules.rules
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(rules_exports);
|
|
25
|
+
__reExport(rules_exports, require("./linter"), module.exports);
|
|
26
|
+
__reExport(rules_exports, require("./rule"), module.exports);
|
|
27
|
+
var import_rules = require("./rules");
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
rules,
|
|
31
|
+
...require("./linter"),
|
|
32
|
+
...require("./rule")
|
|
33
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Linter as LinterType, SDK } from '@rsdoctor/types';
|
|
2
|
+
export { LinterType };
|
|
3
|
+
export declare class Linter<Rules extends LinterType.ExtendRuleData[]> {
|
|
4
|
+
private rules;
|
|
5
|
+
constructor({
|
|
6
|
+
rules,
|
|
7
|
+
extends: extendRules,
|
|
8
|
+
level
|
|
9
|
+
}?: LinterType.Options<Rules>);
|
|
10
|
+
private getRules;
|
|
11
|
+
validate(context: SDK.RuntimeContext): Promise<LinterType.ValidateResult>;
|
|
12
|
+
afterValidate(context: LinterType.InternalRuleCheckerContextForCheckEnd): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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 linter_exports = {};
|
|
20
|
+
__export(linter_exports, {
|
|
21
|
+
Linter: () => Linter,
|
|
22
|
+
LinterType: () => import_types.Linter
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(linter_exports);
|
|
25
|
+
var import_types = require("@rsdoctor/types");
|
|
26
|
+
var import_rule = require("./rule");
|
|
27
|
+
var import_rules = require("./rules");
|
|
28
|
+
var import_utils = require("./utils");
|
|
29
|
+
class Linter {
|
|
30
|
+
constructor({
|
|
31
|
+
rules,
|
|
32
|
+
extends: extendRules,
|
|
33
|
+
level
|
|
34
|
+
} = {}) {
|
|
35
|
+
this.rules = [];
|
|
36
|
+
this.rules = this.getRules(
|
|
37
|
+
rules ?? {},
|
|
38
|
+
extendRules ?? [],
|
|
39
|
+
(0, import_utils.toSeverity)(level ?? "Error", import_types.Linter.Severity.Error)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
getRules(ruleMap, extendRules, filterLevel) {
|
|
43
|
+
const outside = extendRules.map((item) => import_rule.Rule.from(item));
|
|
44
|
+
const rules = import_rules.rules.map((item) => new import_rule.Rule(item)).concat(outside);
|
|
45
|
+
rules.forEach((rule) => {
|
|
46
|
+
if (ruleMap[rule.title]) {
|
|
47
|
+
rule.setOption(ruleMap[rule.title]);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return rules.filter((rule) => rule.match(filterLevel));
|
|
51
|
+
}
|
|
52
|
+
async validate(context) {
|
|
53
|
+
const lintResult = {
|
|
54
|
+
errors: [],
|
|
55
|
+
replace: []
|
|
56
|
+
};
|
|
57
|
+
await Promise.all(
|
|
58
|
+
this.rules.map(async (rule) => {
|
|
59
|
+
const result = await rule.validate(context);
|
|
60
|
+
lintResult.errors.push(...result.errors);
|
|
61
|
+
lintResult.replace.push(...result.replace);
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
return lintResult;
|
|
65
|
+
}
|
|
66
|
+
async afterValidate(context) {
|
|
67
|
+
await Promise.all(this.rules.map((rule) => rule.afterValidate(context)));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
Linter,
|
|
73
|
+
LinterType
|
|
74
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Linter, SDK, Rule as RuleTypes } from '@rsdoctor/types';
|
|
2
|
+
import { LinterType } from './linter';
|
|
3
|
+
type DefaultRuleConfig = Linter.DefaultRuleConfig;
|
|
4
|
+
export declare class Rule<Config = DefaultRuleConfig> implements Linter.RuleMeta<Config> {
|
|
5
|
+
static from<C>(data: Linter.ExtendRuleData<C>): Rule<C>;
|
|
6
|
+
readonly meta: Linter.RuleMeta<Config>;
|
|
7
|
+
private check;
|
|
8
|
+
/**
|
|
9
|
+
* execute when check end
|
|
10
|
+
*/
|
|
11
|
+
private onCheckEnd;
|
|
12
|
+
private _severity;
|
|
13
|
+
private _config?;
|
|
14
|
+
constructor(data: Linter.RuleData<Config>);
|
|
15
|
+
get code(): RuleTypes.RuleMessageCode;
|
|
16
|
+
get title(): string;
|
|
17
|
+
get severity(): Linter.Severity;
|
|
18
|
+
get config(): Config | undefined;
|
|
19
|
+
get category(): "bundle" | "compile" | RuleTypes.RuleMessageCategory | "emo";
|
|
20
|
+
setOption(opt: Linter.RuleConfigItem): void;
|
|
21
|
+
match(level: Linter.Severity): boolean;
|
|
22
|
+
validate(context: SDK.RuntimeContext): Promise<Linter.ValidateResult>;
|
|
23
|
+
afterValidate({
|
|
24
|
+
hooks,
|
|
25
|
+
validateResult,
|
|
26
|
+
data
|
|
27
|
+
}: LinterType.InternalRuleCheckerContextForCheckEnd<Config>): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export declare function defineRule<Title extends Linter.DefaultRuleTitle, T = Linter.DefaultRuleConfig>(ruleCreator: Linter.ExtendRuleConstructor<Title, T>): Linter.ExtendRuleData<T, Title>;
|
|
30
|
+
export declare function defineRule<Title extends Linter.DefaultRuleTitle, T = Linter.DefaultRuleConfig>(ruleCreator: Linter.RuleConstructor<Title, T>): Linter.RuleData<T, Title>;
|
|
31
|
+
export {};
|