@rsdoctor/core 0.0.0-next-20240620044732
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 +22 -0
- package/dist/build-utils/build/chunks/assetsModules.d.ts +4 -0
- package/dist/build-utils/build/chunks/assetsModules.d.ts.map +1 -0
- package/dist/build-utils/build/chunks/assetsModules.js +36 -0
- package/dist/build-utils/build/chunks/chunkTransform.d.ts +5 -0
- package/dist/build-utils/build/chunks/chunkTransform.d.ts.map +1 -0
- package/dist/build-utils/build/chunks/chunkTransform.js +31 -0
- package/dist/build-utils/build/chunks/generateTileGraph.d.ts +11 -0
- package/dist/build-utils/build/chunks/generateTileGraph.d.ts.map +1 -0
- package/dist/build-utils/build/chunks/generateTileGraph.js +71 -0
- package/dist/build-utils/build/chunks/index.d.ts +4 -0
- package/dist/build-utils/build/chunks/index.d.ts.map +1 -0
- package/dist/build-utils/build/chunks/index.js +26 -0
- package/dist/build-utils/build/index.d.ts +5 -0
- package/dist/build-utils/build/index.d.ts.map +1 -0
- package/dist/build-utils/build/index.js +47 -0
- package/dist/build-utils/build/module-graph/index.d.ts +4 -0
- package/dist/build-utils/build/module-graph/index.d.ts.map +1 -0
- package/dist/build-utils/build/module-graph/index.js +26 -0
- package/dist/build-utils/build/module-graph/parser.d.ts +3 -0
- package/dist/build-utils/build/module-graph/parser.d.ts.map +1 -0
- package/dist/build-utils/build/module-graph/parser.js +44 -0
- package/dist/build-utils/build/module-graph/transform.d.ts +5 -0
- package/dist/build-utils/build/module-graph/transform.d.ts.map +1 -0
- package/dist/build-utils/build/module-graph/transform.js +37 -0
- package/dist/build-utils/build/module-graph/treeShaking.d.ts +4 -0
- package/dist/build-utils/build/module-graph/treeShaking.d.ts.map +1 -0
- package/dist/build-utils/build/module-graph/treeShaking.js +132 -0
- package/dist/build-utils/build/module-graph/utils.d.ts +4 -0
- package/dist/build-utils/build/module-graph/utils.d.ts.map +1 -0
- package/dist/build-utils/build/module-graph/utils.js +113 -0
- package/dist/build-utils/build/module-graph/webpack/transform.d.ts +12 -0
- package/dist/build-utils/build/module-graph/webpack/transform.d.ts.map +1 -0
- package/dist/build-utils/build/module-graph/webpack/transform.js +195 -0
- package/dist/build-utils/build/utils/index.d.ts +4 -0
- package/dist/build-utils/build/utils/index.d.ts.map +1 -0
- package/dist/build-utils/build/utils/index.js +26 -0
- package/dist/build-utils/build/utils/loader.d.ts +19 -0
- package/dist/build-utils/build/utils/loader.d.ts.map +1 -0
- package/dist/build-utils/build/utils/loader.js +299 -0
- package/dist/build-utils/build/utils/parseBundle.d.ts +13 -0
- package/dist/build-utils/build/utils/parseBundle.d.ts.map +1 -0
- package/dist/build-utils/build/utils/parseBundle.js +367 -0
- package/dist/build-utils/build/utils/plugin.d.ts +6 -0
- package/dist/build-utils/build/utils/plugin.d.ts.map +1 -0
- package/dist/build-utils/build/utils/plugin.js +63 -0
- package/dist/build-utils/common/chunks/assetsContent.d.ts +5 -0
- package/dist/build-utils/common/chunks/assetsContent.d.ts.map +1 -0
- package/dist/build-utils/common/chunks/assetsContent.js +34 -0
- package/dist/build-utils/common/chunks/assetsModules.d.ts +24 -0
- package/dist/build-utils/common/chunks/assetsModules.d.ts.map +1 -0
- package/dist/build-utils/common/chunks/assetsModules.js +107 -0
- package/dist/build-utils/common/chunks/chunkTransform.d.ts +6 -0
- package/dist/build-utils/common/chunks/chunkTransform.d.ts.map +1 -0
- package/dist/build-utils/common/chunks/chunkTransform.js +73 -0
- package/dist/build-utils/common/chunks/index.d.ts +4 -0
- package/dist/build-utils/common/chunks/index.d.ts.map +1 -0
- package/dist/build-utils/common/chunks/index.js +26 -0
- package/dist/build-utils/common/index.d.ts +6 -0
- package/dist/build-utils/common/index.d.ts.map +1 -0
- package/dist/build-utils/common/index.js +50 -0
- package/dist/build-utils/common/module-graph/compatible.d.ts +10 -0
- package/dist/build-utils/common/module-graph/compatible.d.ts.map +1 -0
- package/dist/build-utils/common/module-graph/compatible.js +63 -0
- package/dist/build-utils/common/module-graph/index.d.ts +4 -0
- package/dist/build-utils/common/module-graph/index.d.ts.map +1 -0
- package/dist/build-utils/common/module-graph/index.js +26 -0
- package/dist/build-utils/common/module-graph/transform.d.ts +8 -0
- package/dist/build-utils/common/module-graph/transform.d.ts.map +1 -0
- package/dist/build-utils/common/module-graph/transform.js +200 -0
- package/dist/build-utils/common/module-graph/utils.d.ts +16 -0
- package/dist/build-utils/common/module-graph/utils.d.ts.map +1 -0
- package/dist/build-utils/common/module-graph/utils.js +62 -0
- package/dist/build-utils/common/trans-utils/index.d.ts +2 -0
- package/dist/build-utils/common/trans-utils/index.d.ts.map +1 -0
- package/dist/build-utils/common/trans-utils/index.js +22 -0
- package/dist/build-utils/common/trans-utils/transStats.d.ts +7 -0
- package/dist/build-utils/common/trans-utils/transStats.d.ts.map +1 -0
- package/dist/build-utils/common/trans-utils/transStats.js +35 -0
- package/dist/build-utils/common/webpack/compatible.d.ts +27 -0
- package/dist/build-utils/common/webpack/compatible.d.ts.map +1 -0
- package/dist/build-utils/common/webpack/compatible.js +181 -0
- package/dist/build-utils/index.d.ts +3 -0
- package/dist/build-utils/index.d.ts.map +1 -0
- package/dist/build-utils/index.js +41 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/inner-plugins/constants.d.ts +7 -0
- package/dist/inner-plugins/constants.d.ts.map +1 -0
- package/dist/inner-plugins/constants.js +52 -0
- package/dist/inner-plugins/index.d.ts +3 -0
- package/dist/inner-plugins/index.d.ts.map +1 -0
- package/dist/inner-plugins/index.js +24 -0
- package/dist/inner-plugins/loaders/proxy.d.ts +5 -0
- package/dist/inner-plugins/loaders/proxy.d.ts.map +1 -0
- package/dist/inner-plugins/loaders/proxy.js +115 -0
- package/dist/inner-plugins/plugins/base.d.ts +14 -0
- package/dist/inner-plugins/plugins/base.d.ts.map +1 -0
- package/dist/inner-plugins/plugins/base.js +45 -0
- package/dist/inner-plugins/plugins/bundle.d.ts +15 -0
- package/dist/inner-plugins/plugins/bundle.d.ts.map +1 -0
- package/dist/inner-plugins/plugins/bundle.js +92 -0
- package/dist/inner-plugins/plugins/bundleTagPlugin.d.ts +7 -0
- package/dist/inner-plugins/plugins/bundleTagPlugin.d.ts.map +1 -0
- package/dist/inner-plugins/plugins/bundleTagPlugin.js +81 -0
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.ts +10 -0
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.ts.map +1 -0
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +126 -0
- package/dist/inner-plugins/plugins/errors.d.ts +12 -0
- package/dist/inner-plugins/plugins/errors.d.ts.map +1 -0
- package/dist/inner-plugins/plugins/errors.js +85 -0
- package/dist/inner-plugins/plugins/index.d.ts +11 -0
- package/dist/inner-plugins/plugins/index.d.ts.map +1 -0
- package/dist/inner-plugins/plugins/index.js +40 -0
- package/dist/inner-plugins/plugins/loader.d.ts +12 -0
- package/dist/inner-plugins/plugins/loader.d.ts.map +1 -0
- package/dist/inner-plugins/plugins/loader.js +161 -0
- package/dist/inner-plugins/plugins/plugins.d.ts +9 -0
- package/dist/inner-plugins/plugins/plugins.d.ts.map +1 -0
- package/dist/inner-plugins/plugins/plugins.js +60 -0
- package/dist/inner-plugins/plugins/progress.d.ts +9 -0
- package/dist/inner-plugins/plugins/progress.d.ts.map +1 -0
- package/dist/inner-plugins/plugins/progress.js +59 -0
- package/dist/inner-plugins/plugins/rules.d.ts +9 -0
- package/dist/inner-plugins/plugins/rules.d.ts.map +1 -0
- package/dist/inner-plugins/plugins/rules.js +85 -0
- package/dist/inner-plugins/plugins/summary.d.ts +15 -0
- package/dist/inner-plugins/plugins/summary.d.ts.map +1 -0
- package/dist/inner-plugins/plugins/summary.js +115 -0
- package/dist/inner-plugins/utils/circleDetect.d.ts +5 -0
- package/dist/inner-plugins/utils/circleDetect.d.ts.map +1 -0
- package/dist/inner-plugins/utils/circleDetect.js +42 -0
- package/dist/inner-plugins/utils/config.d.ts +8 -0
- package/dist/inner-plugins/utils/config.d.ts.map +1 -0
- package/dist/inner-plugins/utils/config.js +151 -0
- package/dist/inner-plugins/utils/index.d.ts +6 -0
- package/dist/inner-plugins/utils/index.d.ts.map +1 -0
- package/dist/inner-plugins/utils/index.js +30 -0
- package/dist/inner-plugins/utils/loader.d.ts +12 -0
- package/dist/inner-plugins/utils/loader.d.ts.map +1 -0
- package/dist/inner-plugins/utils/loader.js +201 -0
- package/dist/inner-plugins/utils/plugin.d.ts +6 -0
- package/dist/inner-plugins/utils/plugin.d.ts.map +1 -0
- package/dist/inner-plugins/utils/plugin.js +126 -0
- package/dist/inner-plugins/utils/sdk.d.ts +4 -0
- package/dist/inner-plugins/utils/sdk.d.ts.map +1 -0
- package/dist/inner-plugins/utils/sdk.js +43 -0
- package/dist/rules/index.d.ts +4 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +33 -0
- package/dist/rules/linter.d.ts +10 -0
- package/dist/rules/linter.d.ts.map +1 -0
- package/dist/rules/linter.js +74 -0
- package/dist/rules/rule.d.ts +28 -0
- package/dist/rules/rule.d.ts.map +1 -0
- package/dist/rules/rule.js +143 -0
- package/dist/rules/rules/default-import-check/index.d.ts +5 -0
- package/dist/rules/rules/default-import-check/index.d.ts.map +1 -0
- package/dist/rules/rules/default-import-check/index.js +124 -0
- package/dist/rules/rules/default-import-check/types.d.ts +5 -0
- package/dist/rules/rules/default-import-check/types.d.ts.map +1 -0
- package/dist/rules/rules/default-import-check/types.js +16 -0
- package/dist/rules/rules/default-import-check/utils.d.ts +11 -0
- package/dist/rules/rules/default-import-check/utils.d.ts.map +1 -0
- package/dist/rules/rules/default-import-check/utils.js +93 -0
- package/dist/rules/rules/duplicate-package/index.d.ts +5 -0
- package/dist/rules/rules/duplicate-package/index.d.ts.map +1 -0
- package/dist/rules/rules/duplicate-package/index.js +71 -0
- package/dist/rules/rules/duplicate-package/types.d.ts +25 -0
- package/dist/rules/rules/duplicate-package/types.d.ts.map +1 -0
- package/dist/rules/rules/duplicate-package/types.js +51 -0
- package/dist/rules/rules/duplicate-package/utils.d.ts +4 -0
- package/dist/rules/rules/duplicate-package/utils.d.ts.map +1 -0
- package/dist/rules/rules/duplicate-package/utils.js +89 -0
- package/dist/rules/rules/ecma-version-check/index.d.ts +5 -0
- package/dist/rules/rules/ecma-version-check/index.d.ts.map +1 -0
- package/dist/rules/rules/ecma-version-check/index.js +82 -0
- package/dist/rules/rules/ecma-version-check/types.d.ts +8 -0
- package/dist/rules/rules/ecma-version-check/types.d.ts.map +1 -0
- package/dist/rules/rules/ecma-version-check/types.js +16 -0
- package/dist/rules/rules/ecma-version-check/utils.d.ts +3 -0
- package/dist/rules/rules/ecma-version-check/utils.d.ts.map +1 -0
- package/dist/rules/rules/ecma-version-check/utils.js +31 -0
- package/dist/rules/rules/index.d.ts +2 -0
- package/dist/rules/rules/index.d.ts.map +1 -0
- package/dist/rules/rules/index.js +37 -0
- package/dist/rules/rules/loader-performance-optimization/index.d.ts +5 -0
- package/dist/rules/rules/loader-performance-optimization/index.d.ts.map +1 -0
- package/dist/rules/rules/loader-performance-optimization/index.js +124 -0
- package/dist/rules/rules/loader-performance-optimization/types.d.ts +23 -0
- package/dist/rules/rules/loader-performance-optimization/types.d.ts.map +1 -0
- package/dist/rules/rules/loader-performance-optimization/types.js +16 -0
- package/dist/rules/rules/loader-performance-optimization/utils.d.ts +2 -0
- package/dist/rules/rules/loader-performance-optimization/utils.d.ts.map +1 -0
- package/dist/rules/rules/loader-performance-optimization/utils.js +38 -0
- package/dist/rules/utils.d.ts +4 -0
- package/dist/rules/utils.d.ts.map +1 -0
- package/dist/rules/utils.js +44 -0
- package/dist/types/chunks.d.ts +12 -0
- package/dist/types/chunks.d.ts.map +1 -0
- package/dist/types/chunks.js +16 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +30 -0
- package/dist/types/loader.d.ts +20 -0
- package/dist/types/loader.d.ts.map +1 -0
- package/dist/types/loader.js +16 -0
- package/dist/types/plugin.d.ts +96 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +16 -0
- package/dist/types/rules.d.ts +8 -0
- package/dist/types/rules.d.ts.map +1 -0
- package/dist/types/rules.js +16 -0
- package/dist/types/webpack.d.ts +15 -0
- package/dist/types/webpack.d.ts.map +1 -0
- package/dist/types/webpack.js +16 -0
- package/package.json +112 -0
|
@@ -0,0 +1,92 @@
|
|
|
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 bundle_exports = {};
|
|
20
|
+
__export(bundle_exports, {
|
|
21
|
+
InternalBundlePlugin: () => InternalBundlePlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(bundle_exports);
|
|
24
|
+
var import_types = require("@rsdoctor/types");
|
|
25
|
+
var import_base = require("./base");
|
|
26
|
+
var import_common = require("../../build-utils/common");
|
|
27
|
+
class InternalBundlePlugin extends import_base.InternalBasePlugin {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.name = "bundle";
|
|
31
|
+
this.map = /* @__PURE__ */ new Map();
|
|
32
|
+
this.thisCompilation = (compilation) => {
|
|
33
|
+
if (compilation.hooks.processAssets && "afterOptimizeAssets" in compilation.hooks) {
|
|
34
|
+
compilation.hooks.afterOptimizeAssets.tap(
|
|
35
|
+
this.tapPostOptions,
|
|
36
|
+
(assets) => {
|
|
37
|
+
Object.keys(assets).forEach((file) => {
|
|
38
|
+
const v = this.ensureAssetContent(file);
|
|
39
|
+
v.content = assets[file].source().toString();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
} else if (compilation.hooks.processAssets && "afterProcessAssets" in compilation.hooks) {
|
|
44
|
+
compilation.hooks.afterProcessAssets.tap(
|
|
45
|
+
this.tapPostOptions,
|
|
46
|
+
() => {
|
|
47
|
+
Object.keys(compilation.assets).forEach((file) => {
|
|
48
|
+
const v = this.ensureAssetContent(file);
|
|
49
|
+
v.content = compilation.assets[file].source().toString();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
} else if ("afterOptimizeChunkAssets" in compilation.hooks) {
|
|
54
|
+
compilation.hooks.afterOptimizeChunkAssets.tap(
|
|
55
|
+
this.tapPostOptions,
|
|
56
|
+
(chunks) => {
|
|
57
|
+
[...chunks].reduce((t, chunk) => t.concat([...chunk.files]), []).forEach((file) => {
|
|
58
|
+
const v = this.ensureAssetContent(file);
|
|
59
|
+
v.content = compilation.assets[file].source().toString();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
this.done = async () => {
|
|
66
|
+
if (this.scheduler.chunkGraph) {
|
|
67
|
+
import_common.Chunks.assetsContents(this.map, this.scheduler.chunkGraph);
|
|
68
|
+
}
|
|
69
|
+
this.sdk.addClientRoutes([
|
|
70
|
+
import_types.Manifest.RsdoctorManifestClientRoutes.ModuleGraph,
|
|
71
|
+
import_types.Manifest.RsdoctorManifestClientRoutes.BundleSize
|
|
72
|
+
]);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
apply(compiler) {
|
|
76
|
+
this.scheduler.ensureModulesChunksGraphApplied(compiler);
|
|
77
|
+
compiler.hooks.compilation.tap(this.tapPostOptions, this.thisCompilation);
|
|
78
|
+
compiler.hooks.done.tapPromise(this.tapPreOptions, this.done.bind(this));
|
|
79
|
+
}
|
|
80
|
+
ensureAssetContent(name) {
|
|
81
|
+
const asset = this.map.get(name);
|
|
82
|
+
if (asset)
|
|
83
|
+
return asset;
|
|
84
|
+
const v = { content: "" };
|
|
85
|
+
this.map.set(name, v);
|
|
86
|
+
return v;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {
|
|
91
|
+
InternalBundlePlugin
|
|
92
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Plugin } from '@rsdoctor/types';
|
|
2
|
+
import { InternalBasePlugin } from './base';
|
|
3
|
+
export declare class InternalBundleTagPlugin<T extends Plugin.BaseCompiler> extends InternalBasePlugin<T> {
|
|
4
|
+
readonly name = "bundleTag";
|
|
5
|
+
apply(compiler: Plugin.BaseCompiler): void;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=bundleTagPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundleTagPlugin.d.ts","sourceRoot":"","sources":["../../../src/inner-plugins/plugins/bundleTagPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAG5C,qBAAa,uBAAuB,CAClC,CAAC,SAAS,MAAM,CAAC,YAAY,CAC7B,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IAC7B,SAAgB,IAAI,eAAe;IAE5B,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,YAAY;CAmD3C"}
|
|
@@ -0,0 +1,81 @@
|
|
|
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 bundleTagPlugin_exports = {};
|
|
20
|
+
__export(bundleTagPlugin_exports, {
|
|
21
|
+
InternalBundleTagPlugin: () => InternalBundleTagPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(bundleTagPlugin_exports);
|
|
24
|
+
var import_path = require("path");
|
|
25
|
+
var import_webpack_sources = require("webpack-sources");
|
|
26
|
+
var import_base = require("./base");
|
|
27
|
+
var import_logger = require("@rsdoctor/utils/logger");
|
|
28
|
+
class InternalBundleTagPlugin extends import_base.InternalBasePlugin {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.name = "bundleTag";
|
|
32
|
+
}
|
|
33
|
+
apply(compiler) {
|
|
34
|
+
const supportBannerPlugin = !!this.options.supports?.banner;
|
|
35
|
+
compiler.hooks.compilation.tap("RsdoctorTagBannerPlugin", (compilation) => {
|
|
36
|
+
compilation.hooks.processAssets.tapPromise(
|
|
37
|
+
{
|
|
38
|
+
name: "RsdoctorTagBannerPlugin",
|
|
39
|
+
stage: -2e3
|
|
40
|
+
},
|
|
41
|
+
async () => {
|
|
42
|
+
if (!compilation.options.plugins.map((p) => p && p.constructor.name).includes("BannerPlugin") && !supportBannerPlugin) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
import_logger.logger.info(
|
|
46
|
+
import_logger.chalk.bgMagenta(
|
|
47
|
+
"Rsdoctor BannerTagPlugin has open. Do not use Rsdoctor on production version."
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
const chunks = compilation.chunks;
|
|
51
|
+
for (let chunk of chunks) {
|
|
52
|
+
for (const file of chunk.files) {
|
|
53
|
+
if (!file || (0, import_path.extname)(file) !== ".js") {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
compilation.updateAsset(
|
|
57
|
+
file,
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
(old) => {
|
|
60
|
+
const concatSource = new import_webpack_sources.ConcatSource();
|
|
61
|
+
let header = "\n console.log('RSDOCTOR_START::');\n";
|
|
62
|
+
let footer = "\n console.log('RSDOCTOR_END::');\n";
|
|
63
|
+
concatSource.add(header);
|
|
64
|
+
concatSource.add(old);
|
|
65
|
+
concatSource.add(footer);
|
|
66
|
+
return concatSource;
|
|
67
|
+
},
|
|
68
|
+
() => {
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
InternalBundleTagPlugin
|
|
81
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RsdoctorPluginInstance } from '../../types';
|
|
2
|
+
import { Linter, Plugin } from '@rsdoctor/types';
|
|
3
|
+
/**
|
|
4
|
+
* @description Generate ModuleGraph and ChunkGraph from stats and webpack module apis;
|
|
5
|
+
* @param {Compiler} compiler
|
|
6
|
+
* @return {*}
|
|
7
|
+
* @memberof RsdoctorWebpackPlugin
|
|
8
|
+
*/
|
|
9
|
+
export declare const ensureModulesChunksGraphFn: (compiler: Plugin.BaseCompiler, _this: RsdoctorPluginInstance<Plugin.BaseCompiler, Linter.ExtendRuleData[]>) => void;
|
|
10
|
+
//# sourceMappingURL=ensureModulesChunkGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureModulesChunkGraph.d.ts","sourceRoot":"","sources":["../../../src/inner-plugins/plugins/ensureModulesChunkGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAuB,MAAM,iBAAiB,CAAC;AAWtE;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,aAC3B,OAAO,YAAY,SACtB,uBAAuB,OAAO,YAAY,EAAE,OAAO,cAAc,EAAE,CAAC,SAsF5E,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
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 ensureModulesChunkGraph_exports = {};
|
|
30
|
+
__export(ensureModulesChunkGraph_exports, {
|
|
31
|
+
ensureModulesChunksGraphFn: () => ensureModulesChunksGraphFn
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(ensureModulesChunkGraph_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_types2 = require("@rsdoctor/types");
|
|
36
|
+
var import_build = require("@rsdoctor/utils/build");
|
|
37
|
+
var import_logger = require("@rsdoctor/utils/logger");
|
|
38
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
39
|
+
var import_build2 = require("../../build-utils/build");
|
|
40
|
+
var import_common = require("../../build-utils/common");
|
|
41
|
+
var import_constants = require("../constants");
|
|
42
|
+
const ensureModulesChunksGraphFn = (compiler, _this) => {
|
|
43
|
+
if (_this._modulesGraphApplied)
|
|
44
|
+
return;
|
|
45
|
+
_this._modulesGraphApplied = true;
|
|
46
|
+
const context = {
|
|
47
|
+
astCache: /* @__PURE__ */ new Map(),
|
|
48
|
+
packagePathMap: /* @__PURE__ */ new Map(),
|
|
49
|
+
getSourceMap: (file) => {
|
|
50
|
+
return _this.sdk.getSourceMap(file);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
compiler.hooks.done.tapPromise(
|
|
54
|
+
(0, import_constants.internalPluginTapPreOptions)("moduleGraph"),
|
|
55
|
+
async (_stats) => {
|
|
56
|
+
const stats = _stats;
|
|
57
|
+
const statsJson = stats.toJson();
|
|
58
|
+
(0, import_logger.debug)(import_build.Process.getMemoryUsageMessage, "[Before Generate ModuleGraph]");
|
|
59
|
+
_this.chunkGraph = import_build2.Chunks.chunkTransform(/* @__PURE__ */ new Map(), statsJson);
|
|
60
|
+
_this.modulesGraph = await import_build2.ModuleGraph.getModuleGraphByStats(
|
|
61
|
+
stats.compilation,
|
|
62
|
+
statsJson,
|
|
63
|
+
process.cwd(),
|
|
64
|
+
_this.chunkGraph,
|
|
65
|
+
_this.options.features,
|
|
66
|
+
context
|
|
67
|
+
);
|
|
68
|
+
(0, import_logger.debug)(import_build.Process.getMemoryUsageMessage, "[After Generate ModuleGraph]");
|
|
69
|
+
if (_this.options.features.treeShaking) {
|
|
70
|
+
_this.modulesGraph = import_build2.ModuleGraph.appendTreeShaking(
|
|
71
|
+
_this.modulesGraph,
|
|
72
|
+
stats.compilation
|
|
73
|
+
) || _this.modulesGraph;
|
|
74
|
+
_this.sdk.addClientRoutes([
|
|
75
|
+
import_types2.Manifest.RsdoctorManifestClientRoutes.TreeShaking
|
|
76
|
+
]);
|
|
77
|
+
(0, import_logger.debug)(
|
|
78
|
+
import_build.Process.getMemoryUsageMessage,
|
|
79
|
+
"[After AppendTreeShaking to ModuleGraph]"
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
const shouldParseBundle = _this.options.supports.parseBundle !== false;
|
|
83
|
+
await getModulesInfosByStats(
|
|
84
|
+
compiler,
|
|
85
|
+
statsJson,
|
|
86
|
+
_this.modulesGraph,
|
|
87
|
+
shouldParseBundle
|
|
88
|
+
);
|
|
89
|
+
(0, import_logger.debug)(import_build.Process.getMemoryUsageMessage, "[After Transform ModuleGraph]");
|
|
90
|
+
_this.modulesGraph && await _this.sdk.reportModuleGraph(_this.modulesGraph);
|
|
91
|
+
await _this.sdk.reportChunkGraph(_this.chunkGraph);
|
|
92
|
+
const reportFilePath = await import_build2.Chunks.generateTileGraph(
|
|
93
|
+
statsJson,
|
|
94
|
+
{
|
|
95
|
+
reportFilename: import_path.default.join(
|
|
96
|
+
import_types2.Constants.RsdoctorOutputFolder,
|
|
97
|
+
import_build2.Chunks.TileGraphReportName
|
|
98
|
+
),
|
|
99
|
+
reportTitle: "bundle-analyzer"
|
|
100
|
+
},
|
|
101
|
+
compiler.outputPath
|
|
102
|
+
);
|
|
103
|
+
reportFilePath && await _this.sdk.reportTileHtml(
|
|
104
|
+
import_fs_extra.default.readFileSync(reportFilePath, "utf-8")
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
async function getModulesInfosByStats(compiler, stats, moduleGraph, parseBundle) {
|
|
110
|
+
if (!moduleGraph) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
const parsedModulesData = await import_build2.Chunks.getAssetsModulesData(
|
|
115
|
+
stats,
|
|
116
|
+
compiler.outputPath,
|
|
117
|
+
parseBundle
|
|
118
|
+
) || {};
|
|
119
|
+
import_common.Chunks.transformAssetsModulesData(parsedModulesData, moduleGraph);
|
|
120
|
+
} catch (e) {
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
+
0 && (module.exports = {
|
|
125
|
+
ensureModulesChunksGraphFn
|
|
126
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
}
|
|
12
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/inner-plugins/plugins/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,qBAAa,2BAA2B,CACtC,CAAC,SAAS,MAAM,CAAC,YAAY,CAC7B,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IAC7B,SAAgB,IAAI,oBAAoB;IAEjC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAIjB,IAAI,UAAiB,OAAO,SAAS,KAAG,QAAQ,IAAI,CAAC,CAiB1D;IAEK,kBAAkB,CACvB,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,QAAQ,EAAE,IAAI,CAAC,mBAAmB,EAClC,KAAK,EAAE,MAAM,OAAO,GAAG,CAAC,UAAU;IAavB,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE;IAW5C,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,EAAE;CAUxD"}
|
|
@@ -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,11 @@
|
|
|
1
|
+
export * from './loader';
|
|
2
|
+
export * from './plugins';
|
|
3
|
+
export * from './errors';
|
|
4
|
+
export * from './progress';
|
|
5
|
+
export * from './summary';
|
|
6
|
+
export * from './base';
|
|
7
|
+
export * from './bundle';
|
|
8
|
+
export * from './ensureModulesChunkGraph';
|
|
9
|
+
export * from './rules';
|
|
10
|
+
export * from './bundleTagPlugin';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/inner-plugins/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 plugins_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(plugins_exports);
|
|
18
|
+
__reExport(plugins_exports, require("./loader"), module.exports);
|
|
19
|
+
__reExport(plugins_exports, require("./plugins"), module.exports);
|
|
20
|
+
__reExport(plugins_exports, require("./errors"), module.exports);
|
|
21
|
+
__reExport(plugins_exports, require("./progress"), module.exports);
|
|
22
|
+
__reExport(plugins_exports, require("./summary"), module.exports);
|
|
23
|
+
__reExport(plugins_exports, require("./base"), module.exports);
|
|
24
|
+
__reExport(plugins_exports, require("./bundle"), module.exports);
|
|
25
|
+
__reExport(plugins_exports, require("./ensureModulesChunkGraph"), module.exports);
|
|
26
|
+
__reExport(plugins_exports, require("./rules"), module.exports);
|
|
27
|
+
__reExport(plugins_exports, require("./bundleTagPlugin"), module.exports);
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
...require("./loader"),
|
|
31
|
+
...require("./plugins"),
|
|
32
|
+
...require("./errors"),
|
|
33
|
+
...require("./progress"),
|
|
34
|
+
...require("./summary"),
|
|
35
|
+
...require("./base"),
|
|
36
|
+
...require("./bundle"),
|
|
37
|
+
...require("./ensureModulesChunkGraph"),
|
|
38
|
+
...require("./rules"),
|
|
39
|
+
...require("./bundleTagPlugin")
|
|
40
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Plugin } from '@rsdoctor/types';
|
|
2
|
+
import { RuleSetRule } from 'webpack';
|
|
3
|
+
import { InternalBasePlugin } from './base';
|
|
4
|
+
export declare class InternalLoaderPlugin<T extends Plugin.BaseCompiler> extends InternalBasePlugin<T> {
|
|
5
|
+
readonly name = "loader";
|
|
6
|
+
readonly internalLoaderPath: string;
|
|
7
|
+
apply(compiler: T): void;
|
|
8
|
+
afterPlugins: (compiler: Plugin.BaseCompiler) => void;
|
|
9
|
+
compilation(compiler: Plugin.BaseCompiler, compilation: Plugin.BaseCompilation): void;
|
|
10
|
+
getInterceptRules(compiler: Plugin.BaseCompiler, rules: RuleSetRule[]): RuleSetRule[];
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/inner-plugins/plugins/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAInD,OAAO,EAA+B,WAAW,EAAE,MAAM,SAAS,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAG5C,qBAAa,oBAAoB,CAC/B,CAAC,SAAS,MAAM,CAAC,YAAY,CAC7B,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IAC7B,SAAgB,IAAI,YAAY;IAEhC,SAAgB,kBAAkB,SAAuC;IAElE,KAAK,CAAC,QAAQ,EAAE,CAAC;IAUjB,YAAY,aAAc,OAAO,YAAY,UAYlD;IAEK,WAAW,CAChB,QAAQ,EAAE,MAAM,CAAC,YAAY,EAC7B,WAAW,EAAE,MAAM,CAAC,eAAe;IA4G9B,iBAAiB,CACtB,QAAQ,EAAE,MAAM,CAAC,YAAY,EAC7B,KAAK,EAAE,WAAW,EAAE;CAcvB"}
|
|
@@ -0,0 +1,161 @@
|
|
|
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
|
+
InternalLoaderPlugin: () => InternalLoaderPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(loader_exports);
|
|
34
|
+
var import_types = require("@rsdoctor/types");
|
|
35
|
+
var import_common = require("@rsdoctor/utils/common");
|
|
36
|
+
var import_lodash = require("lodash");
|
|
37
|
+
var import_utils = require("../utils");
|
|
38
|
+
var import_base = require("./base");
|
|
39
|
+
class InternalLoaderPlugin extends import_base.InternalBasePlugin {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
this.name = "loader";
|
|
43
|
+
this.internalLoaderPath = require.resolve("../loaders/proxy");
|
|
44
|
+
this.afterPlugins = (compiler) => {
|
|
45
|
+
if (compiler.isChild())
|
|
46
|
+
return;
|
|
47
|
+
compiler.options.module.rules = this.getInterceptRules(
|
|
48
|
+
compiler,
|
|
49
|
+
compiler.options.module.rules
|
|
50
|
+
);
|
|
51
|
+
this.sdk.addClientRoutes([
|
|
52
|
+
import_types.Manifest.RsdoctorManifestClientRoutes.WebpackLoaders
|
|
53
|
+
]);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
apply(compiler) {
|
|
57
|
+
compiler.hooks.afterPlugins.tap(this.tapPostOptions, this.afterPlugins);
|
|
58
|
+
compiler.hooks.compilation.tap(
|
|
59
|
+
this.tapPreOptions,
|
|
60
|
+
this.compilation.bind(this, compiler)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
compilation(compiler, compilation) {
|
|
64
|
+
if (compiler.isChild())
|
|
65
|
+
return;
|
|
66
|
+
const wrapper = (callback) => (loaderContext, module2) => {
|
|
67
|
+
const proxyLoaders = module2.loaders || loaderContext?.loaders || [];
|
|
68
|
+
const originLoaders = proxyLoaders.map((loader) => {
|
|
69
|
+
const opts = loader.options || {};
|
|
70
|
+
if (opts[import_common.Loader.LoaderInternalPropertyName]) {
|
|
71
|
+
return {
|
|
72
|
+
...loader,
|
|
73
|
+
loader: opts[import_common.Loader.LoaderInternalPropertyName].loader,
|
|
74
|
+
options: (0, import_lodash.omit)(opts, import_common.Loader.LoaderInternalPropertyName)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return loader;
|
|
78
|
+
});
|
|
79
|
+
const newLoaders = (0, import_lodash.cloneDeep)(originLoaders);
|
|
80
|
+
if (typeof compiler.options.cache === "object" && "version" in compiler.options.cache && typeof compiler.options.cache.version === "string" && compiler.options.cache.version.indexOf("next/dist/build") > -1) {
|
|
81
|
+
callback(loaderContext, module2);
|
|
82
|
+
} else {
|
|
83
|
+
const proxyModule = new Proxy(module2, {
|
|
84
|
+
get(target, p, receiver) {
|
|
85
|
+
if (p === "loaders")
|
|
86
|
+
return newLoaders;
|
|
87
|
+
return Reflect.get(target, p, receiver);
|
|
88
|
+
},
|
|
89
|
+
set(target, p, newValue, receiver) {
|
|
90
|
+
const _newValue = (0, import_lodash.cloneDeep)(newValue);
|
|
91
|
+
if (p === "loaders") {
|
|
92
|
+
if (Array.isArray(_newValue)) {
|
|
93
|
+
newLoaders.length = 0;
|
|
94
|
+
_newValue.forEach((e) => {
|
|
95
|
+
newLoaders.push(e);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return Reflect.set(target, p, _newValue, receiver);
|
|
100
|
+
},
|
|
101
|
+
deleteProperty(target, p) {
|
|
102
|
+
return Reflect.deleteProperty(target, p);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
callback(loaderContext, proxyModule);
|
|
106
|
+
}
|
|
107
|
+
if (!(0, import_lodash.isEqual)(originLoaders, newLoaders)) {
|
|
108
|
+
const rules = this.getInterceptRules(
|
|
109
|
+
compiler,
|
|
110
|
+
newLoaders.map((e) => {
|
|
111
|
+
return {
|
|
112
|
+
loader: e.loader,
|
|
113
|
+
options: e.options
|
|
114
|
+
};
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
module2.loaders = rules.map((e, i) => {
|
|
118
|
+
return {
|
|
119
|
+
...newLoaders[i],
|
|
120
|
+
loader: e.loader,
|
|
121
|
+
options: e.options
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const interceptor = {
|
|
127
|
+
register(tap) {
|
|
128
|
+
const originFn = tap.fn;
|
|
129
|
+
if (typeof originFn === "function") {
|
|
130
|
+
tap.fn = wrapper(originFn);
|
|
131
|
+
}
|
|
132
|
+
return tap;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
if (compiler.webpack?.NormalModule?.getCompilationHooks) {
|
|
136
|
+
compiler.webpack.NormalModule.getCompilationHooks(
|
|
137
|
+
compilation
|
|
138
|
+
).loader.intercept(interceptor);
|
|
139
|
+
} else if ("normalModuleLoader" in compilation.hooks) {
|
|
140
|
+
"normalModuleLoader" in compilation.hooks && compilation.hooks.normalModuleLoader.intercept(interceptor);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
getInterceptRules(compiler, rules) {
|
|
144
|
+
return (0, import_utils.interceptLoader)(
|
|
145
|
+
rules,
|
|
146
|
+
this.internalLoaderPath,
|
|
147
|
+
{
|
|
148
|
+
cwd: compiler.context || process.cwd(),
|
|
149
|
+
host: this.sdk.server.origin,
|
|
150
|
+
skipLoaders: this.options.loaderInterceptorOptions.skipLoaders
|
|
151
|
+
// not implement
|
|
152
|
+
},
|
|
153
|
+
this.sdk.root,
|
|
154
|
+
"resolveLoader" in compiler.options ? compiler.options.resolveLoader : {}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
159
|
+
0 && (module.exports = {
|
|
160
|
+
InternalLoaderPlugin
|
|
161
|
+
});
|