$
This commit is contained in:
1
node_modules/webpack-cli/lib/bootstrap.d.ts
generated
vendored
Normal file
1
node_modules/webpack-cli/lib/bootstrap.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
16
node_modules/webpack-cli/lib/bootstrap.js
generated
vendored
Normal file
16
node_modules/webpack-cli/lib/bootstrap.js
generated
vendored
Normal 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
1
node_modules/webpack-cli/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./types";
|
22
node_modules/webpack-cli/lib/index.js
generated
vendored
Normal file
22
node_modules/webpack-cli/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./types"), exports);
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const CLI = require("./webpack-cli");
|
||||
module.exports = CLI;
|
||||
// TODO remove after drop `@webpack-cli/migrate`
|
||||
module.exports.utils = { logger: console };
|
13
node_modules/webpack-cli/lib/plugins/CLIPlugin.d.ts
generated
vendored
Normal file
13
node_modules/webpack-cli/lib/plugins/CLIPlugin.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Compiler } from "webpack";
|
||||
import { CLIPluginOptions } from "../types";
|
||||
export declare class CLIPlugin {
|
||||
logger: ReturnType<Compiler["getInfrastructureLogger"]>;
|
||||
options: CLIPluginOptions;
|
||||
constructor(options: CLIPluginOptions);
|
||||
setupHotPlugin(compiler: Compiler): void;
|
||||
setupPrefetchPlugin(compiler: Compiler): void;
|
||||
setupBundleAnalyzerPlugin(compiler: Compiler): Promise<void>;
|
||||
setupProgressPlugin(compiler: Compiler): void;
|
||||
setupHelpfulOutput(compiler: Compiler): void;
|
||||
apply(compiler: Compiler): void;
|
||||
}
|
99
node_modules/webpack-cli/lib/plugins/CLIPlugin.js
generated
vendored
Normal file
99
node_modules/webpack-cli/lib/plugins/CLIPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CLIPlugin = void 0;
|
||||
class CLIPlugin {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
}
|
||||
setupHotPlugin(compiler) {
|
||||
const { HotModuleReplacementPlugin } = compiler.webpack || require("webpack");
|
||||
const hotModuleReplacementPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof HotModuleReplacementPlugin));
|
||||
if (!hotModuleReplacementPlugin) {
|
||||
new HotModuleReplacementPlugin().apply(compiler);
|
||||
}
|
||||
}
|
||||
setupPrefetchPlugin(compiler) {
|
||||
const { PrefetchPlugin } = compiler.webpack || require("webpack");
|
||||
new PrefetchPlugin(null, this.options.prefetch).apply(compiler);
|
||||
}
|
||||
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) {
|
||||
new ProgressPlugin({
|
||||
profile: this.options.progress === "profile",
|
||||
}).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}'`);
|
||||
}
|
||||
});
|
||||
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.hot) {
|
||||
this.setupHotPlugin(compiler);
|
||||
}
|
||||
if (this.options.prefetch) {
|
||||
this.setupPrefetchPlugin(compiler);
|
||||
}
|
||||
if (this.options.analyze) {
|
||||
this.setupBundleAnalyzerPlugin(compiler);
|
||||
}
|
||||
this.setupHelpfulOutput(compiler);
|
||||
}
|
||||
}
|
||||
exports.CLIPlugin = CLIPlugin;
|
||||
module.exports = CLIPlugin;
|
227
node_modules/webpack-cli/lib/types.d.ts
generated
vendored
Normal file
227
node_modules/webpack-cli/lib/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,227 @@
|
||||
/// <reference types="node" />
|
||||
import webpack, { EntryOptions, Stats, Configuration, WebpackError, StatsOptions, WebpackOptionsNormalized, Compiler, MultiCompiler, Problem, Argument, AssetEmittedInfo, FileCacheOptions } from "webpack";
|
||||
import { ClientConfiguration, Configuration as DevServerConfig } from "webpack-dev-server";
|
||||
import { Colorette } from "colorette";
|
||||
import { Command, CommandOptions, OptionConstructor, ParseOptions } from "commander";
|
||||
import { prepare } from "rechoir";
|
||||
import { 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>;
|
||||
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;
|
||||
options: WebpackCLICommandOption[];
|
||||
_args: WebpackCLICommandOption[];
|
||||
}
|
||||
interface WebpackCLIStats extends Stats {
|
||||
presetToOptions?: (item: string | boolean) => StatsOptions;
|
||||
}
|
||||
declare type WebpackCLIMainOption = Pick<WebpackCLIBuiltInOption, "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;
|
||||
};
|
||||
}
|
||||
declare 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;
|
||||
description: string;
|
||||
describe?: string;
|
||||
negatedDescription?: string;
|
||||
defaultValue?: string;
|
||||
}
|
||||
interface WebpackCLIBuiltInOption extends WebpackCLIBuiltInFlag {
|
||||
hidden?: boolean;
|
||||
group?: "core";
|
||||
helpLevel?: "minimum" | "verbose";
|
||||
}
|
||||
declare type WebpackCLIExternalCommandInfo = Pick<WebpackCLIOptions, "name" | "alias" | "description"> & {
|
||||
pkg: string;
|
||||
};
|
||||
/**
|
||||
* Webpack dev server
|
||||
*/
|
||||
declare 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[];
|
||||
argv: Argv;
|
||||
};
|
||||
declare type Callback<T extends unknown[]> = (...args: T) => void;
|
||||
/**
|
||||
* Webpack
|
||||
*/
|
||||
declare type WebpackConfiguration = Configuration;
|
||||
declare type ConfigOptions = PotentialPromise<WebpackConfiguration | CallableOption>;
|
||||
declare type CallableOption = (env: Env | undefined, argv: Argv) => WebpackConfiguration;
|
||||
declare type WebpackCompiler = Compiler | MultiCompiler;
|
||||
declare type FlagType = boolean | "enum" | "string" | "path" | "number" | "boolean" | "RegExp" | "reset";
|
||||
declare type FlagConfig = {
|
||||
negatedDescription: string;
|
||||
type: FlagType;
|
||||
values: FlagType[];
|
||||
};
|
||||
declare type FileSystemCacheOptions = WebpackConfiguration & {
|
||||
cache: FileCacheOptions & {
|
||||
defaultConfig: string[];
|
||||
};
|
||||
};
|
||||
declare type ProcessedArguments = Record<string, BasicPrimitive | RegExp | (BasicPrimitive | RegExp)[]>;
|
||||
declare type MultipleCompilerStatsOptions = StatsOptions & {
|
||||
children: StatsOptions[];
|
||||
};
|
||||
declare type CommandAction = Parameters<WebpackCLICommand["action"]>[0];
|
||||
interface WebpackRunOptions extends WebpackOptionsNormalized {
|
||||
json?: boolean;
|
||||
argv?: Argv;
|
||||
env: Env;
|
||||
}
|
||||
/**
|
||||
* Package management
|
||||
*/
|
||||
declare type PackageManager = "pnpm" | "yarn" | "npm";
|
||||
interface PackageInstallOptions {
|
||||
preMessage?: () => void;
|
||||
}
|
||||
interface BasicPackageJsonContent {
|
||||
name: string;
|
||||
version: string;
|
||||
description: string;
|
||||
license: string;
|
||||
}
|
||||
/**
|
||||
* Webpack V4
|
||||
*/
|
||||
declare type WebpackV4LegacyStats = Required<WebpackCLIStats>;
|
||||
interface WebpackV4Compiler extends Compiler {
|
||||
compiler: Compiler;
|
||||
}
|
||||
/**
|
||||
* Plugins and util types
|
||||
*/
|
||||
interface CLIPluginOptions {
|
||||
configPath?: string;
|
||||
helpfulOutput: boolean;
|
||||
hot?: boolean | "only";
|
||||
progress?: boolean | "profile";
|
||||
prefetch?: string;
|
||||
analyze?: boolean;
|
||||
}
|
||||
declare type BasicPrimitive = string | boolean | number;
|
||||
declare type Instantiable<InstanceType = unknown, ConstructorParameters extends unknown[] = unknown[]> = {
|
||||
new (...args: ConstructorParameters): InstanceType;
|
||||
};
|
||||
declare type PotentialPromise<T> = T | Promise<T>;
|
||||
declare type ModuleName = string;
|
||||
declare type Path = string;
|
||||
declare type LogHandler = (value: any) => void;
|
||||
declare 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;
|
||||
}
|
||||
declare type DynamicImport<T> = (url: string) => Promise<{
|
||||
default: T;
|
||||
}>;
|
||||
interface ImportLoaderError extends Error {
|
||||
code?: string;
|
||||
}
|
||||
/**
|
||||
* External libraries types
|
||||
*/
|
||||
declare 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, WebpackV4LegacyStats, WebpackDevServerOptions, WebpackRunOptions, WebpackV4Compiler, WebpackCompiler, WebpackConfiguration, Argv, Argument, BasicPrimitive, BasicPackageJsonContent, CallableOption, Callback, CLIPluginOptions, CommandAction, CommanderOption, CommandOptions, ConfigOptions, DynamicImport, FileSystemCacheOptions, FlagConfig, ImportLoaderError, Instantiable, JsonExt, ModuleName, MultipleCompilerStatsOptions, PackageInstallOptions, PackageManager, Path, ProcessedArguments, PromptOptions, Problem, PotentialPromise, Rechoir, RechoirError, };
|
2
node_modules/webpack-cli/lib/types.js
generated
vendored
Normal file
2
node_modules/webpack-cli/lib/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
1
node_modules/webpack-cli/lib/utils/dynamic-import-loader.d.ts
generated
vendored
Normal file
1
node_modules/webpack-cli/lib/utils/dynamic-import-loader.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
13
node_modules/webpack-cli/lib/utils/dynamic-import-loader.js
generated
vendored
Normal file
13
node_modules/webpack-cli/lib/utils/dynamic-import-loader.js
generated
vendored
Normal 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
1
node_modules/webpack-cli/lib/webpack-cli.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
1905
node_modules/webpack-cli/lib/webpack-cli.js
generated
vendored
Normal file
1905
node_modules/webpack-cli/lib/webpack-cli.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user