MCPcopy Create free account
hub / github.com/webpack/webpack-cli / internalBuildConfig

Method internalBuildConfig

packages/webpack-cli/src/webpack-cli.ts:3270–3409  ·  view source on GitHub ↗
(configuration: Configuration)

Source from the content-addressed store, hash-verified

3268 // it skips the schema-to-arguments walk entirely.
3269 let builtInArgs: ReturnType<(typeof webpack)["cli"]["getArguments"]> | undefined;
3270 const internalBuildConfig = (configuration: Configuration) => {
3271 const originalWatchValue = configuration.watch;
3272
3273 // Apply options
3274 const args: Record<string, WebpackArgument> = {};
3275 const values: ProcessedArguments = {};
3276
3277 for (const name of Object.keys(options)) {
3278 if (INTERNAL_OPTION_KEYS.has(name)) continue;
3279
3280 const kebabName = this.toKebabCase(name);
3281 const arg = (builtInArgs ??= this.#getArguments(options.webpack, undefined))[kebabName];
3282
3283 if (arg) {
3284 args[name] = arg;
3285 // We really don't know what the value is
3286 // eslint-disable-next-line @typescript-eslint/no-explicit-any
3287 values[name] = options[name as keyof Options] as any;
3288 }
3289 }
3290
3291 if (Object.keys(values).length > 0) {
3292 this.#processArguments(options.webpack, args, configuration, values);
3293 }
3294
3295 // Output warnings
3296 if (!Object.isExtensible(configuration)) {
3297 return;
3298 }
3299
3300 if (
3301 options.isWatchingLikeCommand &&
3302 options.argv?.env &&
3303 (typeof originalWatchValue !== "undefined" || typeof options.argv?.watch !== "undefined")
3304 ) {
3305 this.logger.warn(
3306 `No need to use the '${
3307 options.argv.env.WEBPACK_WATCH ? "watch" : "serve"
3308 }' command together with '{ watch: true | false }' or '--watch'/'--no-watch' configuration, it does not make sense.`,
3309 );
3310
3311 if (options.argv.env.WEBPACK_SERVE) {
3312 configuration.watch = false;
3313 }
3314 }
3315
3316 const isFileSystemCacheOptions = (
3317 config: Configuration,
3318 ): config is Configuration & { cache: FileCacheOptions } =>
3319 typeof config.cache !== "undefined" &&
3320 typeof config.cache !== "boolean" &&
3321 config.cache.type === "filesystem";
3322
3323 // Setup default cache options
3324 if (isFileSystemCacheOptions(configuration) && Object.isExtensible(configuration.cache)) {
3325 const configPath = config.path.get(configuration);
3326
3327 if (configPath) {

Callers

nothing calls this directly

Calls 5

toKebabCaseMethod · 0.95
#getArgumentsMethod · 0.95
#processArgumentsMethod · 0.95
getMethod · 0.80

Tested by

no test coverage detected