@rsdoctor/webpack-plugin 1.2.3 → 1.2.4-beta.1

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.
@@ -4,4 +4,3 @@ export declare const pluginTapPostOptions: Tap;
4
4
  export declare const pluginTapPreOptions: Tap;
5
5
  export declare const internalPluginTapPreOptions: (namespace: string) => Tap;
6
6
  export declare const internalPluginTapPostOptions: (namespace: string) => Tap;
7
- //# sourceMappingURL=constants.d.ts.map
package/dist/index.cjs ADDED
@@ -0,0 +1,236 @@
1
+ "use strict";
2
+ let globalController, __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
3
+ var __webpack_require__ = {};
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module.default : ()=>module;
6
+ return __webpack_require__.d(getter, {
7
+ a: getter
8
+ }), getter;
9
+ }, __webpack_require__.d = (exports1, definition)=>{
10
+ for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
11
+ enumerable: !0,
12
+ get: definition[key]
13
+ });
14
+ }, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
15
+ 'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
16
+ value: 'Module'
17
+ }), Object.defineProperty(exports1, '__esModule', {
18
+ value: !0
19
+ });
20
+ };
21
+ var __webpack_exports__ = {};
22
+ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
23
+ RsdoctorWebpackMultiplePlugin: ()=>RsdoctorWebpackMultiplePlugin,
24
+ LinterType: ()=>rules_namespaceObject.LinterType,
25
+ RsdoctorWebpackPlugin: ()=>RsdoctorWebpackPlugin,
26
+ defineRule: ()=>rules_namespaceObject.defineRule
27
+ });
28
+ let build_utils_namespaceObject = require("@rsdoctor/core/build-utils"), plugins_namespaceObject = require("@rsdoctor/core/plugins"), graph_namespaceObject = require("@rsdoctor/graph"), sdk_namespaceObject = require("@rsdoctor/sdk"), types_namespaceObject = require("@rsdoctor/types"), build_namespaceObject = require("@rsdoctor/utils/build"), common_namespaceObject = require("@rsdoctor/utils/common"), logger_namespaceObject = require("@rsdoctor/utils/logger"), pluginTapName = 'RsdoctorWebpackPlugin', pluginTapPostOptions = {
29
+ name: pluginTapName,
30
+ stage: 999
31
+ }, pluginTapPreOptions = null, internalPluginTapPreOptions = (namespace)=>({
32
+ name: `${pluginTapName}:${namespace}`,
33
+ stage: -998
34
+ }), internalPluginTapPostOptions = (namespace)=>({
35
+ name: `${pluginTapName}:${namespace}`,
36
+ stage: 1000
37
+ }), external_path_namespaceObject = require("path");
38
+ var external_path_default = __webpack_require__.n(external_path_namespaceObject);
39
+ class RsdoctorResolverPlugin {
40
+ options;
41
+ sdk;
42
+ tapOptions = {
43
+ name: 'RsdoctorResolverPlugin'
44
+ };
45
+ contextMap = new Map();
46
+ constructor(options, sdk){
47
+ this.options = options, this.sdk = sdk;
48
+ }
49
+ getResolverData(context, params) {
50
+ let ctx = this.contextMap.get(context.issuer);
51
+ if (!ctx) return;
52
+ let { request, query, result, error, stacks } = params, [start, startHRTime] = ctx, data = {
53
+ isEntry: !!context.issuer,
54
+ issuerPath: context.issuer || '',
55
+ request,
56
+ startAt: start,
57
+ endAt: common_namespaceObject.Time.getCurrentTimestamp(start, startHRTime),
58
+ pid: process.pid,
59
+ ppid: process.ppid
60
+ };
61
+ return query && (data.query = query), result && (data.result = result), error && (data.error = error, data.stacks = stacks || []), data;
62
+ }
63
+ getResolveStackData(request, path, name = 'anonymous') {
64
+ let data = {
65
+ name,
66
+ path
67
+ };
68
+ return [
69
+ 'request',
70
+ 'query',
71
+ 'fragment',
72
+ 'file',
73
+ 'module',
74
+ 'directory',
75
+ 'internal'
76
+ ].forEach((key)=>{
77
+ request[key] && (data[key] = request[key]);
78
+ }), data;
79
+ }
80
+ getResolveRequest(request, ctx) {
81
+ if (request) return request;
82
+ if (ctx?.stack) {
83
+ let [target] = [
84
+ ...ctx.stack
85
+ ].map((e)=>e.split(' ').map((e)=>e.trim())).filter((e)=>e.length > 2);
86
+ if (target) return target[target.length - 1];
87
+ }
88
+ return '';
89
+ }
90
+ apply(resolver) {
91
+ resolver.hooks.result.tap(this.tapOptions, (request, resolveCtx)=>{
92
+ let { context } = request;
93
+ if (this.contextMap.get(context.issuer)) {
94
+ let data = this.getResolverData(context, {
95
+ request: this.getResolveRequest(request.request, resolveCtx),
96
+ query: request.query,
97
+ result: request.path
98
+ });
99
+ data && this.sdk.reportResolver([
100
+ data
101
+ ]);
102
+ }
103
+ }), resolver.hooks.noResolve.tap(this.tapOptions, (request, error)=>{
104
+ let { context } = request;
105
+ if (context.issuer) {
106
+ let resolvedPaths = new Set(error.details.split('\n').map((e)=>e.trim().split(' ')[0]).filter((e)=>external_path_default().isAbsolute(e)));
107
+ if (resolvedPaths.size && this.contextMap.has(context.issuer)) {
108
+ let stacks = [
109
+ ...resolvedPaths
110
+ ].map((e)=>this.getResolveStackData(request, e, 'noResolve')), data = this.getResolverData(context, {
111
+ request: this.getResolveRequest(request.request),
112
+ query: request.query,
113
+ error,
114
+ stacks
115
+ });
116
+ data && this.sdk.reportResolver([
117
+ data
118
+ ]);
119
+ }
120
+ }
121
+ }), resolver.hooks.resolveStep.tap(this.tapOptions, (_, request)=>{
122
+ let { context } = request;
123
+ context.issuer && !this.contextMap.has(context.issuer) && this.contextMap.set(context.issuer, [
124
+ Date.now(),
125
+ process.hrtime()
126
+ ]);
127
+ });
128
+ }
129
+ }
130
+ class InternalResolverPlugin extends plugins_namespaceObject.InternalBasePlugin {
131
+ name = 'resolver';
132
+ apply(compiler) {
133
+ this.scheduler.ensureModulesChunksGraphApplied(compiler), compiler.hooks.afterPlugins.tap(this.tapPostOptions, this.afterPlugins);
134
+ }
135
+ afterPlugins = (compiler)=>{
136
+ compiler.isChild() || (compiler.options.resolve.plugins = (compiler.options.resolve.plugins ?? []).concat(new RsdoctorResolverPlugin({}, this.sdk)), this.sdk.addClientRoutes([
137
+ types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.ModuleResolve
138
+ ]));
139
+ };
140
+ }
141
+ class RsdoctorWebpackPlugin {
142
+ name = pluginTapName;
143
+ options;
144
+ sdk;
145
+ isRsdoctorPlugin;
146
+ modulesGraph;
147
+ _bootstrapTask;
148
+ browserIsOpened = !1;
149
+ chunkGraph;
150
+ constructor(options){
151
+ this.options = (0, plugins_namespaceObject.normalizeUserConfig)(options);
152
+ let { port, output, innerClientPath, printLog, sdkInstance } = this.options;
153
+ this.sdk = sdkInstance ?? new sdk_namespaceObject.RsdoctorSDK({
154
+ port: port,
155
+ name: pluginTapName,
156
+ root: process.cwd(),
157
+ type: output.reportCodeType,
158
+ config: {
159
+ innerClientPath: innerClientPath,
160
+ printLog: printLog,
161
+ mode: output.mode,
162
+ brief: output.mode === types_namespaceObject.SDK.IMode[types_namespaceObject.SDK.IMode.brief] && output.options || void 0
163
+ }
164
+ }), this.modulesGraph = new graph_namespaceObject.ModuleGraph(), this.chunkGraph = new graph_namespaceObject.ChunkGraph(), this.isRsdoctorPlugin = !0;
165
+ }
166
+ apply(compiler) {
167
+ this._bootstrapTask || (this._bootstrapTask = this.sdk.bootstrap()), (0, plugins_namespaceObject.setSDK)(this.sdk), new plugins_namespaceObject.InternalSummaryPlugin(this).apply(compiler), this.options.features.loader && (new build_utils_namespaceObject.Loader.ProbeLoaderPlugin().apply(compiler), this.sdk.addClientRoutes([
168
+ types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.WebpackLoaders
169
+ ]), common_namespaceObject.Loader.isVue(compiler) || new plugins_namespaceObject.InternalLoaderPlugin(this).apply(compiler)), this.options.features.resolver && new InternalResolverPlugin(this).apply(compiler), this.options.features.plugins && new plugins_namespaceObject.InternalPluginsPlugin(this).apply(compiler), this.options.features.bundle && (new plugins_namespaceObject.InternalBundlePlugin(this).apply(compiler), new plugins_namespaceObject.InternalBundleTagPlugin(this).apply(compiler)), new plugins_namespaceObject.InternalErrorReporterPlugin(this).apply(compiler), new plugins_namespaceObject.InternalRulesPlugin(this).apply(compiler), new plugins_namespaceObject.InternalProgressPlugin(this).apply(compiler), compiler.hooks.afterPlugins.tap(pluginTapPostOptions, this.afterPlugins), compiler.hooks.watchRun.tapPromise(pluginTapPostOptions, this.beforeRun), compiler.hooks.beforeRun.tapPromise(pluginTapPostOptions, this.beforeRun), compiler.hooks.done.tapPromise({
170
+ ...pluginTapPostOptions,
171
+ stage: pluginTapPostOptions.stage + 100
172
+ }, this.done.bind(this));
173
+ }
174
+ afterPlugins = (compiler)=>{
175
+ if (compiler.isChild()) return;
176
+ let configuration = (0, plugins_namespaceObject.processCompilerConfig)(compiler.options), rspackVersion = 'rspackVersion' in compiler.webpack ? compiler.webpack.rspackVersion : void 0, webpackVersion = compiler.webpack?.version;
177
+ this.sdk.reportConfiguration({
178
+ name: rspackVersion ? 'rspack' : 'webpack',
179
+ version: rspackVersion || webpackVersion || 'unknown',
180
+ config: configuration,
181
+ root: (0, sdk_namespaceObject.findRoot)() || ''
182
+ }), configuration.name && this.sdk.setName(configuration.name);
183
+ };
184
+ beforeRun = async (compiler)=>{
185
+ compiler.isChild() || await this._bootstrapTask.then(()=>{
186
+ this.options.disableClientServer || this.browserIsOpened || this.options.output.mode === types_namespaceObject.SDK.IMode[types_namespaceObject.SDK.IMode.brief] || (this.browserIsOpened = !0, this.sdk.server.openClientPage());
187
+ });
188
+ };
189
+ ensureModulesChunksGraphApplied(compiler) {
190
+ (0, plugins_namespaceObject.ensureModulesChunksGraphFn)(compiler, this);
191
+ }
192
+ done = async ()=>{
193
+ try {
194
+ this.sdk.server.broadcast(), logger_namespaceObject.logger.debug(`${build_namespaceObject.Process.getMemoryUsageMessage()}, '[Before Write Manifest]'`), await this.sdk.writeStore(), logger_namespaceObject.logger.debug(`${build_namespaceObject.Process.getMemoryUsageMessage()}, '[After Write Manifest]'`), this.options.disableClientServer ? (await this.sdk.dispose(), logger_namespaceObject.logger.debug(`${build_namespaceObject.Process.getMemoryUsageMessage()}, '[After SDK Dispose]'`)) : this.options.output.mode !== types_namespaceObject.SDK.IMode[types_namespaceObject.SDK.IMode.brief] || this.options.disableClientServer || (0, plugins_namespaceObject.handleBriefModeReport)(this.sdk, this.options, this.options.disableClientServer);
195
+ } catch (e) {
196
+ console.error("[Rsdoctor] Webpack plugin this.done error", e);
197
+ }
198
+ };
199
+ }
200
+ class RsdoctorWebpackMultiplePlugin extends RsdoctorWebpackPlugin {
201
+ controller;
202
+ constructor(options = {}){
203
+ let controller = (()=>{
204
+ if (globalController) return globalController;
205
+ let controller = new sdk_namespaceObject.RsdoctorSDKController();
206
+ return globalController = controller, controller;
207
+ })(), normallizedOptions = (0, plugins_namespaceObject.normalizeUserConfig)(options);
208
+ super({
209
+ ...options,
210
+ sdkInstance: controller.createSlave({
211
+ name: options.name || 'Builder',
212
+ stage: options.stage,
213
+ extraConfig: {
214
+ innerClientPath: normallizedOptions.innerClientPath,
215
+ printLog: normallizedOptions.printLog,
216
+ mode: normallizedOptions.output.mode ? normallizedOptions.output.mode : void 0,
217
+ brief: normallizedOptions.output.mode === types_namespaceObject.SDK.IMode[types_namespaceObject.SDK.IMode.brief] && normallizedOptions.output.options || void 0
218
+ },
219
+ type: normallizedOptions.output.reportCodeType
220
+ })
221
+ }), this.controller = controller;
222
+ }
223
+ apply(compiler) {
224
+ 'dependencies' in compiler.options && (this.sdk.dependencies = compiler.options.dependencies), super.apply(compiler);
225
+ }
226
+ }
227
+ let rules_namespaceObject = require("@rsdoctor/core/rules");
228
+ for(var __webpack_i__ in exports.LinterType = __webpack_exports__.LinterType, exports.RsdoctorWebpackMultiplePlugin = __webpack_exports__.RsdoctorWebpackMultiplePlugin, exports.RsdoctorWebpackPlugin = __webpack_exports__.RsdoctorWebpackPlugin, exports.defineRule = __webpack_exports__.defineRule, __webpack_exports__)-1 === [
229
+ "LinterType",
230
+ "RsdoctorWebpackMultiplePlugin",
231
+ "RsdoctorWebpackPlugin",
232
+ "defineRule"
233
+ ].indexOf(__webpack_i__) && (exports[__webpack_i__] = __webpack_exports__[__webpack_i__]);
234
+ Object.defineProperty(exports, '__esModule', {
235
+ value: !0
236
+ });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './plugin';
2
2
  export * from './multiple';
