Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

292
node_modules/webpack/lib/dll/DelegatedModule.js generated vendored Normal file
View File

@@ -0,0 +1,292 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const { OriginalSource, RawSource } = require("webpack-sources");
const Module = require("../Module");
const {
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES
} = require("../ModuleSourceTypeConstants");
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("../ModuleTypeConstants");
const RuntimeGlobals = require("../RuntimeGlobals");
const DelegatedSourceDependency = require("../dependencies/DelegatedSourceDependency");
const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
const makeSerializable = require("../util/makeSerializable");
/** @typedef {import("../../declarations/plugins/dll/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
/** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
/** @typedef {import("../Generator").SourceTypes} SourceTypes */
/** @typedef {import("./LibManifestPlugin").ManifestModuleData} ManifestModuleData */
/** @typedef {import("../Module").ModuleId} ModuleId */
/** @typedef {import("../Module").BuildCallback} BuildCallback */
/** @typedef {import("../Module").BuildMeta} BuildMeta */
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
/** @typedef {import("../Module").LibIdent} LibIdent */
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("../Module").Sources} Sources */
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
/** @typedef {import("../RequestShortener")} RequestShortener */
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
/** @typedef {import("../dependencies/StaticExportsDependency").Exports} Exports */
/** @typedef {import("../util/Hash")} Hash */
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
/** @typedef {string} DelegatedModuleSourceRequest */
/** @typedef {NonNullable<DllReferencePluginOptions["type"]>} DelegatedModuleType */
/**
* Defines the delegated module data type used by this module.
* @typedef {object} DelegatedModuleData
* @property {BuildMeta=} buildMeta build meta
* @property {Exports=} exports exports
* @property {ModuleId} id module id
*/
const RUNTIME_REQUIREMENTS = new Set([
RuntimeGlobals.module,
RuntimeGlobals.require
]);
class DelegatedModule extends Module {
/**
* Creates an instance of DelegatedModule.
* @param {DelegatedModuleSourceRequest} sourceRequest source request
* @param {DelegatedModuleData} data data
* @param {DelegatedModuleType} type type
* @param {string} userRequest user request
* @param {string | Module} originalRequest original request
*/
constructor(sourceRequest, data, type, userRequest, originalRequest) {
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
// Info from Factory
this.sourceRequest = sourceRequest;
this.request = data.id;
this.delegationType = type;
this.userRequest = userRequest;
this.originalRequest = originalRequest;
this.delegateData = data;
// Build info
/** @type {undefined | DelegatedSourceDependency} */
this.delegatedSourceDependency = undefined;
}
/**
* Returns the source types this module can generate.
* @returns {SourceTypes} types available (do not mutate)
*/
getSourceTypes() {
return JAVASCRIPT_TYPES;
}
/**
* Gets the library identifier.
* @param {LibIdentOptions} options options
* @returns {LibIdent | null} an identifier for library inclusion
*/
libIdent(options) {
return typeof this.originalRequest === "string"
? this.originalRequest
: this.originalRequest.libIdent(options);
}
/**
* Returns the unique identifier used to reference this module.
* @returns {string} a unique identifier of the module
*/
identifier() {
return `delegated ${JSON.stringify(this.request)} from ${
this.sourceRequest
}`;
}
/**
* Returns a human-readable identifier for this module.
* @param {RequestShortener} requestShortener the request shortener
* @returns {string} a user readable identifier of the module
*/
readableIdentifier(requestShortener) {
return `delegated ${this.userRequest} from ${this.sourceRequest}`;
}
/**
* Checks whether the module needs to be rebuilt for the current build state.
* @param {NeedBuildContext} context context info
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
return callback(null, !this.buildMeta);
}
/**
* Builds the module using the provided compilation context.
* @param {WebpackOptions} options webpack options
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {
const delegateData = /** @type {ManifestModuleData} */ (this.delegateData);
this.buildMeta = { ...delegateData.buildMeta };
this.buildInfo = {};
this.dependencies.length = 0;
this.delegatedSourceDependency = new DelegatedSourceDependency(
this.sourceRequest
);
this.addDependency(this.delegatedSourceDependency);
this.addDependency(
new StaticExportsDependency(delegateData.exports || true, false)
);
callback();
}
/**
* Generates code and runtime requirements for this module.
* @param {CodeGenerationContext} context context for code generation
* @returns {CodeGenerationResult} result
*/
codeGeneration({ runtimeTemplate, moduleGraph, chunkGraph }) {
const dep = /** @type {DelegatedSourceDependency} */ (this.dependencies[0]);
const sourceModule = moduleGraph.getModule(dep);
/** @type {string} */
let str;
if (!sourceModule) {
str = runtimeTemplate.throwMissingModuleErrorBlock({
request: this.sourceRequest
});
} else {
str = `module.exports = (${runtimeTemplate.moduleExports({
module: sourceModule,
chunkGraph,
request: dep.request,
/** @type {RuntimeRequirements} */
runtimeRequirements: new Set()
})})`;
switch (this.delegationType) {
case "require":
str += `(${JSON.stringify(this.request)})`;
break;
case "object":
str += `[${JSON.stringify(this.request)}]`;
break;
}
str += ";";
}
/** @type {Sources} */
const sources = new Map();
if (this.useSourceMap || this.useSimpleSourceMap) {
sources.set(JAVASCRIPT_TYPE, new OriginalSource(str, this.identifier()));
} else {
sources.set(JAVASCRIPT_TYPE, new RawSource(str));
}
return {
sources,
runtimeRequirements: RUNTIME_REQUIREMENTS
};
}
/**
* Returns the estimated size for the requested source type.
* @param {string=} type the source type for which the size should be estimated
* @returns {number} the estimated size of the module (must be non-zero)
*/
size(type) {
return 42;
}
/**
* Updates the hash with the data contributed by this instance.
* @param {Hash} hash the hash used to track dependencies
* @param {UpdateHashContext} context context
* @returns {void}
*/
updateHash(hash, context) {
hash.update(this.delegationType);
hash.update(JSON.stringify(this.request));
super.updateHash(hash, context);
}
/**
* Serializes this instance into the provided serializer context.
* @param {ObjectSerializerContext} context context
*/
serialize(context) {
const { write } = context;
// constructor
write(this.sourceRequest);
write(this.delegateData);
write(this.delegationType);
write(this.userRequest);
write(this.originalRequest);
super.serialize(context);
}
/**
* Restores this instance from the provided deserializer context.
* @param {ObjectDeserializerContext} context context\
* @returns {DelegatedModule} DelegatedModule
*/
static deserialize(context) {
const { read } = context;
const obj = new DelegatedModule(
read(), // sourceRequest
read(), // delegateData
read(), // delegationType
read(), // userRequest
read() // originalRequest
);
obj.deserialize(context);
return obj;
}
/**
* Assuming this module is in the cache. Update the (cached) module with
* the fresh module from the factory. Usually updates internal references
* and properties.
* @param {Module} module fresh module
* @returns {void}
*/
updateCacheModule(module) {
super.updateCacheModule(module);
const m = /** @type {DelegatedModule} */ (module);
this.delegationType = m.delegationType;
this.userRequest = m.userRequest;
this.originalRequest = m.originalRequest;
this.delegateData = m.delegateData;
}
/**
* Assuming this module is in the cache. Remove internal references to allow freeing some memory.
*/
cleanupForCache() {
super.cleanupForCache();
this.delegateData =
/** @type {EXPECTED_ANY} */
(undefined);
}
}
makeSerializable(DelegatedModule, "webpack/lib/dll/DelegatedModule");
module.exports = DelegatedModule;

