From 9bce51f651aad297ef9eb6df832bfdaf1de05d84 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 22 四月 2026 14:27:54 +0800
Subject: [PATCH] 青岛推送
---
node_modules/webpack/lib/debug/ProfilingPlugin.js | 50 ++++++++++++++++++++++++++++++++++++--------------
1 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/node_modules/webpack/lib/debug/ProfilingPlugin.js b/node_modules/webpack/lib/debug/ProfilingPlugin.js
index 8f81dc2..897a41f 100644
--- a/node_modules/webpack/lib/debug/ProfilingPlugin.js
+++ b/node_modules/webpack/lib/debug/ProfilingPlugin.js
@@ -11,7 +11,6 @@
JSON_MODULE_TYPE,
WEBASSEMBLY_MODULES
} = require("../ModuleTypeConstants");
-const createSchemaValidation = require("../util/create-schema-validation");
const { dirname, mkdirpSync } = require("../util/fs");
/** @typedef {import("inspector").Session} Session */
@@ -24,33 +23,28 @@
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
/**
+ * Defines the hook type used by this module.
* @template T, R
* @typedef {import("tapable").Hook<T, R>} Hook
*/
/**
+ * Defines the fake hook type used by this module.
* @template T
* @typedef {import("../util/deprecation").FakeHook<T>} FakeHook
*/
/**
+ * Defines the hook map type used by this module.
* @template T
* @typedef {import("tapable").HookMap<T>} HookMap
*/
/**
+ * Defines the hook interceptor type used by this module.
* @template T, R
* @typedef {import("tapable").HookInterceptor<T, R>} HookInterceptor
*/
-
-const validate = createSchemaValidation(
- require("../../schemas/plugins/debug/ProfilingPlugin.check"),
- () => require("../../schemas/plugins/debug/ProfilingPlugin.json"),
- {
- name: "Profiling Plugin",
- baseDataPath: "options"
- }
-);
/** @typedef {{ Session: typeof import("inspector").Session }} Inspector */
@@ -67,6 +61,7 @@
class Profiler {
/**
+ * Creates an instance of Profiler.
* @param {Inspector} inspector inspector
*/
constructor(inspector) {
@@ -107,6 +102,7 @@
}
/**
+ * Returns promise for the result.
* @param {string} method method name
* @param {EXPECTED_OBJECT=} params params
* @returns {Promise<EXPECTED_ANY | void>} Promise for the result
@@ -137,6 +133,7 @@
}
/**
+ * Returns }>} profile result.
* @returns {Promise<{ profile: { startTime: number, endTime: number } }>} profile result
*/
stopProfiling() {
@@ -171,6 +168,7 @@
*/
/**
+ * Creates a trace from the provided f.
* @param {IntermediateFileSystem} fs filesystem used for output
* @param {string} outputPath The location where to write the log.
* @returns {Trace} The trace object
@@ -239,23 +237,37 @@
class ProfilingPlugin {
/**
+ * Creates an instance of ProfilingPlugin.
* @param {ProfilingPluginOptions=} options options object
*/
constructor(options = {}) {
- validate(options);
- this.outputPath = options.outputPath || "events.json";
+ /** @type {ProfilingPluginOptions} */
+ this.options = options;
}
/**
- * Apply the plugin
+ * Applies the plugin by registering its hooks on the compiler.
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
+ compiler.hooks.validate.tap(PLUGIN_NAME, () => {
+ compiler.validate(
+ () => require("../../schemas/plugins/debug/ProfilingPlugin.json"),
+ this.options,
+ {
+ name: "Profiling Plugin",
+ baseDataPath: "options"
+ },
+ (options) =>
+ require("../../schemas/plugins/debug/ProfilingPlugin.check")(options)
+ );
+ });
+
const tracer = createTrace(
/** @type {IntermediateFileSystem} */
(compiler.intermediateFileSystem),
- this.outputPath
+ this.options.outputPath || "events.json"
);
tracer.profiler.startProfiling();
@@ -373,6 +385,7 @@
/** @typedef {Record<string, Hook<EXPECTED_ANY, EXPECTED_ANY> | FakeHook<EXPECTED_ANY> | HookMap<EXPECTED_ANY>>} Hooks */
/**
+ * Intercept all hooks for.
* @param {EXPECTED_OBJECT & { hooks?: Hooks }} instance instance
* @param {Trace} tracer tracer
* @param {string} logLabel log label
@@ -390,6 +403,7 @@
};
/**
+ * Intercept all parser hooks.
* @param {NormalModuleFactory} moduleFactory normal module factory
* @param {Trace} tracer tracer
*/
@@ -411,6 +425,7 @@
};
/**
+ * Intercept all generator hooks.
* @param {NormalModuleFactory} moduleFactory normal module factory
* @param {Trace} tracer tracer
*/
@@ -432,6 +447,7 @@
};
/**
+ * Intercept all javascript modules plugin hooks.
* @param {Compilation} compilation compilation
* @param {Trace} tracer tracer
*/
@@ -449,6 +465,7 @@
};
/**
+ * Intercept all css modules plugin hooks.
* @param {Compilation} compilation compilation
* @param {Trace} tracer tracer
*/
@@ -465,6 +482,7 @@
/** @typedef {(...args: EXPECTED_ANY[]) => EXPECTED_ANY | Promise<(...args: EXPECTED_ANY[]) => EXPECTED_ANY>} PluginFunction */
/**
+ * Creates interceptor for.
* @template T
* @param {string} instance instance
* @param {Trace} tracer tracer
@@ -472,6 +490,7 @@
*/
const makeInterceptorFor = (instance, tracer) => (hookName) => ({
/**
+ * Returns modified full tap.
* @param {FullTap} tapInfo tap info
* @returns {FullTap} modified full tap
*/
@@ -491,6 +510,7 @@
});
/**
+ * Creates new profiled tap fn.
* @param {string} hookName Name of the hook to profile.
* @param {Trace} tracer The trace object.
* @param {object} options Options for the profiled fn.
@@ -535,6 +555,7 @@
fn(
...args,
/**
+ * Handles the cat callback for this hook.
* @param {...EXPECTED_ANY[]} r result
*/
(...r) => {
@@ -561,6 +582,7 @@
id,
cat: defaultCategory
});
+ /** @type {PluginFunction} */
let r;
try {
r = fn(...args);
--
Gitblit v1.9.3