3
3
  export { defineRule, LinterType } from '@rsdoctor/core/rules';
4
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,90 +1,204 @@
1
- "use strict";
2
- var __webpack_modules__ = {
3
- "./multiple": function(module) {
4
- module.exports = require("./multiple.js");
5
- },
6
- "./plugin": function(module) {
7
- module.exports = require("./plugin.js");
8
- },
9
- "@rsdoctor/core/rules": function(module) {
10
- module.exports = require("@rsdoctor/core/rules");
11
- }
1
+ let globalController;
2
+ import { Loader } from "@rsdoctor/core/build-utils";
3
+ import { InternalBasePlugin, InternalBundlePlugin, InternalBundleTagPlugin, InternalErrorReporterPlugin, InternalLoaderPlugin, InternalPluginsPlugin, InternalProgressPlugin, InternalRulesPlugin, InternalSummaryPlugin, ensureModulesChunksGraphFn, handleBriefModeReport, normalizeUserConfig, processCompilerConfig, setSDK } from "@rsdoctor/core/plugins";
4
+ import { ChunkGraph, ModuleGraph } from "@rsdoctor/graph";
5
+ import { RsdoctorSDK, RsdoctorSDKController, findRoot } from "@rsdoctor/sdk";
6
+ import { Manifest, SDK } from "@rsdoctor/types";
7
+ import { Process } from "@rsdoctor/utils/build";
8
+ import { Loader as common_Loader, Time } from "@rsdoctor/utils/common";
9
+ import { logger } from "@rsdoctor/utils/logger";
10
+ import path_0 from "path";
11
+ import { LinterType, defineRule } from "@rsdoctor/core/rules";
12
+ let pluginTapName = 'RsdoctorWebpackPlugin', pluginTapPostOptions = {
13
+ name: pluginTapName,
14
+ stage: 999
12
15
  };
13
- var __webpack_module_cache__ = {};
14
- function __webpack_require__(moduleId) {
15
- var cachedModule = __webpack_module_cache__[moduleId];
16
- if (void 0 !== cachedModule) return cachedModule.exports;
17
- var module = __webpack_module_cache__[moduleId] = {
18
- exports: {}
16
+ class RsdoctorResolverPlugin {
17
+ options;
18
+ sdk;
19
+ tapOptions = {
20
+ name: 'RsdoctorResolverPlugin'
19
21
  };
20
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
21
- return module.exports;
22
- }
23
- (()=>{
24
- __webpack_require__.n = (module)=>{
25
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
26
- __webpack_require__.d(getter, {
27
- a: getter
22
+ contextMap = new Map();
23
+ constructor(options, sdk){
24
+ this.options = options, this.sdk = sdk;
25
+ }
26
+ getResolverData(context, params) {
27
+ let ctx = this.contextMap.get(context.issuer);
28
+ if (!ctx) return;
29
+ let { request, query, result, error, stacks } = params, [start, startHRTime] = ctx, data = {
30
+ isEntry: !!context.issuer,
31
+ issuerPath: context.issuer || '',
32
+ request,
33
+ startAt: start,
34
+ endAt: Time.getCurrentTimestamp(start, startHRTime),
35
+ pid: process.pid,
36
+ ppid: process.ppid
37
+ };
38
+ return query && (data.query = query), result && (data.result = result), error && (data.error = error, data.stacks = stacks || []), data;
39
+ }
40
+ getResolveStackData(request, path, name = 'anonymous') {
41
+ let data = {
42
+ name,
43
+ path
44
+ };
45
+ return [
46
+ 'request',
47
+ 'query',
48
+ 'fragment',
49
+ 'file',
50
+ 'module',
51
+ 'directory',
52
+ 'internal'
53
+ ].forEach((key)=>{
54
+ request[key] && (data[key] = request[key]);
55
+ }), data;
56
+ }
57
+ getResolveRequest(request, ctx) {
58
+ if (request) return request;
59
+ if (ctx?.stack) {
60
+ let [target] = [
61
+ ...ctx.stack
62
+ ].map((e)=>e.split(' ').map((e)=>e.trim())).filter((e)=>e.length > 2);
63
+ if (target) return target[target.length - 1];
64
+ }
65
+ return '';
66
+ }
67
+ apply(resolver) {
68
+ resolver.hooks.result.tap(this.tapOptions, (request, resolveCtx)=>{
69
+ let { context } = request;
70
+ if (this.contextMap.get(context.issuer)) {
71
+ let data = this.getResolverData(context, {
72
+ request: this.getResolveRequest(request.request, resolveCtx),
73
+ query: request.query,
74
+ result: request.path
75
+ });
76
+ data && this.sdk.reportResolver([
77
+ data
78
+ ]);
79
+ }
80
+ }), resolver.hooks.noResolve.tap(this.tapOptions, (request, error)=>{
81
+ let { context } = request;
82
+ if (context.issuer) {
83
+ let resolvedPaths = new Set(error.details.split('\n').map((e)=>e.trim().split(' ')[0]).filter((e)=>path_0.isAbsolute(e)));
84
+ if (resolvedPaths.size && this.contextMap.has(context.issuer)) {
85
+ let stacks = [
86
+ ...resolvedPaths
87
+ ].map((e)=>this.getResolveStackData(request, e, 'noResolve')), data = this.getResolverData(context, {
88
+ request: this.getResolveRequest(request.request),
89
+ query: request.query,
90
+ error,
91
+ stacks
92
+ });
93
+ data && this.sdk.reportResolver([
94
+ data
95
+ ]);
96
+ }
97
+ }
98
+ }), resolver.hooks.resolveStep.tap(this.tapOptions, (_, request)=>{
99
+ let { context } = request;
100
+ context.issuer && !this.contextMap.has(context.issuer) && this.contextMap.set(context.issuer, [
101
+ Date.now(),
102
+ process.hrtime()
103
+ ]);
28
104
  });
29
- return getter;
105
+ }
106
+ }
107
+ class InternalResolverPlugin extends InternalBasePlugin {
108
+ name = 'resolver';
109
+ apply(compiler) {
110
+ this.scheduler.ensureModulesChunksGraphApplied(compiler), compiler.hooks.afterPlugins.tap(this.tapPostOptions, this.afterPlugins);
111
+ }
112
+ afterPlugins = (compiler)=>{
113
+ compiler.isChild() || (compiler.options.resolve.plugins = (compiler.options.resolve.plugins ?? []).concat(new RsdoctorResolverPlugin({}, this.sdk)), this.sdk.addClientRoutes([
114
+ Manifest.RsdoctorManifestClientRoutes.ModuleResolve
115
+ ]));
30
116
  };
31
- })();
32
- (()=>{
33
- __webpack_require__.d = (exports1, definition)=>{
34
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
35
- enumerable: true,
36
- get: definition[key]
37
- });
117
+ }
118
+ class RsdoctorWebpackPlugin {
119
+ name = pluginTapName;
120
+ options;
121
+ sdk;
122
+ isRsdoctorPlugin;
123
+ modulesGraph;
124
+ _bootstrapTask;
125
+ browserIsOpened = !1;
126
+ chunkGraph;
127
+ constructor(options){
128
+ this.options = normalizeUserConfig(options);
129
+ let { port, output, innerClientPath, printLog, sdkInstance } = this.options;
130
+ this.sdk = sdkInstance ?? new RsdoctorSDK({
131
+ port: port,
132
+ name: pluginTapName,
133
+ root: process.cwd(),
134
+ type: output.reportCodeType,
135
+ config: {
136
+ innerClientPath: innerClientPath,
137
+ printLog: printLog,
138
+ mode: output.mode,
139
+ brief: output.mode === SDK.IMode[SDK.IMode.brief] && output.options || void 0
140
+ }
141
+ }), this.modulesGraph = new ModuleGraph(), this.chunkGraph = new ChunkGraph(), this.isRsdoctorPlugin = !0;
142
+ }
143
+ apply(compiler) {
144
+ this._bootstrapTask || (this._bootstrapTask = this.sdk.bootstrap()), setSDK(this.sdk), new InternalSummaryPlugin(this).apply(compiler), this.options.features.loader && (new Loader.ProbeLoaderPlugin().apply(compiler), this.sdk.addClientRoutes([
145
+ Manifest.RsdoctorManifestClientRoutes.WebpackLoaders
146
+ ]), common_Loader.isVue(compiler) || new InternalLoaderPlugin(this).apply(compiler)), this.options.features.resolver && new InternalResolverPlugin(this).apply(compiler), this.options.features.plugins && new InternalPluginsPlugin(this).apply(compiler), this.options.features.bundle && (new InternalBundlePlugin(this).apply(compiler), new InternalBundleTagPlugin(this).apply(compiler)), new InternalErrorReporterPlugin(this).apply(compiler), new InternalRulesPlugin(this).apply(compiler), new InternalProgressPlugin(this).apply(compiler), compiler.hooks.afterPlugins.tap(pluginTapPostOptions, this.afterPlugins), compiler.hooks.watchRun.tapPromise(pluginTapPostOptions, this.beforeRun), compiler.hooks.beforeRun.tapPromise(pluginTapPostOptions, this.beforeRun), compiler.hooks.done.tapPromise({
147
+ ...pluginTapPostOptions,
148
+ stage: pluginTapPostOptions.stage + 100
149
+ }, this.done.bind(this));
150
+ }
151
+ afterPlugins = (compiler)=>{
152
+ if (compiler.isChild()) return;
153
+ let configuration = processCompilerConfig(compiler.options), rspackVersion = 'rspackVersion' in compiler.webpack ? compiler.webpack.rspackVersion : void 0, webpackVersion = compiler.webpack?.version;
154
+ this.sdk.reportConfiguration({
155
+ name: rspackVersion ? 'rspack' : 'webpack',
156
+ version: rspackVersion || webpackVersion || 'unknown',
157
+ config: configuration,
158
+ root: findRoot() || ''
159
+ }), configuration.name && this.sdk.setName(configuration.name);
38
160
  };
39
- })();
40
- (()=>{
41
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
42
- })();
43
- (()=>{
44
- __webpack_require__.r = (exports1)=>{
45
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
46
- value: 'Module'
47
- });
48
- Object.defineProperty(exports1, '__esModule', {
49
- value: true
161
+ beforeRun = async (compiler)=>{
162
+ compiler.isChild() || await this._bootstrapTask.then(()=>{
163
+ this.options.disableClientServer || this.browserIsOpened || this.options.output.mode === SDK.IMode[SDK.IMode.brief] || (this.browserIsOpened = !0, this.sdk.server.openClientPage());
50
164
  });
51
165
  };
52
- })();
53
- var __webpack_exports__ = {};
54
- (()=>{
55
- __webpack_require__.r(__webpack_exports__);
56
- __webpack_require__.d(__webpack_exports__, {
57
- LinterType: ()=>_rsdoctor_core_rules__WEBPACK_IMPORTED_MODULE_2__.LinterType,
58
- defineRule: ()=>_rsdoctor_core_rules__WEBPACK_IMPORTED_MODULE_2__.defineRule
59
- });
60
- var _plugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./plugin");
61
- var __WEBPACK_REEXPORT_OBJECT__ = {};
62
- for(var __WEBPACK_IMPORT_KEY__ in _plugin__WEBPACK_IMPORTED_MODULE_0__)if ([
63
- "default",
64
- "defineRule",
65
- "LinterType"
66
- ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
67
- return _plugin__WEBPACK_IMPORTED_MODULE_0__[key];
68
- }).bind(0, __WEBPACK_IMPORT_KEY__);
69
- __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
70
- var _multiple__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./multiple");
71
- var __WEBPACK_REEXPORT_OBJECT__ = {};
72
- for(var __WEBPACK_IMPORT_KEY__ in _multiple__WEBPACK_IMPORTED_MODULE_1__)if ([
73
- "default",
74
- "defineRule",
75
- "LinterType"
76
- ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
77
- return _multiple__WEBPACK_IMPORTED_MODULE_1__[key];
78
- }).bind(0, __WEBPACK_IMPORT_KEY__);
79
- __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
80
- var _rsdoctor_core_rules__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("@rsdoctor/core/rules");
81
- })();
82
- exports.LinterType = __webpack_exports__.LinterType;
83
- exports.defineRule = __webpack_exports__.defineRule;
84
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
85
- "LinterType",
86
- "defineRule"
87
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
88
- Object.defineProperty(exports, '__esModule', {
89
- value: true
90
- });
166
+ ensureModulesChunksGraphApplied(compiler) {
167
+ ensureModulesChunksGraphFn(compiler, this);
168
+ }
169
+ done = async ()=>{
170
+ try {
171
+ this.sdk.server.broadcast(), logger.debug(`${Process.getMemoryUsageMessage()}, '[Before Write Manifest]'`), await this.sdk.writeStore(), logger.debug(`${Process.getMemoryUsageMessage()}, '[After Write Manifest]'`), this.options.disableClientServer ? (await this.sdk.dispose(), logger.debug(`${Process.getMemoryUsageMessage()}, '[After SDK Dispose]'`)) : this.options.output.mode !== SDK.IMode[SDK.IMode.brief] || this.options.disableClientServer || handleBriefModeReport(this.sdk, this.options, this.options.disableClientServer);
172
+ } catch (e) {
173
+ console.error("[Rsdoctor] Webpack plugin this.done error", e);
174
+ }
175
+ };
176
+ }
177
+ class RsdoctorWebpackMultiplePlugin extends RsdoctorWebpackPlugin {
178
+ controller;
179
+ constructor(options = {}){
180
+ let controller = (()=>{
181
+ if (globalController) return globalController;
182
+ let controller = new RsdoctorSDKController();
183
+ return globalController = controller, controller;
184
+ })(), normallizedOptions = normalizeUserConfig(options);
185
+ super({
186
+ ...options,
187
+ sdkInstance: controller.createSlave({
188
+ name: options.name || 'Builder',
189
+ stage: options.stage,
190
+ extraConfig: {
191
+ innerClientPath: normallizedOptions.innerClientPath,
192
+ printLog: normallizedOptions.printLog,
193
+ mode: normallizedOptions.output.mode ? normallizedOptions.output.mode : void 0,
194
+ brief: normallizedOptions.output.mode === SDK.IMode[SDK.IMode.brief] && normallizedOptions.output.options || void 0
195
+ },
196
+ type: normallizedOptions.output.reportCodeType
197
+ })
198
+ }), this.controller = controller;
199
+ }
200
+ apply(compiler) {
201
+ 'dependencies' in compiler.options && (this.sdk.dependencies = compiler.options.dependencies), super.apply(compiler);
202
+ }
203
+ }
204
+ export { LinterType, RsdoctorWebpackMultiplePlugin, RsdoctorWebpackPlugin, defineRule };
@@ -1,5 +1,5 @@
1
- import type { Linter } from '@rsdoctor/types';
2
- import type { RsdoctorMultiplePluginOptions } from '@rsdoctor/core';
1
+ import { type Linter } from '@rsdoctor/types';
2
+ import type { RsdoctorMultiplePluginOptions } from '@rsdoctor/core/types';
3
3
  import { RsdoctorWebpackPlugin } from './plugin';
4
4
  import type { Compiler } from 'webpack';
5
5
  export declare class RsdoctorWebpackMultiplePlugin<Rules extends Linter.ExtendRuleData[]> extends RsdoctorWebpackPlugin<Rules> {
@@ -7,4 +7,3 @@ export declare class RsdoctorWebpackMultiplePlugin<Rules extends Linter.ExtendRu
7
7
  constructor(options?: RsdoctorMultiplePluginOptions<Rules>);
8
8
  apply(compiler: Compiler): void;
9
9
  }
10
- //# sourceMappingURL=multiple.d.ts.map
package/dist/plugin.d.ts CHANGED
@@ -1,18 +1,17 @@
1
- import type { RsdoctorPluginInstance, RsdoctorPluginOptionsNormalized, RsdoctorWebpackPluginOptions } from '@rsdoctor/core/types';
1
+ import type { RsdoctorPluginInstance } from '@rsdoctor/core/types';
2
2
  import { ChunkGraph, ModuleGraph } from '@rsdoctor/graph';
3
- import { RsdoctorSDK } from '@rsdoctor/sdk';
4
- import { Linter } from '@rsdoctor/types';
3
+ import { Linter, SDK, Plugin } from '@rsdoctor/types';
5
4
  import type { Compiler } from 'webpack';
6
5
  export declare class RsdoctorWebpackPlugin<Rules extends Linter.ExtendRuleData[]> implements RsdoctorPluginInstance<Compiler, Rules> {
7
6
  readonly name = "RsdoctorWebpackPlugin";
8
- readonly options: RsdoctorPluginOptionsNormalized<Rules>;
9
- readonly sdk: RsdoctorSDK;
7
+ readonly options: Plugin.RsdoctorPluginOptionsNormalized<Rules>;
8
+ readonly sdk: SDK.RsdoctorBuilderSDKInstance;
10
9
  readonly isRsdoctorPlugin: boolean;
11
10
  modulesGraph: ModuleGraph;
12
11
  _bootstrapTask: Promise<unknown>;
13
12
  protected browserIsOpened: boolean;
14
13
  chunkGraph: ChunkGraph;
15
- constructor(options?: RsdoctorWebpackPluginOptions<Rules>);
14
+ constructor(options?: Plugin.RsdoctorWebpackPluginOptions<Rules>);
16
15
  apply(compiler: unknown): unknown;
17
16
  afterPlugins: (compiler: Compiler) => void;
18
17
  beforeRun: (compiler: Compiler) => Promise<void>;
@@ -25,4 +24,3 @@ export declare class RsdoctorWebpackPlugin<Rules extends Linter.ExtendRuleData[]
25
24
  ensureModulesChunksGraphApplied(compiler: Compiler): void;
26
25
  done: () => Promise<void>;
27
26
  }
28
- //# sourceMappingURL=plugin.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { InternalBasePlugin } from '@rsdoctor/core/plugins';
2
- import { RsdoctorSDK } from '@rsdoctor/sdk';
3
2
  import { SDK } from '@rsdoctor/types';
4
3
  import type { Compiler, Resolver } from 'webpack';
5
4
  interface RsdoctorResolverPluginOptions {
@@ -23,12 +22,12 @@ declare interface ResolvePluginInstance {
23
22
  }
24
23
  export declare class RsdoctorResolverPlugin implements ResolvePluginInstance {
25
24
  protected options: RsdoctorResolverPluginOptions;
26
- protected sdk: RsdoctorSDK;
25
+ protected sdk: SDK.RsdoctorBuilderSDKInstance;
27
26
  protected tapOptions: {
28
27
  name: string;
29
28
  };
30
29
  protected contextMap: Map<string, [number, [number, number]]>;
31
- constructor(options: RsdoctorResolverPluginOptions, sdk: RsdoctorSDK);
30
+ constructor(options: RsdoctorResolverPluginOptions, sdk: SDK.RsdoctorBuilderSDKInstance);
32
31
  protected getResolverData(context: ResolveRequestContext, params: {
33
32
  request: string;
34
33
  query?: string;
@@ -46,4 +45,3 @@ export declare class InternalResolverPlugin extends InternalBasePlugin<Compiler>
46
45
  afterPlugins: (compiler: Compiler) => void;
47
46
  }
48
47
  export {};
49
- //# sourceMappingURL=resolver.d.ts.map
package/package.json CHANGED
@@ -1,32 +1,39 @@
1
1
  {
2
2
  "name": "@rsdoctor/webpack-plugin",
3
- "version": "1.2.3",
3
+ "version": "1.2.4-beta.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
7
7
  "directory": "packages/webpack-plugin"
8
8
  },
9
9
  "license": "MIT",
10
- "main": "dist/index.js",
10
+ "main": "dist/index.cjs",
11
11
  "types": "dist/index.d.ts",
12
12
  "files": [
13
13
  "dist"
14
14
  ],
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js",
20
+ "default": "./dist/index.cjs"
21
+ }
22
+ },
15
23
  "dependencies": {
16
24
  "lodash": "^4.17.21",
17
- "@rsdoctor/core": "1.2.3",
18
- "@rsdoctor/graph": "1.2.3",
19
- "@rsdoctor/sdk": "1.2.3",
20
- "@rsdoctor/types": "1.2.3",
21
- "@rsdoctor/utils": "1.2.3"
25
+ "@rsdoctor/core": "1.2.4-beta.1",
26
+ "@rsdoctor/graph": "1.2.4-beta.1",
27
+ "@rsdoctor/utils": "1.2.4-beta.1",
28
+ "@rsdoctor/sdk": "1.2.4-beta.1",
29
+ "@rsdoctor/types": "1.2.4-beta.1"
22
30
  },
23
31
  "devDependencies": {
24
- "@rslib/core": "^0.11.0",
25
32
  "@types/lodash": "^4.17.20",
26
33
  "@types/node": "^22.8.1",
27
34
  "@types/tapable": "2.2.7",
28
35
  "tslib": "2.8.1",
29
- "typescript": "^5.2.2",
36
+ "typescript": "^5.9.2",
30
37
  "webpack": "^5.97.1"
31
38
  },
32
39
  "peerDependencies": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAEnC,eAAO,MAAM,aAAa,0BAA0B,CAAC;AAErD,eAAO,MAAM,oBAAoB,EAAE,GAGlC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,GAGjC,CAAC;AAEF,eAAO,MAAM,2BAA2B,cAAe,MAAM,KAAG,GAG9D,CAAC;AAEH,eAAO,MAAM,4BAA4B,cAAe,MAAM,KAAG,GAG/D,CAAC"}
package/dist/constants.js DELETED
@@ -1,64 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- internalPluginTapPostOptions: ()=>internalPluginTapPostOptions,
28
- internalPluginTapPreOptions: ()=>internalPluginTapPreOptions,
29
- pluginTapName: ()=>pluginTapName,
30
- pluginTapPostOptions: ()=>pluginTapPostOptions,
31
- pluginTapPreOptions: ()=>pluginTapPreOptions
32
- });
33
- const pluginTapName = 'RsdoctorWebpackPlugin';
34
- const pluginTapPostOptions = {
35
- name: pluginTapName,
36
- stage: 999
37
- };
38
- const pluginTapPreOptions = {
39
- name: pluginTapName,
40
- stage: -999
41
- };
42
- const internalPluginTapPreOptions = (namespace)=>({
43
- name: `${pluginTapName}:${namespace}`,
44
- stage: -998
45
- });
46
- const internalPluginTapPostOptions = (namespace)=>({
47
- name: `${pluginTapName}:${namespace}`,
48
- stage: 1000
49
- });
50
- exports.internalPluginTapPostOptions = __webpack_exports__.internalPluginTapPostOptions;
51
- exports.internalPluginTapPreOptions = __webpack_exports__.internalPluginTapPreOptions;
52
- exports.pluginTapName = __webpack_exports__.pluginTapName;
53
- exports.pluginTapPostOptions = __webpack_exports__.pluginTapPostOptions;
54
- exports.pluginTapPreOptions = __webpack_exports__.pluginTapPreOptions;
55
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
56
- "internalPluginTapPostOptions",
57
- "internalPluginTapPreOptions",
58
- "pluginTapName",
59
- "pluginTapPostOptions",
60
- "pluginTapPreOptions"
61
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
62
- Object.defineProperty(exports, '__esModule', {
63
- value: true
64
- });
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"multiple.d.ts","sourceRoot":"","sources":["../src/multiple.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,qBAAa,6BAA6B,CACxC,KAAK,SAAS,MAAM,CAAC,cAAc,EAAE,CACrC,SAAQ,qBAAqB,CAAC,KAAK,CAAC;IAEpC,OAAO,CAAC,UAAU,CAAwB;gBAE9B,OAAO,GAAE,6BAA6B,CAAC,KAAK,CAAM;IAiC9D,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAQzB"}
package/dist/multiple.js DELETED
@@ -1,81 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- RsdoctorWebpackMultiplePlugin: ()=>RsdoctorWebpackMultiplePlugin
28
- });
29
- const sdk_namespaceObject = require("@rsdoctor/sdk");
30
- const external_plugin_js_namespaceObject = require("./plugin.js");
31
- const plugins_namespaceObject = require("@rsdoctor/core/plugins");
32
- function _define_property(obj, key, value) {
33
- if (key in obj) Object.defineProperty(obj, key, {
34
- value: value,
35
- enumerable: true,
36
- configurable: true,
37
- writable: true
38
- });
39
- else obj[key] = value;
40
- return obj;
41
- }
42
- let globalController;
43
- class RsdoctorWebpackMultiplePlugin extends external_plugin_js_namespaceObject.RsdoctorWebpackPlugin {
44
- apply(compiler) {
45
- if ('dependencies' in compiler.options) this.sdk.dependencies = compiler.options.dependencies;
46
- super.apply(compiler);
47
- }
48
- constructor(options = {}){
49
- const controller = (()=>{
50
- if (globalController) return globalController;
51
- const controller = new sdk_namespaceObject.RsdoctorSDKController();
52
- globalController = controller;
53
- return controller;
54
- })();
55
- const normallizedOptions = (0, plugins_namespaceObject.normalizeUserConfig)(options);
56
- const instance = controller.createSlave({
57
- name: options.name || 'Builder',
58
- stage: options.stage,
59
- extraConfig: {
60
- innerClientPath: normallizedOptions.innerClientPath,
61
- printLog: normallizedOptions.printLog,
62
- mode: normallizedOptions.mode ? normallizedOptions.mode : void 0,
63
- brief: normallizedOptions.brief,
64
- compressData: normallizedOptions.output.compressData
65
- },
66
- type: normallizedOptions.output.reportCodeType
67
- });
68
- super({
69
- ...options,
70
- sdkInstance: instance
71
- }), _define_property(this, "controller", void 0);
72
- this.controller = controller;
73
- }
74
- }
75
- exports.RsdoctorWebpackMultiplePlugin = __webpack_exports__.RsdoctorWebpackMultiplePlugin;
76
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
77
- "RsdoctorWebpackMultiplePlugin"
78
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
79
- Object.defineProperty(exports, '__esModule', {
80
- value: true
81
- });
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,sBAAsB,EACtB,+BAA+B,EAC/B,4BAA4B,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAyB,WAAW,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAa,MAAM,EAAiB,MAAM,iBAAiB,CAAC;AAKnE,OAAO,KAAK,EAAE,QAAQ,EAA8B,MAAM,SAAS,CAAC;AAQpE,qBAAa,qBAAqB,CAAC,KAAK,SAAS,MAAM,CAAC,cAAc,EAAE,CACtE,YAAW,sBAAsB,CAAC,QAAQ,EAAE,KAAK,CAAC;IAElD,SAAgB,IAAI,2BAAiB;IAErC,SAAgB,OAAO,EAAE,+BAA+B,CAAC,KAAK,CAAC,CAAC;IAEhE,SAAgB,GAAG,EAAE,WAAW,CAAC;IAEjC,SAAgB,gBAAgB,EAAE,OAAO,CAAC;IAEnC,YAAY,EAAE,WAAW,CAAC;IAE1B,cAAc,EAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEzC,SAAS,CAAC,eAAe,UAAS;IAE3B,UAAU,EAAE,UAAU,CAAC;gBAElB,OAAO,CAAC,EAAE,4BAA4B,CAAC,KAAK,CAAC;IAwBzD,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO;IA8D1B,YAAY,aAAc,QAAQ,KAAG,IAAI,CAqC9C;IAEK,SAAS,aAAoB,QAAQ,KAAG,OAAO,CAAC,IAAI,CAAC,CAW1D;IAEF;;;;;OAKG;IACI,+BAA+B,CAAC,QAAQ,EAAE,QAAQ;IAIlD,IAAI,QAAa,OAAO,CAAC,IAAI,CAAC,CAgCnC;CACH"}
package/dist/plugin.js DELETED
@@ -1,178 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- RsdoctorWebpackPlugin: ()=>RsdoctorWebpackPlugin
37
- });
38
- const plugins_namespaceObject = require("@rsdoctor/core/plugins");
39
- const graph_namespaceObject = require("@rsdoctor/graph");
40
- const sdk_namespaceObject = require("@rsdoctor/sdk");
41
- const types_namespaceObject = require("@rsdoctor/types");
42
- const build_namespaceObject = require("@rsdoctor/utils/build");
43
- const logger_namespaceObject = require("@rsdoctor/utils/logger");
44
- const external_lodash_namespaceObject = require("lodash");
45
- const external_path_namespaceObject = require("path");
46
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
47
- const external_constants_js_namespaceObject = require("./constants.js");
48
- const resolver_js_namespaceObject = require("./plugins/resolver.js");
49
- const common_namespaceObject = require("@rsdoctor/utils/common");
50
- const build_utils_namespaceObject = require("@rsdoctor/core/build-utils");
51
- function _define_property(obj, key, value) {
52
- if (key in obj) Object.defineProperty(obj, key, {
53
- value: value,
54
- enumerable: true,
55
- configurable: true,
56
- writable: true
57
- });
58
- else obj[key] = value;
59
- return obj;
60
- }
61
- class RsdoctorWebpackPlugin {
62
- apply(compiler) {
63
- if (!this._bootstrapTask) this._bootstrapTask = this.sdk.bootstrap();
64
- (0, plugins_namespaceObject.setSDK)(this.sdk);
65
- new plugins_namespaceObject.InternalSummaryPlugin(this).apply(compiler);
66
- if (this.options.features.loader) {
67
- new build_utils_namespaceObject.Loader.ProbeLoaderPlugin().apply(compiler);
68
- this.sdk.addClientRoutes([
69
- types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.WebpackLoaders
70
- ]);
71
- if (!common_namespaceObject.Loader.isVue(compiler)) new plugins_namespaceObject.InternalLoaderPlugin(this).apply(compiler);
72
- }
73
- if (this.options.features.resolver) new resolver_js_namespaceObject.InternalResolverPlugin(this).apply(compiler);
74
- if (this.options.features.plugins) new plugins_namespaceObject.InternalPluginsPlugin(this).apply(compiler);
75
- if (this.options.features.bundle) {
76
- new plugins_namespaceObject.InternalBundlePlugin(this).apply(compiler);
77
- new plugins_namespaceObject.InternalBundleTagPlugin(this).apply(compiler);
78
- }
79
- new plugins_namespaceObject.InternalErrorReporterPlugin(this).apply(compiler);
80
- new plugins_namespaceObject.InternalRulesPlugin(this).apply(compiler);
81
- new plugins_namespaceObject.InternalProgressPlugin(this).apply(compiler);
82
- compiler.hooks.afterPlugins.tap(external_constants_js_namespaceObject.pluginTapPostOptions, this.afterPlugins);
83
- compiler.hooks.watchRun.tapPromise(external_constants_js_namespaceObject.pluginTapPostOptions, this.beforeRun);
84
- compiler.hooks.beforeRun.tapPromise(external_constants_js_namespaceObject.pluginTapPostOptions, this.beforeRun);
85
- compiler.hooks.done.tapPromise({
86
- ...external_constants_js_namespaceObject.pluginTapPostOptions,
87
- stage: external_constants_js_namespaceObject.pluginTapPostOptions.stage + 100
88
- }, this.done.bind(this));
89
- }
90
- ensureModulesChunksGraphApplied(compiler) {
91
- (0, plugins_namespaceObject.ensureModulesChunksGraphFn)(compiler, this);
92
- }
93
- constructor(options){
94
- _define_property(this, "name", external_constants_js_namespaceObject.pluginTapName);
95
- _define_property(this, "options", void 0);
96
- _define_property(this, "sdk", void 0);
97
- _define_property(this, "isRsdoctorPlugin", void 0);
98
- _define_property(this, "modulesGraph", void 0);
99
- _define_property(this, "_bootstrapTask", void 0);
100
- _define_property(this, "browserIsOpened", false);
101
- _define_property(this, "chunkGraph", void 0);
102
- _define_property(this, "afterPlugins", (compiler)=>{
103
- var _compiler_webpack, _compiler_webpack1;
104
- if (compiler.isChild()) return;
105
- const { plugins, infrastructureLogging, ...rest } = compiler.options;
106
- const _rest = (0, external_lodash_namespaceObject.cloneDeep)(rest);
107
- (0, plugins_namespaceObject.makeRulesSerializable)(_rest.module.defaultRules);
108
- (0, plugins_namespaceObject.makeRulesSerializable)(_rest.module.rules);
109
- const configuration = {
110
- ..._rest,
111
- plugins: plugins.map((e)=>null == e ? void 0 : e.constructor.name)
112
- };
113
- const rspackVersion = null == (_compiler_webpack = compiler.webpack) ? void 0 : _compiler_webpack.rspackVersion;
114
- const webpackVersion = null == (_compiler_webpack1 = compiler.webpack) ? void 0 : _compiler_webpack1.version;
115
- this.sdk.reportConfiguration({
116
- name: rspackVersion ? 'rspack' : 'webpack',
117
- version: rspackVersion || webpackVersion || 'unknown',
118
- config: configuration,
119
- root: (0, sdk_namespaceObject.findRoot)() || ''
120
- });
121
- this.sdk.setOutputDir(external_path_default().resolve(this.options.output.reportDir || compiler.outputPath, `./${types_namespaceObject.Constants.RsdoctorOutputFolder}`));
122
- if (configuration.name) this.sdk.setName(configuration.name);
123
- });
124
- _define_property(this, "beforeRun", async (compiler)=>{
125
- if (compiler.isChild()) return;
126
- await this._bootstrapTask.then(()=>{
127
- if (!this.options.disableClientServer && !this.browserIsOpened) {
128
- if (this.options.mode !== types_namespaceObject.SDK.IMode[types_namespaceObject.SDK.IMode.brief]) {
129
- this.browserIsOpened = true;
130
- this.sdk.server.openClientPage();
131
- }
132
- }
133
- });
134
- });
135
- _define_property(this, "done", async ()=>{
136
- try {
137
- this.sdk.server.broadcast();
138
- logger_namespaceObject.logger.debug(`${build_namespaceObject.Process.getMemoryUsageMessage()}, '[Before Write Manifest]'`);
139
- await this.sdk.writeStore();
140
- logger_namespaceObject.logger.debug(`${build_namespaceObject.Process.getMemoryUsageMessage()}, '[After Write Manifest]'`);
141
- if (this.options.disableClientServer) {
142
- await this.sdk.dispose();
143
- logger_namespaceObject.logger.debug(`${build_namespaceObject.Process.getMemoryUsageMessage()}, '[After SDK Dispose]'`);
144
- } else if (this.options.mode === types_namespaceObject.SDK.IMode[types_namespaceObject.SDK.IMode.brief] && !this.options.disableClientServer) {
145
- const outputFilePath = external_path_default().resolve(this.sdk.outputDir, this.options.brief.reportHtmlName || 'rsdoctor-report.html');
146
- console.log(`${logger_namespaceObject.chalk.green('[RSDOCTOR] generated brief report')}: ${outputFilePath}`);
147
- (0, sdk_namespaceObject.openBrowser)(`file:///${outputFilePath}`);
148
- }
149
- } catch (e) {
150
- console.error("[Rsdoctor] Webpack plugin this.done error", e);
151
- }
152
- });
153
- this.options = (0, plugins_namespaceObject.normalizeUserConfig)(options);
154
- this.sdk = this.options.sdkInstance ?? new sdk_namespaceObject.RsdoctorSDK({
155
- port: this.options.port,
156
- name: external_constants_js_namespaceObject.pluginTapName,
157
- root: process.cwd(),
158
- type: this.options.output.reportCodeType,
159
- config: {
160
- innerClientPath: this.options.innerClientPath,
161
- printLog: this.options.printLog,
162
- mode: this.options.mode,
163
- brief: this.options.brief,
164
- compressData: this.options.output.compressData
165
- }
166
- });
167
- this.modulesGraph = new graph_namespaceObject.ModuleGraph();
168
- this.chunkGraph = new graph_namespaceObject.ChunkGraph();
169
- this.isRsdoctorPlugin = true;
170
- }
171
- }
172
- exports.RsdoctorWebpackPlugin = __webpack_exports__.RsdoctorWebpackPlugin;
173
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
174
- "RsdoctorWebpackPlugin"
175
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
176
- Object.defineProperty(exports, '__esModule', {
177
- value: true
178
- });
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/plugins/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAY,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElD,UAAU,6BAA6B;CAAG;AAE1C,UAAU,qBAAqB;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,yBAAyB;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,OAAO,EAAE,qBAAqB,CAAC;CAChC;AAED;;GAEG;AACH,OAAO,WAAW,qBAAqB;IACrC,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;CACrC;AAED,qBAAa,sBAAuB,YAAW,qBAAqB;IAQhE,SAAS,CAAC,OAAO,EAAE,6BAA6B;IAChD,SAAS,CAAC,GAAG,EAAE,WAAW;IAR5B,SAAS,CAAC,UAAU;;MAElB;IAEF,SAAS,CAAC,UAAU,0CAAiD;gBAGzD,OAAO,EAAE,6BAA6B,EACtC,GAAG,EAAE,WAAW;IAG5B,SAAS,CAAC,eAAe,CACvB,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,MAAM,CAAC,EAAE,GAAG,CAAC,gBAAgB,EAAE,CAAC;KACjC;IAiCH,SAAS,CAAC,mBAAmB,CAC3B,OAAO,EAAE,yBAAyB,EAClC,IAAI,EAAE,MAAM,EACZ,IAAI,SAAc;IA2BpB,SAAS,CAAC,iBAAiB,CACzB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,GAAG,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAwB1C,KAAK,CAAC,QAAQ,EAAE,QAAQ;CA4DzB;AAED,qBAAa,sBAAuB,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IACtE,SAAgB,IAAI,cAAc;IAE3B,KAAK,CAAC,QAAQ,EAAE,QAAQ;IAMxB,YAAY,aAAc,QAAQ,UAYvC;CACH"}
@@ -1,187 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- InternalResolverPlugin: ()=>InternalResolverPlugin,
37
- RsdoctorResolverPlugin: ()=>RsdoctorResolverPlugin
38
- });
39
- const plugins_namespaceObject = require("@rsdoctor/core/plugins");
40
- const types_namespaceObject = require("@rsdoctor/types");
41
- const common_namespaceObject = require("@rsdoctor/utils/common");
42
- const external_path_namespaceObject = require("path");
43
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
44
- function _define_property(obj, key, value) {
45
- if (key in obj) Object.defineProperty(obj, key, {
46
- value: value,
47
- enumerable: true,
48
- configurable: true,
49
- writable: true
50
- });
51
- else obj[key] = value;
52
- return obj;
53
- }
54
- class RsdoctorResolverPlugin {
55
- getResolverData(context, params) {
56
- const ctx = this.contextMap.get(context.issuer);
57
- if (!ctx) return;
58
- const { request, query, result, error, stacks } = params;
59
- const [start, startHRTime] = ctx;
60
- const data = {
61
- isEntry: Boolean(context.issuer),
62
- issuerPath: context.issuer || '',
63
- request,
64
- startAt: start,
65
- endAt: common_namespaceObject.Time.getCurrentTimestamp(start, startHRTime),
66
- pid: process.pid,
67
- ppid: process.ppid
68
- };
69
- if (query) data.query = query;
70
- if (result) data.result = result;
71
- if (error) {
72
- data.error = error;
73
- data.stacks = stacks || [];
74
- }
75
- return data;
76
- }
77
- getResolveStackData(request, path, name = 'anonymous') {
78
- const data = {
79
- name,
80
- path
81
- };
82
- const keys = [
83
- 'request',
84
- 'query',
85
- 'fragment',
86
- 'file',
87
- 'module',
88
- 'directory',
89
- 'internal'
90
- ];
91
- keys.forEach((key)=>{
92
- if (request[key]) data[key] = request[key];
93
- });
94
- return data;
95
- }
96
- getResolveRequest(request, ctx) {
97
- if (request) return request;
98
- if (null == ctx ? void 0 : ctx.stack) {
99
- const [target] = [
100
- ...ctx.stack
101
- ].map((e)=>e.split(' ').map((e)=>e.trim())).filter((e)=>e.length > 2);
102
- if (target) return target[target.length - 1];
103
- }
104
- return '';
105
- }
106
- apply(resolver) {
107
- resolver.hooks.result.tap(this.tapOptions, (request, resolveCtx)=>{
108
- const { context } = request;
109
- const ctx = this.contextMap.get(context.issuer);
110
- if (ctx) {
111
- const data = this.getResolverData(context, {
112
- request: this.getResolveRequest(request.request, resolveCtx),
113
- query: request.query,
114
- result: request.path
115
- });
116
- data && this.sdk.reportResolver([
117
- data
118
- ]);
119
- }
120
- });
121
- resolver.hooks.noResolve.tap(this.tapOptions, (request, error)=>{
122
- const { context } = request;
123
- if (context.issuer) {
124
- const resolvedPaths = new Set(error.details.split('\n').map((e)=>e.trim().split(' ')[0]).filter((e)=>external_path_default().isAbsolute(e)));
125
- if (resolvedPaths.size) {
126
- if (this.contextMap.has(context.issuer)) {
127
- const stacks = [
128
- ...resolvedPaths
129
- ].map((e)=>this.getResolveStackData(request, e, 'noResolve'));
130
- const data = this.getResolverData(context, {
131
- request: this.getResolveRequest(request.request),
132
- query: request.query,
133
- error,
134
- stacks
135
- });
136
- data && this.sdk.reportResolver([
137
- data
138
- ]);
139
- }
140
- }
141
- }
142
- });
143
- resolver.hooks.resolveStep.tap(this.tapOptions, (_, request)=>{
144
- const { context } = request;
145
- if (context.issuer && !this.contextMap.has(context.issuer)) this.contextMap.set(context.issuer, [
146
- Date.now(),
147
- process.hrtime()
148
- ]);
149
- });
150
- }
151
- constructor(options, sdk){
152
- _define_property(this, "options", void 0);
153
- _define_property(this, "sdk", void 0);
154
- _define_property(this, "tapOptions", void 0);
155
- _define_property(this, "contextMap", void 0);
156
- this.options = options;
157
- this.sdk = sdk;
158
- this.tapOptions = {
159
- name: 'RsdoctorResolverPlugin'
160
- };
161
- this.contextMap = new Map();
162
- }
163
- }
164
- class InternalResolverPlugin extends plugins_namespaceObject.InternalBasePlugin {
165
- apply(compiler) {
166
- this.scheduler.ensureModulesChunksGraphApplied(compiler);
167
- compiler.hooks.afterPlugins.tap(this.tapPostOptions, this.afterPlugins);
168
- }
169
- constructor(...args){
170
- super(...args), _define_property(this, "name", 'resolver'), _define_property(this, "afterPlugins", (compiler)=>{
171
- if (compiler.isChild()) return;
172
- compiler.options.resolve.plugins = (compiler.options.resolve.plugins ?? []).concat(new RsdoctorResolverPlugin({}, this.sdk));
173
- this.sdk.addClientRoutes([
174
- types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.ModuleResolve
175
- ]);
176
- });
177
- }
178
- }
179
- exports.InternalResolverPlugin = __webpack_exports__.InternalResolverPlugin;
180
- exports.RsdoctorResolverPlugin = __webpack_exports__.RsdoctorResolverPlugin;
181
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
182
- "InternalResolverPlugin",
183
- "RsdoctorResolverPlugin"
184
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
185
- Object.defineProperty(exports, '__esModule', {
186
- value: true
187
- });