View File

@@ -0,0 +1,119 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const DelegatedModule = require("./DelegatedModule");
/** @typedef {import("../../declarations/plugins/dll/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
/** @typedef {import("../../declarations/plugins/dll/DllReferencePlugin").DllReferencePluginOptionsContent} DllReferencePluginOptionsContent */
/** @typedef {import("./DelegatedModule").DelegatedModuleData} DelegatedModuleData */
/** @typedef {import("./DelegatedModule").DelegatedModuleSourceRequest} DelegatedModuleSourceRequest */
/** @typedef {import("./DelegatedModule").DelegatedModuleType} DelegatedModuleType */
/** @typedef {import("../NormalModuleFactory")} NormalModuleFactory */
/** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
/**
* Defines the options type used by this module.
* @typedef {object} Options
* @property {DelegatedModuleSourceRequest} source source
* @property {NonNullable<DllReferencePluginOptions["context"]>} context absolute context path to which lib ident is relative to
* @property {DllReferencePluginOptionsContent} content content
* @property {DllReferencePluginOptions["type"]} type type
* @property {DllReferencePluginOptions["extensions"]} extensions extensions
* @property {DllReferencePluginOptions["scope"]} scope scope
* @property {AssociatedObjectForCache=} associatedObjectForCache object for caching
*/
const PLUGIN_NAME = "DelegatedModuleFactoryPlugin";
class DelegatedModuleFactoryPlugin {
/**
* Creates an instance of DelegatedModuleFactoryPlugin.
* @param {Options} options options
*/
constructor(options) {
this.options = options;
options.type = options.type || "require";
options.extensions = options.extensions || ["", ".js", ".json", ".wasm"];
}
/**
* Applies the plugin by registering its hooks on the compiler.
* @param {NormalModuleFactory} normalModuleFactory the normal module factory
* @returns {void}
*/
apply(normalModuleFactory) {
const scope = this.options.scope;
if (scope) {
normalModuleFactory.hooks.factorize.tapAsync(
PLUGIN_NAME,
(data, callback) => {
const [dependency] = data.dependencies;
const { request } = dependency;
if (request && request.startsWith(`${scope}/`)) {
const innerRequest = `.${request.slice(scope.length)}`;
/** @type {undefined | DelegatedModuleData} */
let resolved;
if (innerRequest in this.options.content) {
resolved = this.options.content[innerRequest];
return callback(
null,
new DelegatedModule(
this.options.source,
resolved,
/** @type {DelegatedModuleType} */
(this.options.type),
innerRequest,
request
)
);
}
const extensions =
/** @type {string[]} */
(this.options.extensions);
for (let i = 0; i < extensions.length; i++) {
const extension = extensions[i];
const requestPlusExt = innerRequest + extension;
if (requestPlusExt in this.options.content) {
resolved = this.options.content[requestPlusExt];
return callback(
null,
new DelegatedModule(
this.options.source,
resolved,
/** @type {DelegatedModuleType} */
(this.options.type),
requestPlusExt,
request + extension
)
);
}
}
}
return callback();
}
);
} else {
normalModuleFactory.hooks.module.tap(PLUGIN_NAME, (module) => {
const request = module.libIdent(this.options);
if (request && request in this.options.content) {
const resolved = this.options.content[request];
return new DelegatedModule(
this.options.source,
resolved,
/** @type {DelegatedModuleType} */
(this.options.type),
request,
module
);
}
return module;
});
}
}
}
module.exports = DelegatedModuleFactoryPlugin;

