webpack-cli
Advanced tools
Comparing version 4.10.0 to 5.0.1
@@ -21,3 +21,1 @@ "use strict"; | ||
module.exports = CLI; | ||
// TODO remove after drop `@webpack-cli/migrate` | ||
module.exports.utils = { logger: console }; |
@@ -7,4 +7,2 @@ import { Compiler } from "webpack"; | ||
constructor(options: CLIPluginOptions); | ||
setupHotPlugin(compiler: Compiler): void; | ||
setupPrefetchPlugin(compiler: Compiler): void; | ||
setupBundleAnalyzerPlugin(compiler: Compiler): Promise<void>; | ||
@@ -11,0 +9,0 @@ setupProgressPlugin(compiler: Compiler): void; |
@@ -8,13 +8,2 @@ "use strict"; | ||
} | ||
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) { | ||
@@ -87,8 +76,2 @@ // eslint-disable-next-line node/no-extraneous-require,@typescript-eslint/no-var-requires | ||
} | ||
if (this.options.hot) { | ||
this.setupHotPlugin(compiler); | ||
} | ||
if (this.options.prefetch) { | ||
this.setupPrefetchPlugin(compiler); | ||
} | ||
if (this.options.analyze) { | ||
@@ -95,0 +78,0 @@ this.setupBundleAnalyzerPlugin(compiler); |
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
import { Colorette } from "colorette"; | ||
import { Command, CommandOptions, OptionConstructor, ParseOptions } from "commander"; | ||
import { Command, CommandOptions, Option, ParseOptions } from "commander"; | ||
import { prepare } from "rechoir"; | ||
@@ -32,2 +32,7 @@ import { stringifyStream } from "@discoveryjs/json-ext"; | ||
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>; | ||
@@ -72,3 +77,3 @@ makeOption(command: WebpackCLICommand, option: WebpackCLIBuiltInOption): void; | ||
} | ||
declare type WebpackCLIMainOption = Pick<WebpackCLIBuiltInOption, "description" | "defaultValue" | "multiple"> & { | ||
type WebpackCLIMainOption = Pick<WebpackCLIBuiltInOption, "description" | "defaultValue" | "multiple"> & { | ||
flags: string; | ||
@@ -88,3 +93,3 @@ type: Set<BooleanConstructor | StringConstructor | NumberConstructor>; | ||
} | ||
declare type WebpackCLICommandOptions = WebpackCLIBuiltInOption[] | (() => Promise<WebpackCLIBuiltInOption[]>); | ||
type WebpackCLICommandOptions = WebpackCLIBuiltInOption[] | (() => Promise<WebpackCLIBuiltInOption[]>); | ||
interface WebpackCLIBuiltInFlag { | ||
@@ -107,3 +112,3 @@ name: string; | ||
} | ||
declare type WebpackCLIExternalCommandInfo = Pick<WebpackCLIOptions, "name" | "alias" | "description"> & { | ||
type WebpackCLIExternalCommandInfo = Pick<WebpackCLIOptions, "name" | "alias" | "description"> & { | ||
pkg: string; | ||
@@ -114,3 +119,3 @@ }; | ||
*/ | ||
declare type WebpackDevServerOptions = DevServerConfig & WebpackConfiguration & ClientConfiguration & AssetEmittedInfo & WebpackOptionsNormalized & FileCacheOptions & Argv & { | ||
type WebpackDevServerOptions = DevServerConfig & WebpackConfiguration & ClientConfiguration & AssetEmittedInfo & WebpackOptionsNormalized & FileCacheOptions & Argv & { | ||
nodeEnv?: "string"; | ||
@@ -126,14 +131,15 @@ watchOptionsStdin?: boolean; | ||
configName?: string[]; | ||
disableInterpret?: boolean; | ||
argv: Argv; | ||
}; | ||
declare type Callback<T extends unknown[]> = (...args: T) => void; | ||
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 = { | ||
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; | ||
@@ -143,3 +149,3 @@ type: FlagType; | ||
}; | ||
declare type FileSystemCacheOptions = WebpackConfiguration & { | ||
type FileSystemCacheOptions = WebpackConfiguration & { | ||
cache: FileCacheOptions & { | ||
@@ -149,7 +155,7 @@ defaultConfig: string[]; | ||
}; | ||
declare type ProcessedArguments = Record<string, BasicPrimitive | RegExp | (BasicPrimitive | RegExp)[]>; | ||
declare type MultipleCompilerStatsOptions = StatsOptions & { | ||
type ProcessedArguments = Record<string, BasicPrimitive | RegExp | (BasicPrimitive | RegExp)[]>; | ||
type MultipleCompilerStatsOptions = StatsOptions & { | ||
children: StatsOptions[]; | ||
}; | ||
declare type CommandAction = Parameters<WebpackCLICommand["action"]>[0]; | ||
type CommandAction = Parameters<WebpackCLICommand["action"]>[0]; | ||
interface WebpackRunOptions extends WebpackOptionsNormalized { | ||
@@ -159,2 +165,3 @@ json?: boolean; | ||
env: Env; | ||
failOnWarnings?: boolean; | ||
} | ||
@@ -164,3 +171,3 @@ /** | ||
*/ | ||
declare type PackageManager = "pnpm" | "yarn" | "npm"; | ||
type PackageManager = "pnpm" | "yarn" | "npm"; | ||
interface PackageInstallOptions { | ||
@@ -176,9 +183,2 @@ preMessage?: () => void; | ||
/** | ||
* Webpack V4 | ||
*/ | ||
declare type WebpackV4LegacyStats = Required<WebpackCLIStats>; | ||
interface WebpackV4Compiler extends Compiler { | ||
compiler: Compiler; | ||
} | ||
/** | ||
* Plugins and util types | ||
@@ -194,11 +194,11 @@ */ | ||
} | ||
declare type BasicPrimitive = string | boolean | number; | ||
declare type Instantiable<InstanceType = unknown, ConstructorParameters extends unknown[] = unknown[]> = { | ||
type BasicPrimitive = string | boolean | number; | ||
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; | ||
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> { | ||
@@ -215,3 +215,3 @@ env?: Env; | ||
} | ||
declare type DynamicImport<T> = (url: string) => Promise<{ | ||
type DynamicImport<T> = (url: string) => Promise<{ | ||
default: T; | ||
@@ -225,3 +225,4 @@ }>; | ||
*/ | ||
declare type CommanderOption = InstanceType<OptionConstructor>; | ||
type OptionConstructor = new (flags: string, description?: string) => Option; | ||
type CommanderOption = InstanceType<OptionConstructor>; | ||
interface Rechoir { | ||
@@ -242,2 +243,2 @@ prepare: typeof prepare; | ||
} | ||
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, }; | ||
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, MultipleCompilerStatsOptions, PackageInstallOptions, PackageManager, Path, ProcessedArguments, PromptOptions, Problem, PotentialPromise, Rechoir, RechoirError, }; |
{ | ||
"name": "webpack-cli", | ||
"version": "4.10.0", | ||
"version": "5.0.1", | ||
"description": "CLI for webpack & friends", | ||
@@ -21,3 +21,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=10.13.0" | ||
"node": ">=14.15.0" | ||
}, | ||
@@ -39,16 +39,20 @@ "keywords": [ | ||
"@discoveryjs/json-ext": "^0.5.0", | ||
"@webpack-cli/configtest": "^1.2.0", | ||
"@webpack-cli/info": "^1.5.0", | ||
"@webpack-cli/serve": "^1.7.0", | ||
"@webpack-cli/configtest": "^2.0.1", | ||
"@webpack-cli/info": "^2.0.1", | ||
"@webpack-cli/serve": "^2.0.1", | ||
"colorette": "^2.0.14", | ||
"commander": "^7.0.0", | ||
"commander": "^9.4.1", | ||
"cross-spawn": "^7.0.3", | ||
"envinfo": "^7.7.3", | ||
"fastest-levenshtein": "^1.0.12", | ||
"import-local": "^3.0.2", | ||
"interpret": "^2.2.0", | ||
"rechoir": "^0.7.0", | ||
"interpret": "^3.1.1", | ||
"rechoir": "^0.8.0", | ||
"webpack-merge": "^5.7.3" | ||
}, | ||
"devDependencies": { | ||
"@types/envinfo": "^7.8.1" | ||
}, | ||
"peerDependencies": { | ||
"webpack": "4.x.x || 5.x.x" | ||
"webpack": "5.x.x" | ||
}, | ||
@@ -59,5 +63,2 @@ "peerDependenciesMeta": { | ||
}, | ||
"@webpack-cli/migrate": { | ||
"optional": true | ||
}, | ||
"webpack-bundle-analyzer": { | ||
@@ -70,3 +71,3 @@ "optional": true | ||
}, | ||
"gitHead": "20882d463450d010bb76e0824fe555e9785e9561" | ||
"gitHead": "4a0f89380b3f920652bda7dfc0c23405099b94b8" | ||
} |
@@ -72,3 +72,2 @@ <div align="center"> | ||
loader|l [output-path] [options] Scaffold a loader. | ||
migrate|m <config-path> [new-config-path] Migrate a configuration to a new version. | ||
plugin|p [output-path] [options] Scaffold a plugin. | ||
@@ -80,40 +79,39 @@ serve|server|s [entries...] [options] Run the webpack dev server. | ||
### webpack 4 | ||
### Available Options | ||
``` | ||
Options: | ||
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information | ||
-c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js. | ||
--config-name <value...> Name of the configuration to use. | ||
-m, --merge Merge two or more configurations using 'webpack-merge'. | ||
--env <value...> Environment passed to the configuration when it is a function. | ||
--node-env <value> Sets process.env.NODE_ENV to the specified value. | ||
--progress [value] Print compilation progress during build. | ||
-j, --json [value] Prints result as JSON or store it in a file. | ||
-d, --devtool <value> Determine source maps to use. | ||
--no-devtool Do not generate source maps. | ||
--entry <value...> The entry point(s) of your application e.g. ./src/main.js. | ||
-h, --hot [value] Enables Hot Module Replacement | ||
--no-hot Disables Hot Module Replacement | ||
--mode <value> Defines the mode to pass to webpack. | ||
--name <value> Name of the configuration. Used when loading multiple configurations. | ||
-o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/. | ||
--prefetch <value> Prefetch this request | ||
--stats [value] It instructs webpack on how to treat the stats e.g. verbose. | ||
--no-stats Disable stats output. | ||
-t, --target <value...> Sets the build target e.g. node. | ||
-w, --watch Watch for files changes. | ||
--no-watch Do not watch for file changes. | ||
--watch-options-stdin Stop watching when stdin stream has ended. | ||
--no-watch-options-stdin Do not stop watching when stdin stream has ended. | ||
Options: | ||
-c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js. | ||
--config-name <value...> Name of the configuration to use. | ||
-m, --merge Merge two or more configurations using 'webpack-merge'. | ||
--disable-interpret Disable interpret for loading the config file. | ||
--env <value...> Environment passed to the configuration when it is a function. | ||
--node-env <value> Sets process.env.NODE_ENV to the specified value. | ||
--define-process-env-node-env <value> Sets process.env.NODE_ENV to the specified value. (Currently an alias for `--node-env`) | ||
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information. | ||
--progress [value] Print compilation progress during build. | ||
-j, --json [value] Prints result as JSON or store it in a file. | ||
--fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack | ||
-d, --devtool <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). | ||
--no-devtool Negative 'devtool' option. | ||
--entry <value...> A module that is loaded upon startup. Only the last one is exported. | ||
--mode <value> Enable production optimizations or development hints. | ||
--name <value> Name of the configuration. Used when loading multiple configurations. | ||
-o, --output-path <value> The output directory as **absolute path** (required). | ||
--stats [value] Stats options object or preset name. | ||
--no-stats Negative 'stats' option. | ||
-t, --target <value...> Environment to build for. Environment to build for. An array of environments to build for all of them when possible. | ||
--no-target Negative 'target' option. | ||
-w, --watch Enter watch mode, which rebuilds on file change. | ||
--no-watch Negative 'watch' option. | ||
--watch-options-stdin Stop watching when stdin stream has ended. | ||
--no-watch-options-stdin Negative 'watch-options-stdin' option. | ||
Global options: | ||
--color Enable colors on console. | ||
--no-color Disable colors on console. | ||
-v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. | ||
-h, --help [verbose] Display help for commands and options. | ||
--color Enable colors on console. | ||
--no-color Disable colors on console. | ||
-v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. | ||
-h, --help [verbose] Display help for commands and options. | ||
``` | ||
### webpack 5 | ||
Checkout [`OPTIONS.md`](https://github.com/webpack/webpack-cli/blob/master/OPTIONS.md) to see list of all available options. | ||
@@ -120,0 +118,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102507
14
1
2143
146
18
+ Addedenvinfo@^7.7.3
+ Added@webpack-cli/configtest@2.1.1(transitive)
+ Added@webpack-cli/info@2.0.2(transitive)
+ Added@webpack-cli/serve@2.0.5(transitive)
+ Addedcommander@9.5.0(transitive)
+ Addedinterpret@3.1.1(transitive)
+ Addedrechoir@0.8.0(transitive)
- Removed@webpack-cli/configtest@1.2.0(transitive)
- Removed@webpack-cli/info@1.5.0(transitive)
- Removed@webpack-cli/serve@1.7.0(transitive)
- Removedcommander@7.2.0(transitive)
- Removedinterpret@2.2.0(transitive)
- Removedrechoir@0.7.1(transitive)
Updated@webpack-cli/info@^2.0.1
Updated@webpack-cli/serve@^2.0.1
Updatedcommander@^9.4.1
Updatedinterpret@^3.1.1
Updatedrechoir@^0.8.0