This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

1
node_modules/webpack-cli/lib/bootstrap.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

16
node_modules/webpack-cli/lib/bootstrap.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// eslint-disable-next-line @typescript-eslint/no-var-requires
const WebpackCLI = require("./webpack-cli");
const runCLI = async (args) => {
// Create a new instance of the CLI object
const cli = new WebpackCLI();
try {
await cli.run(args);
}
catch (error) {
cli.logger.error(error);
process.exit(2);
}
};
module.exports = runCLI;

1
node_modules/webpack-cli/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export type * from "./types";

5
node_modules/webpack-cli/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// eslint-disable-next-line @typescript-eslint/no-var-requires
const CLI = require("./webpack-cli");
module.exports = CLI;

12
node_modules/webpack-cli/lib/plugins/cli-plugin.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
import { type Compiler } from "webpack";
import { type CLIPluginOptions } from "../types";
export declare class CLIPlugin {
#private;
logger: ReturnType<Compiler["getInfrastructureLogger"]>;
options: CLIPluginOptions;
constructor(options: CLIPluginOptions);
setupBundleAnalyzerPlugin(compiler: Compiler): Promise<void>;
setupProgressPlugin(compiler: Compiler): void;
setupHelpfulOutput(compiler: Compiler): void;
apply(compiler: Compiler): void;
}

108
node_modules/webpack-cli/lib/plugins/cli-plugin.js generated vendored Normal file
View File

@@ -0,0 +1,108 @@
"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _a, _CLIPlugin_progressStates;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CLIPlugin = void 0;
class CLIPlugin {
constructor(options) {
this.options = options;
}
async setupBundleAnalyzerPlugin(compiler) {
// eslint-disable-next-line node/no-extraneous-require,@typescript-eslint/no-var-requires
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const bundleAnalyzerPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof BundleAnalyzerPlugin));
if (!bundleAnalyzerPlugin) {
new BundleAnalyzerPlugin().apply(compiler);
}
}
setupProgressPlugin(compiler) {
const { ProgressPlugin } = compiler.webpack || require("webpack");
const progressPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof ProgressPlugin));
if (progressPlugin) {
return;
}
const isProfile = this.options.progress === "profile";
const options = {
profile: isProfile,
};
if (this.options.isMultiCompiler && ProgressPlugin.createDefaultHandler) {
const handler = ProgressPlugin.createDefaultHandler(isProfile, compiler.getInfrastructureLogger("webpack.Progress"));
const idx = __classPrivateFieldGet(CLIPlugin, _a, "f", _CLIPlugin_progressStates).length;
__classPrivateFieldGet(CLIPlugin, _a, "f", _CLIPlugin_progressStates)[idx] = [0];
options.handler = (p, msg, ...args) => {
__classPrivateFieldGet(CLIPlugin, _a, "f", _CLIPlugin_progressStates)[idx] = [p, msg, ...args];
let sum = 0;
for (const [p] of __classPrivateFieldGet(CLIPlugin, _a, "f", _CLIPlugin_progressStates)) {
sum += p;
}
handler(sum / __classPrivateFieldGet(CLIPlugin, _a, "f", _CLIPlugin_progressStates).length, `[${compiler.name ? compiler.name : idx}] ${msg}`, ...args);
};
}
new ProgressPlugin(options).apply(compiler);
}
setupHelpfulOutput(compiler) {
const pluginName = "webpack-cli";
const getCompilationName = () => (compiler.name ? `'${compiler.name}'` : "");
const logCompilation = (message) => {
if (process.env.WEBPACK_CLI_START_FINISH_FORCE_LOG) {
process.stderr.write(message);
}
else {
this.logger.log(message);
}
};
const { configPath } = this.options;
compiler.hooks.run.tap(pluginName, () => {
const name = getCompilationName();
logCompilation(`Compiler${name ? ` ${name}` : ""} starting... `);
if (configPath) {
this.logger.log(`Compiler${name ? ` ${name}` : ""} is using config: ${configPath
.map((path) => `'${path}'`)
.join(", ")}`);
}
});
compiler.hooks.watchRun.tap(pluginName, (compiler) => {
const { bail, watch } = compiler.options;
if (bail && watch) {
this.logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.');
}
const name = getCompilationName();
logCompilation(`Compiler${name ? ` ${name}` : ""} starting... `);
if (configPath) {
this.logger.log(`Compiler${name ? ` ${name}` : ""} is using config: '${configPath}'`);
}
});
compiler.hooks.invalid.tap(pluginName, (filename, changeTime) => {
const date = new Date(changeTime);
this.logger.log(`File '${filename}' was modified`);
this.logger.log(`Changed time is ${date} (timestamp is ${changeTime})`);
});
(compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(pluginName, () => {
const name = getCompilationName();
logCompilation(`Compiler${name ? ` ${name}` : ""} finished`);
process.nextTick(() => {
if (compiler.watchMode) {
this.logger.log(`Compiler${name ? `${name}` : ""} is watching files for updates...`);
}
});
});
}
apply(compiler) {
this.logger = compiler.getInfrastructureLogger("webpack-cli");
if (this.options.progress) {
this.setupProgressPlugin(compiler);
}
if (this.options.analyze) {
this.setupBundleAnalyzerPlugin(compiler);
}
this.setupHelpfulOutput(compiler);
}
}
exports.CLIPlugin = CLIPlugin;
_a = CLIPlugin;
_CLIPlugin_progressStates = { value: [] };
module.exports = CLIPlugin;

