feat: refactoring project
This commit is contained in:
21
node_modules/webpack/lib/BannerPlugin.js
generated
vendored
21
node_modules/webpack/lib/BannerPlugin.js
generated
vendored
@@ -14,10 +14,13 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
||||
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerFunction} BannerFunction */
|
||||
/** @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("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
||||
|
||||
const validate = createSchemaValidation(
|
||||
require("../schemas/plugins/BannerPlugin.check.js"),
|
||||
/** @type {(function(typeof import("../schemas/plugins/BannerPlugin.json")): boolean)} */
|
||||
(require("../schemas/plugins/BannerPlugin.check.js")),
|
||||
() => require("../schemas/plugins/BannerPlugin.json"),
|
||||
{
|
||||
name: "Banner Plugin",
|
||||
@@ -59,6 +62,7 @@ class BannerPlugin {
|
||||
const bannerOption = options.banner;
|
||||
if (typeof bannerOption === "function") {
|
||||
const getBanner = bannerOption;
|
||||
/** @type {BannerFunction} */
|
||||
this.banner = this.options.raw
|
||||
? getBanner
|
||||
: /** @type {BannerFunction} */ data => wrapComment(getBanner(data));
|
||||
@@ -66,6 +70,7 @@ class BannerPlugin {
|
||||
const banner = this.options.raw
|
||||
? bannerOption
|
||||
: wrapComment(bannerOption);
|
||||
/** @type {BannerFunction} */
|
||||
this.banner = () => banner;
|
||||
}
|
||||
}
|
||||
@@ -103,15 +108,17 @@ class BannerPlugin {
|
||||
continue;
|
||||
}
|
||||
|
||||
const data = {
|
||||
chunk,
|
||||
filename: file
|
||||
};
|
||||
/** @type {PathData} */
|
||||
const data = { chunk, filename: file };
|
||||
|
||||
const comment = compilation.getPath(banner, data);
|
||||
const comment = compilation.getPath(
|
||||
/** @type {TemplatePath} */
|
||||
(banner),
|
||||
data
|
||||
);
|
||||
|
||||
compilation.updateAsset(file, old => {
|
||||
let cached = cache.get(old);
|
||||
const cached = cache.get(old);
|
||||
if (!cached || cached.comment !== comment) {
|
||||
const source = options.footer
|
||||
? new ConcatSource(old, "\n", comment)
|
||||
|
||||
Reference in New Issue
Block a user