50
node_modules/webpack/lib/dll/DelegatedPlugin.js generated vendored Normal file
View File

@@ -0,0 +1,50 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const DelegatedSourceDependency = require("../dependencies/DelegatedSourceDependency");
const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("./DelegatedModuleFactoryPlugin").Options} Options */
const PLUGIN_NAME = "DelegatedPlugin";
class DelegatedPlugin {
/**
* Creates an instance of DelegatedPlugin.
* @param {Options} options options
*/
constructor(options) {
this.options = options;
}
/**
* Applies the plugin by registering its hooks on the compiler.
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
compiler.hooks.compilation.tap(
PLUGIN_NAME,
(compilation, { normalModuleFactory }) => {
compilation.dependencyFactories.set(
DelegatedSourceDependency,
normalModuleFactory
);
}
);
compiler.hooks.compile.tap(PLUGIN_NAME, ({ normalModuleFactory }) => {
new DelegatedModuleFactoryPlugin({
associatedObjectForCache: compiler.root,
...this.options
}).apply(normalModuleFactory);
});
}
}
module.exports = DelegatedPlugin;

77
node_modules/webpack/lib/dll/DllEntryPlugin.js generated vendored Normal file
View File

@@ -0,0 +1,77 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const DllEntryDependency = require("../dependencies/DllEntryDependency");
const EntryDependency = require("../dependencies/EntryDependency");
const DllModuleFactory = require("./DllModuleFactory");
/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../Entrypoint").EntryOptions} EntryOptions */
/** @typedef {string[]} Entries */
/** @typedef {EntryOptions & { name: string }} Options */
const PLUGIN_NAME = "DllEntryPlugin";
class DllEntryPlugin {
/**
* Creates an instance of DllEntryPlugin.
* @param {string} context context
* @param {Entries} entries entry names
* @param {Options} options options
*/
constructor(context, entries, options) {
this.context = context;
this.entries = entries;
this.options = options;
}
/**
* Applies the plugin by registering its hooks on the compiler.
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
compiler.hooks.compilation.tap(
PLUGIN_NAME,
(compilation, { normalModuleFactory }) => {
const dllModuleFactory = new DllModuleFactory();
compilation.dependencyFactories.set(
DllEntryDependency,
dllModuleFactory
);
compilation.dependencyFactories.set(
EntryDependency,
normalModuleFactory
);
}
);
compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
compilation.addEntry(
this.context,
new DllEntryDependency(
this.entries.map((e, idx) => {
const dep = new EntryDependency(e);
dep.loc = {
name: this.options.name,
index: idx
};
return dep;
}),
this.options.name
),
this.options,
(error) => {
if (error) return callback(error);
callback();
}
);
});
}
}
module.exports = DllEntryPlugin;

186
node_modules/webpack/lib/dll/DllModule.js generated vendored Normal file
View File

@@ -0,0 +1,186 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const { RawSource } = require("webpack-sources");
const Module = require("../Module");
const {
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES
} = require("../ModuleSourceTypeConstants");
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("../ModuleTypeConstants");
const RuntimeGlobals = require("../RuntimeGlobals");
const makeSerializable = require("../util/makeSerializable");
/** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
/** @typedef {import("../Generator").SourceTypes} SourceTypes */
/** @typedef {import("../Module").BuildCallback} BuildCallback */
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("../Module").Sources} Sources */
/** @typedef {import("../RequestShortener")} RequestShortener */
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
/** @typedef {import("../util/Hash")} Hash */
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
const RUNTIME_REQUIREMENTS = new Set([
RuntimeGlobals.require,
RuntimeGlobals.module
]);
class DllModule extends Module {
/**
* Creates an instance of DllModule.
* @param {string} context context path
* @param {Dependency[]} dependencies dependencies
* @param {string} name name
*/
constructor(context, dependencies, name) {
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, context);
// Info from Factory
/** @type {Dependency[]} */
this.dependencies = dependencies;
this.name = name;
}
/**
* Returns the source types this module can generate.
* @returns {SourceTypes} types available (do not mutate)
*/
getSourceTypes() {
return JAVASCRIPT_TYPES;
}
/**
* Returns the unique identifier used to reference this module.
* @returns {string} a unique identifier of the module
*/
identifier() {
return `dll ${this.name}`;
}
/**
* Returns a human-readable identifier for this module.
* @param {RequestShortener} requestShortener the request shortener
* @returns {string} a user readable identifier of the module
*/
readableIdentifier(requestShortener) {
return `dll ${this.name}`;
}
/**
* Builds the module using the provided compilation context.
* @param {WebpackOptions} options webpack options
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {
this.buildMeta = {};
this.buildInfo = {};
return callback();
}
/**
* Generates code and runtime requirements for this module.
* @param {CodeGenerationContext} context context for code generation
* @returns {CodeGenerationResult} result
*/
codeGeneration(context) {
/** @type {Sources} */
const sources = new Map();
sources.set(
JAVASCRIPT_TYPE,
new RawSource(`module.exports = ${RuntimeGlobals.require};`)
);
return {
sources,
runtimeRequirements: RUNTIME_REQUIREMENTS
};
}
/**
* Checks whether the module needs to be rebuilt for the current build state.
* @param {NeedBuildContext} context context info
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
return callback(null, !this.buildMeta);
}
/**
* Returns the estimated size for the requested source type.
* @param {string=} type the source type for which the size should be estimated
* @returns {number} the estimated size of the module (must be non-zero)
*/
size(type) {
return 12;
}
/**
* Updates the hash with the data contributed by this instance.
* @param {Hash} hash the hash used to track dependencies
* @param {UpdateHashContext} context context
* @returns {void}
*/
updateHash(hash, context) {
hash.update(`dll module${this.name || ""}`);
super.updateHash(hash, context);
}
/**
* Serializes this instance into the provided serializer context.
* @param {ObjectSerializerContext} context context
*/
serialize(context) {
context.write(this.name);
super.serialize(context);
}
/**
* Restores this instance from the provided deserializer context.
* @param {ObjectDeserializerContext} context context
*/
deserialize(context) {
this.name = context.read();
super.deserialize(context);
}
/**
* Assuming this module is in the cache. Update the (cached) module with
* the fresh module from the factory. Usually updates internal references
* and properties.
* @param {Module} module fresh module
* @returns {void}
*/
updateCacheModule(module) {
super.updateCacheModule(module);
this.dependencies = module.dependencies;
}
/**
* Assuming this module is in the cache. Remove internal references to allow freeing some memory.
*/
cleanupForCache() {
super.cleanupForCache();
this.dependencies = /** @type {EXPECTED_ANY} */ (undefined);
}
}
makeSerializable(DllModule, "webpack/lib/dll/DllModule");
module.exports = DllModule;

