feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -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)