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/BannerPlugin.js | 41 +++++++++++++++++++++++++++--------------
1 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/node_modules/webpack/lib/BannerPlugin.js b/node_modules/webpack/lib/BannerPlugin.js
index fb04ac1..5c59b31 100644
--- a/node_modules/webpack/lib/BannerPlugin.js
+++ b/node_modules/webpack/lib/BannerPlugin.js
@@ -9,25 +9,20 @@
const Compilation = require("./Compilation");
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
const Template = require("./Template");
-const createSchemaValidation = require("./util/create-schema-validation");
-/** @typedef {import("../declarations/plugins/BannerPlugin").BannerFunction} BannerFunction */
+/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginArgument} BannerPluginArgument */
+/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginOptions} BannerPluginOptions */
/** @typedef {import("./Compilation").PathData} PathData */
/** @typedef {import("./Compiler")} Compiler */
+/** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
-const validate = createSchemaValidation(
- /** @type {((value: typeof import("../schemas/plugins/BannerPlugin.json")) => boolean)} */
- (require("../schemas/plugins/BannerPlugin.check")),
- () => require("../schemas/plugins/BannerPlugin.json"),
- {
- name: "Banner Plugin",
- baseDataPath: "options"
- }
-);
+/** @typedef {(data: { hash?: string, chunk: Chunk, filename: string }) => string} BannerFunction */
/**
+ * Wraps banner text in a JavaScript block comment, preserving multi-line
+ * formatting and escaping accidental comment terminators.
* @param {string} str string to wrap
* @returns {string} wrapped string
*/
@@ -45,8 +40,14 @@
const PLUGIN_NAME = "BannerPlugin";
+/**
+ * Prepends or appends banner text to emitted assets that match the configured
+ * file filters.
+ */
class BannerPlugin {
/**
+ * Normalizes banner options and compiles the configured banner source into a
+ * function that can render per-asset banner text.
* @param {BannerPluginArgument} options options object
*/
constructor(options) {
@@ -56,8 +57,7 @@
};
}
- validate(options);
-
+ /** @type {BannerPluginOptions} */
this.options = options;
const bannerOption = options.banner;
@@ -77,17 +77,30 @@
}
/**
- * Apply the plugin
+ * Validates the configured options and injects rendered banner comments into
+ * matching compilation assets at the configured process-assets stage.
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
+ compiler.hooks.validate.tap(PLUGIN_NAME, () => {
+ compiler.validate(
+ () => require("../schemas/plugins/BannerPlugin.json"),
+ this.options,
+ {
+ name: "Banner Plugin",
+ baseDataPath: "options"
+ },
+ (options) => require("../schemas/plugins/BannerPlugin.check")(options)
+ );
+ });
const options = this.options;
const banner = this.banner;
const matchObject = ModuleFilenameHelpers.matchObject.bind(
undefined,
options
);
+ /** @type {WeakMap<Source, { source: ConcatSource, comment: string }>} */
const cache = new WeakMap();
const stage =
this.options.stage || Compilation.PROCESS_ASSETS_STAGE_ADDITIONS;
--
Gitblit v1.9.3