39
node_modules/webpack/lib/dll/DllModuleFactory.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const ModuleFactory = require("../ModuleFactory");
const DllModule = require("./DllModule");
/** @typedef {import("../ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
/** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
/** @typedef {import("../dependencies/DllEntryDependency")} DllEntryDependency */
class DllModuleFactory extends ModuleFactory {
constructor() {
super();
this.hooks = Object.freeze({});
}
/**
* Processes the provided data.
* @param {ModuleFactoryCreateData} data data object
* @param {ModuleFactoryCallback} callback callback
* @returns {void}
*/
create(data, callback) {
const dependency = /** @type {DllEntryDependency} */ (data.dependencies[0]);
callback(null, {
module: new DllModule(
data.context,
dependency.dependencies,
dependency.name
)
});
}
}
module.exports = DllModuleFactory;

75
node_modules/webpack/lib/dll/DllPlugin.js generated vendored Normal file
View File

@@ -0,0 +1,75 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const FlagAllModulesAsUsedPlugin = require("../FlagAllModulesAsUsedPlugin");
const DllEntryPlugin = require("./DllEntryPlugin");
const LibManifestPlugin = require("./LibManifestPlugin");
/** @typedef {import("../../declarations/plugins/dll/DllPlugin").DllPluginOptions} DllPluginOptions */
/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("./DllEntryPlugin").Entries} Entries */
/** @typedef {import("./DllEntryPlugin").Options} Options */
const PLUGIN_NAME = "DllPlugin";
class DllPlugin {
/**
* Creates an instance of DllPlugin.
* @param {DllPluginOptions} options options object
*/
constructor(options) {
/** @type {DllPluginOptions} */
this.options = options;
}
/**
* 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/dll/DllPlugin.json"),
this.options,
{
name: "Dll Plugin",
baseDataPath: "options"
},
(options) =>
require("../../schemas/plugins/dll/DllPlugin.check")(options)
);
});
const entryOnly = this.options.entryOnly !== false;
compiler.hooks.entryOption.tap(PLUGIN_NAME, (context, entry) => {
if (typeof entry !== "function") {
for (const name of Object.keys(entry)) {
/** @type {Options} */
const options = { name };
new DllEntryPlugin(
context,
/** @type {Entries} */
(entry[name].import),
options
).apply(compiler);
}
} else {
throw new Error(
`${PLUGIN_NAME} doesn't support dynamic entry (function) yet`
);
}
return true;
});
new LibManifestPlugin({ ...this.options, entryOnly }).apply(compiler);
if (!entryOnly) {
new FlagAllModulesAsUsedPlugin(PLUGIN_NAME).apply(compiler);
}
}
}
module.exports = DllPlugin;

