[cli-dev-mode/optimizer] omit pageLoadAssetSizeLimit from cache (#95826)

Co-authored-by: spalger <spalger@users.noreply.github.com>
This commit is contained in:
Spencer 2021-03-30 15:08:12 -07:00 committed by GitHub
parent cd4483f391
commit 2010f4eba1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 29 additions and 12 deletions

View file

@ -135,6 +135,7 @@ it('passes correct args to sub-classes', () => {
"repoRoot": <absolute path>,
"runExamples": false,
"silent": false,
"verbose": false,
"watch": true,
},
],

View file

@ -37,6 +37,7 @@ export type SomeCliArgs = Pick<
CliArgs,
| 'quiet'
| 'silent'
| 'verbose'
| 'disableOptimizer'
| 'watch'
| 'oss'
@ -148,6 +149,7 @@ export class CliDevMode {
dist: cliArgs.dist,
quiet: !!cliArgs.quiet,
silent: !!cliArgs.silent,
verbose: !!cliArgs.verbose,
watch: cliArgs.watch,
});
}

View file

@ -46,6 +46,7 @@ const defaultOptions: Options = {
pluginScanDirs: ['/some-scan-path'],
quiet: true,
silent: true,
verbose: false,
repoRoot: '/app',
runExamples: true,
watch: true,

View file

@ -25,6 +25,7 @@ export interface Options {
repoRoot: string;
quiet: boolean;
silent: boolean;
verbose: boolean;
watch: boolean;
cache: boolean;
dist: boolean;
@ -80,6 +81,7 @@ export class Optimizer {
const { flags: levelFlags } = parseLogLevel(
pickLevelFromFlags({
verbose: options.verbose,
quiet: options.quiet,
silent: options.silent,
})

View file

@ -24,6 +24,7 @@ export interface CliArgs {
/** @deprecated */
quiet?: boolean;
silent?: boolean;
verbose?: boolean;
watch: boolean;
basePath: boolean;
oss: boolean;

View file

@ -42,7 +42,6 @@ it('creates cache keys', () => {
"id": "bar",
"manifestPath": undefined,
"outputDir": "/foo/bar/target",
"pageLoadAssetSizeLimit": undefined,
"publicDirNames": Array [
"public",
],

View file

@ -11,6 +11,7 @@ import Fs from 'fs';
import { BundleCache } from './bundle_cache';
import { UnknownVals } from './ts_helpers';
import { omit } from './obj_helpers';
import { includes, ascending, entriesToObject } from './array_helpers';
const VALID_BUNDLE_TYPES = ['plugin' as const, 'entry' as const];
@ -90,7 +91,7 @@ export class Bundle {
*/
createCacheKey(files: string[], mtimes: Map<string, number | undefined>): unknown {
return {
spec: this.toSpec(),
spec: omit(this.toSpec(), ['pageLoadAssetSizeLimit']),
mtimes: entriesToObject(
files.map((p) => [p, mtimes.get(p)] as const).sort(ascending((e) => e[0]))
),

View file

@ -18,3 +18,4 @@ export * from './array_helpers';
export * from './event_stream_helpers';
export * from './parse_path';
export * from './theme_tags';
export * from './obj_helpers';

View file

@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
export function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {
const result: any = {};
for (const [key, value] of Object.entries(obj) as any) {
if (!keys.includes(key)) {
result[key] = value;
}
}
return result as Omit<T, K>;
}

View file

@ -17,6 +17,7 @@ import {
ThemeTag,
ThemeTags,
parseThemeTags,
omit,
} from '../common';
import { findKibanaPlatformPlugins, KibanaPlatformPlugin } from './kibana_platform_plugins';
@ -40,16 +41,6 @@ function pickMaxWorkerCount(dist: boolean) {
return Math.max(maxWorkers, 2);
}
function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {
const result: any = {};
for (const [key, value] of Object.entries(obj) as any) {
if (!keys.includes(key)) {
result[key] = value;
}
}
return result as Omit<T, K>;
}
interface Options {
/** absolute path to root of the repo/build */
repoRoot: string;

View file

@ -228,6 +228,7 @@ export default function (program) {
// no longer supported
quiet: !!opts.quiet,
silent: !!opts.silent,
verbose: !!opts.verbose,
watch: !!opts.watch,
runExamples: !!opts.runExamples,
// We want to run without base path when the `--run-examples` flag is given so that we can use local