230
node_modules/webpack-cli/lib/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,230 @@
/// <reference types="node" />
import type { EntryOptions, Stats, Configuration, WebpackError, StatsOptions, WebpackOptionsNormalized, Compiler, MultiCompiler, Problem, Argument, AssetEmittedInfo, FileCacheOptions } from "webpack";
import type webpack from "webpack";
import type { ClientConfiguration, Configuration as DevServerConfig } from "webpack-dev-server";
import { type Colorette } from "colorette";
import { type Command, type CommandOptions, type Option, type ParseOptions } from "commander";
import { type prepare } from "rechoir";
import { type stringifyStream } from "@discoveryjs/json-ext";
/**
* Webpack CLI
*/
interface IWebpackCLI {
colors: WebpackCLIColors;
logger: WebpackCLILogger;
isColorSupportChanged: boolean | undefined;
webpack: typeof webpack;
builtInOptionsCache: WebpackCLIBuiltInOption[] | undefined;
program: WebpackCLICommand;
isMultipleCompiler(compiler: WebpackCompiler): compiler is MultiCompiler;
isPromise<T>(value: Promise<T>): value is Promise<T>;
isFunction(value: unknown): value is CallableFunction;
getLogger(): WebpackCLILogger;
createColors(useColors?: boolean): WebpackCLIColors;
toKebabCase: StringFormatter;
capitalizeFirstLetter: StringFormatter;
checkPackageExists(packageName: string): boolean;
getAvailablePackageManagers(): PackageManager[];
getDefaultPackageManager(): PackageManager | undefined;
doInstall(packageName: string, options?: PackageInstallOptions): Promise<string>;
loadJSONFile<T = unknown>(path: Path, handleError: boolean): Promise<T>;
tryRequireThenImport<T = unknown>(module: ModuleName, handleError: boolean): Promise<T>;
getInfoOptions(): WebpackCLIBuiltInOption[];
getInfoOutput(options: {
output: string;
additionalPackage: string[];
}): Promise<string>;
makeCommand(commandOptions: WebpackCLIOptions, options: WebpackCLICommandOptions, action: CommandAction): Promise<WebpackCLICommand | undefined>;
makeOption(command: WebpackCLICommand, option: WebpackCLIBuiltInOption): void;
run(args: Parameters<WebpackCLICommand["parseOptions"]>[0], parseOptions?: ParseOptions): Promise<void>;
getBuiltInOptions(): WebpackCLIBuiltInOption[];
loadWebpack(handleError?: boolean): Promise<typeof webpack>;
loadConfig(options: Partial<WebpackDevServerOptions>): Promise<WebpackCLIConfig>;
buildConfig(config: WebpackCLIConfig, options: WebpackDevServerOptions): Promise<WebpackCLIConfig>;
isValidationError(error: Error): error is WebpackError;
createCompiler(options: Partial<WebpackDevServerOptions>, callback?: Callback<[Error | undefined, WebpackCLIStats | undefined]>): Promise<WebpackCompiler>;
needWatchStdin(compiler: Compiler | MultiCompiler): boolean;
runWebpack(options: WebpackRunOptions, isWatchCommand: boolean): Promise<void>;
}
interface WebpackCLIColors extends Colorette {
isColorSupported: boolean;
}
interface WebpackCLILogger {
error: LogHandler;
warn: LogHandler;
info: LogHandler;
success: LogHandler;
log: LogHandler;
raw: LogHandler;
}
interface WebpackCLICommandOption extends CommanderOption {
helpLevel?: "minimum" | "verbose";
}
interface WebpackCLIConfig {
options: WebpackConfiguration | WebpackConfiguration[];
path: WeakMap<object, string[]>;
}
interface WebpackCLICommand extends Command {
pkg: string | undefined;
forHelp: boolean | undefined;
_args: WebpackCLICommandOption[];
}
interface WebpackCLIStats extends Stats {
presetToOptions?: (item: string | boolean) => StatsOptions;
}
type WebpackCLIMainOption = Pick<WebpackCLIBuiltInOption, "valueName" | "description" | "defaultValue" | "multiple"> & {
flags: string;
type: Set<BooleanConstructor | StringConstructor | NumberConstructor>;
};
interface WebpackCLIOptions extends CommandOptions {
name: string;
alias: string | string[];
description?: string;
usage?: string;
dependencies?: string[];
pkg?: string;
argsDescription?: {
[argName: string]: string;
};
}
type WebpackCLICommandOptions = WebpackCLIBuiltInOption[] | (() => Promise<WebpackCLIBuiltInOption[]>);
interface WebpackCLIBuiltInFlag {
name: string;
alias?: string;
type?: (value: string, previous: Record<string, BasicPrimitive | object>) => Record<string, BasicPrimitive | object>;
configs?: Partial<FlagConfig>[];
negative?: boolean;
multiple?: boolean;
valueName?: string;
description: string;
describe?: string;
negatedDescription?: string;
defaultValue?: string;
helpLevel: "minimum" | "verbose";
}
interface WebpackCLIBuiltInOption extends WebpackCLIBuiltInFlag {
hidden?: boolean;
group?: "core";
}
type WebpackCLIExternalCommandInfo = Pick<WebpackCLIOptions, "name" | "alias" | "description"> & {
pkg: string;
};
/**
* Webpack dev server
*/
type WebpackDevServerOptions = DevServerConfig & WebpackConfiguration & ClientConfiguration & AssetEmittedInfo & WebpackOptionsNormalized & FileCacheOptions & Argv & {
nodeEnv?: "string";
watchOptionsStdin?: boolean;
progress?: boolean | "profile" | undefined;
analyze?: boolean;
prefetch?: string;
json?: boolean;
entry: EntryOptions;
merge?: boolean;
config: string[];
configName?: string[];
disableInterpret?: boolean;
extends?: string[];
argv: Argv;
};
type Callback<T extends unknown[]> = (...args: T) => void;
/**
* Webpack
*/
type WebpackConfiguration = Configuration;
type ConfigOptions = PotentialPromise<WebpackConfiguration | CallableOption>;
type CallableOption = (env: Env | undefined, argv: Argv) => WebpackConfiguration;
type WebpackCompiler = Compiler | MultiCompiler;
type FlagType = boolean | "enum" | "string" | "path" | "number" | "boolean" | "RegExp" | "reset";
type FlagConfig = {
negatedDescription: string;
type: FlagType;
values: FlagType[];
};
type FileSystemCacheOptions = WebpackConfiguration & {
cache: FileCacheOptions & {
defaultConfig: string[];
};
};
type ProcessedArguments = Record<string, BasicPrimitive | RegExp | (BasicPrimitive | RegExp)[]>;
type CommandAction = Parameters<WebpackCLICommand["action"]>[0];
interface WebpackRunOptions extends WebpackOptionsNormalized {
progress?: boolean | "profile";
json?: boolean;
argv?: Argv;
env: Env;
failOnWarnings?: boolean;
isWatchingLikeCommand?: boolean;
}
/**
* Package management
*/
type PackageManager = "pnpm" | "yarn" | "npm";
interface PackageInstallOptions {
preMessage?: () => void;
}
interface BasicPackageJsonContent {
name: string;
version: string;
description: string;
license: string;
}
/**
* Plugins and util types
*/
interface CLIPluginOptions {
isMultiCompiler?: boolean;
configPath?: string[];
helpfulOutput: boolean;
hot?: boolean | "only";
progress?: boolean | "profile";
prefetch?: string;
analyze?: boolean;
}
type BasicPrimitive = string | boolean | number;
type Instantiable<InstanceType = unknown, ConstructorParameters extends unknown[] = unknown[]> = {
new (...args: ConstructorParameters): InstanceType;
};
type PotentialPromise<T> = T | Promise<T>;
type ModuleName = string;
type Path = string;
type LogHandler = (value: any) => void;
type StringFormatter = (value: string) => string;
interface Argv extends Record<string, any> {
env?: Env;
}
interface Env {
WEBPACK_BUNDLE?: boolean;
WEBPACK_BUILD?: boolean;
WEBPACK_WATCH?: boolean;
WEBPACK_SERVE?: boolean;
WEBPACK_PACKAGE?: string;
WEBPACK_DEV_SERVER_PACKAGE?: string;
}
type DynamicImport<T> = (url: string) => Promise<{
default: T;
}>;
interface ImportLoaderError extends Error {
code?: string;
}
/**
* External libraries types
*/
type OptionConstructor = new (flags: string, description?: string) => Option;
type CommanderOption = InstanceType<OptionConstructor>;
interface Rechoir {
prepare: typeof prepare;
}
interface JsonExt {
stringifyStream: typeof stringifyStream;
}
interface RechoirError extends Error {
failures: RechoirError[];
error: Error;
}
interface PromptOptions {
message: string;
defaultResponse: string;
stream: NodeJS.WritableStream;
}
export { IWebpackCLI, WebpackCLICommandOption, WebpackCLIBuiltInOption, WebpackCLIBuiltInFlag, WebpackCLIColors, WebpackCLIStats, WebpackCLIConfig, WebpackCLIExternalCommandInfo, WebpackCLIOptions, WebpackCLICommand, WebpackCLICommandOptions, WebpackCLIMainOption, WebpackCLILogger, WebpackDevServerOptions, WebpackRunOptions, WebpackCompiler, WebpackConfiguration, Argv, Argument, BasicPrimitive, BasicPackageJsonContent, CallableOption, Callback, CLIPluginOptions, CommandAction, CommanderOption, CommandOptions, ConfigOptions, DynamicImport, FileSystemCacheOptions, FlagConfig, ImportLoaderError, Instantiable, JsonExt, ModuleName, PackageInstallOptions, PackageManager, Path, ProcessedArguments, PromptOptions, Problem, PotentialPromise, Rechoir, RechoirError, };

2
node_modules/webpack-cli/lib/types.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function dynamicImportLoader() {
let importESM;
try {
importESM = new Function("id", "return import(id);");
}
catch (e) {
importESM = null;
}
return importESM;
}
module.exports = dynamicImportLoader;

1
node_modules/webpack-cli/lib/webpack-cli.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

1892
node_modules/webpack-cli/lib/webpack-cli.js generated vendored Normal file

File diff suppressed because it is too large Load Diff