196
node_modules/webpack/lib/dll/DllReferencePlugin.js generated vendored Normal file
View File

@@ -0,0 +1,196 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const ExternalModuleFactoryPlugin = require("../ExternalModuleFactoryPlugin");
const DelegatedSourceDependency = require("../dependencies/DelegatedSourceDependency");
const WebpackError = require("../errors/WebpackError");
const { makePathsRelative } = require("../util/identifier");
const parseJson = require("../util/parseJson");
const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
/** @typedef {import("../../declarations/WebpackOptions").Externals} Externals */
/** @typedef {import("../../declarations/plugins/dll/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
/** @typedef {import("../../declarations/plugins/dll/DllReferencePlugin").DllReferencePluginOptionsContent} DllReferencePluginOptionsContent */
/** @typedef {import("../../declarations/plugins/dll/DllReferencePlugin").DllReferencePluginOptionsManifest} DllReferencePluginOptionsManifest */
/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../Compiler").CompilationParams} CompilationParams */
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
/** @typedef {{ path: string, data: DllReferencePluginOptionsManifest | undefined, error: Error | undefined }} CompilationDataItem */
const PLUGIN_NAME = "DllReferencePlugin";
class DllReferencePlugin {
/**
* Creates an instance of DllReferencePlugin.
* @param {DllReferencePluginOptions} options options object
*/
constructor(options) {
this.options = options;
}
/**
* 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/dll/DllReferencePlugin.json"),
this.options,
{
name: "Dll Reference Plugin",
baseDataPath: "options"
},
(options) =>
require("../../schemas/plugins/dll/DllReferencePlugin.check")(options)
);
});
compiler.hooks.compilation.tap(
PLUGIN_NAME,
(compilation, { normalModuleFactory }) => {
compilation.dependencyFactories.set(
DelegatedSourceDependency,
normalModuleFactory
);
}
);
/** @type {WeakMap<CompilationParams, CompilationDataItem>} */
const compilationData = new WeakMap();
compiler.hooks.beforeCompile.tapAsync(PLUGIN_NAME, (params, callback) => {
if ("manifest" in this.options) {
const manifest = this.options.manifest;
if (typeof manifest === "string") {
/** @type {InputFileSystem} */
(compiler.inputFileSystem).readFile(manifest, (err, result) => {
if (err) return callback(err);
/** @type {CompilationDataItem} */
const data = {
path: manifest,
data: undefined,
error: undefined
};
// Catch errors parsing the manifest so that blank
// or malformed manifest files don't kill the process.
try {
data.data =
/** @type {DllReferencePluginOptionsManifest} */
(
/** @type {unknown} */
(parseJson(/** @type {Buffer} */ (result).toString("utf8")))
);
} catch (parseErr) {
// Store the error in the params so that it can
// be added as a compilation error later on.
const manifestPath = makePathsRelative(
compiler.context,
manifest,
compiler.root
);
data.error = new DllManifestError(
manifestPath,
/** @type {Error} */ (parseErr).message
);
}
compilationData.set(params, data);
return callback();
});
return;
}
}
return callback();
});
compiler.hooks.compile.tap(PLUGIN_NAME, (params) => {
let name = this.options.name;
let sourceType = this.options.sourceType;
let resolvedContent =
"content" in this.options ? this.options.content : undefined;
if ("manifest" in this.options) {
const manifestParameter = this.options.manifest;
/** @type {undefined | DllReferencePluginOptionsManifest} */
let manifest;
if (typeof manifestParameter === "string") {
const data =
/** @type {CompilationDataItem} */
(compilationData.get(params));
// If there was an error parsing the manifest
// file, exit now because the error will be added
// as a compilation error in the "compilation" hook.
if (data.error) {
return;
}
manifest = data.data;
} else {
manifest = manifestParameter;
}
if (manifest) {
if (!name) name = manifest.name;
if (!sourceType) sourceType = manifest.type;
if (!resolvedContent) resolvedContent = manifest.content;
}
}
/** @type {Externals} */
const externals = {};
const source = `dll-reference ${name}`;
externals[source] = /** @type {string} */ (name);
const normalModuleFactory = params.normalModuleFactory;
new ExternalModuleFactoryPlugin(sourceType || "var", externals).apply(
normalModuleFactory
);
new DelegatedModuleFactoryPlugin({
source,
type: this.options.type,
scope: this.options.scope,
context: this.options.context || compiler.context,
content:
/** @type {DllReferencePluginOptionsContent} */
(resolvedContent),
extensions: this.options.extensions,
associatedObjectForCache: compiler.root
}).apply(normalModuleFactory);
});
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation, params) => {
if ("manifest" in this.options) {
const manifest = this.options.manifest;
if (typeof manifest === "string") {
const data =
/** @type {CompilationDataItem} */
(compilationData.get(params));
// If there was an error parsing the manifest file, add the
// error as a compilation error to make the compilation fail.
if (data.error) {
compilation.errors.push(
/** @type {DllManifestError} */ (data.error)
);
}
compilation.fileDependencies.add(manifest);
}
}
});
}
}
class DllManifestError extends WebpackError {
/**
* Creates an instance of DllManifestError.
* @param {string} filename filename of the manifest
* @param {string} message error message
*/
constructor(filename, message) {
super();
this.name = "DllManifestError";
this.message = `Dll manifest ${filename}\n${message}`;
}
}
module.exports = DllReferencePlugin;

147
node_modules/webpack/lib/dll/LibManifestPlugin.js generated vendored Normal file
View File

@@ -0,0 +1,147 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const asyncLib = require("neo-async");
const EntryDependency = require("../dependencies/EntryDependency");
const { someInIterable } = require("../util/IterableHelpers");
const { compareModulesById } = require("../util/comparators");
const { dirname, mkdirp } = require("../util/fs");
/** @typedef {import("../ChunkGraph").ModuleId} ModuleId */
/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../Compiler").IntermediateFileSystem} IntermediateFileSystem */
/** @typedef {import("../Module").BuildMeta} BuildMeta */
/** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */
/**
* Defines the manifest module data type used by this module.
* @typedef {object} ManifestModuleData
* @property {ModuleId} id
* @property {BuildMeta=} buildMeta
* @property {ExportInfoName[]=} exports
*/
/**
* Defines the lib manifest plugin options type used by this module.
* @typedef {object} LibManifestPluginOptions
* @property {string=} context Context of requests in the manifest file (defaults to the webpack context).
* @property {boolean=} entryOnly If true, only entry points will be exposed (default: true).
* @property {boolean=} format If true, manifest json file (output) will be formatted.
* @property {string=} name Name of the exposed dll function (external name, use value of 'output.library').
* @property {string} path Absolute path to the manifest json file (output).
* @property {string=} type Type of the dll bundle (external type, use value of 'output.libraryTarget').
*/
const PLUGIN_NAME = "LibManifestPlugin";
class LibManifestPlugin {
/**
* Creates an instance of LibManifestPlugin.
* @param {LibManifestPluginOptions} options the options
*/
constructor(options) {
this.options = options;
}
/**
* Applies the plugin by registering its hooks on the compiler.
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
compiler.hooks.emit.tapAsync(
{ name: PLUGIN_NAME, stage: 110 },
(compilation, callback) => {
const moduleGraph = compilation.moduleGraph;
// store used paths to detect issue and output an error. #18200
/** @type {Set<string>} */
const usedPaths = new Set();
asyncLib.each(
[...compilation.chunks],
(chunk, callback) => {
if (!chunk.canBeInitial()) {
callback();
return;
}
const chunkGraph = compilation.chunkGraph;
const targetPath = compilation.getPath(this.options.path, {
chunk
});
if (usedPaths.has(targetPath)) {
callback(new Error("each chunk must have a unique path"));
return;
}
usedPaths.add(targetPath);
const name =
this.options.name &&
compilation.getPath(this.options.name, {
chunk,
contentHashType: "javascript"
});
const content = Object.create(null);
for (const module of chunkGraph.getOrderedChunkModulesIterable(
chunk,
compareModulesById(chunkGraph)
)) {
if (
this.options.entryOnly &&
!someInIterable(
moduleGraph.getIncomingConnections(module),
(c) => c.dependency instanceof EntryDependency
)
) {
continue;
}
const ident = module.libIdent({
context: this.options.context || compiler.context,
associatedObjectForCache: compiler.root
});
if (ident) {
const exportsInfo = moduleGraph.getExportsInfo(module);
const providedExports = exportsInfo.getProvidedExports();
/** @type {ManifestModuleData} */
const data = {
id: /** @type {ModuleId} */ (chunkGraph.getModuleId(module)),
buildMeta: /** @type {BuildMeta} */ (module.buildMeta),
exports: Array.isArray(providedExports)
? providedExports
: undefined
};
content[ident] = data;
}
}
const manifest = {
name,
type: this.options.type,
content
};
// Apply formatting to content if format flag is true;
const manifestContent = this.options.format
? JSON.stringify(manifest, null, 2)
: JSON.stringify(manifest);
const buffer = Buffer.from(manifestContent, "utf8");
const intermediateFileSystem =
/** @type {IntermediateFileSystem} */ (
compiler.intermediateFileSystem
);
mkdirp(
intermediateFileSystem,
dirname(intermediateFileSystem, targetPath),
(err) => {
if (err) return callback(err);
intermediateFileSystem.writeFile(targetPath, buffer, callback);
}
);
},
callback
);
}
);
}
}
module.exports = LibManifestPlugin;