From ee9bf2dc97503cd297058bfe8d69477bca89a4a1 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sun, 5 May 2019 01:38:54 -0700 Subject: [PATCH] [react-dev-utils] Update for 9.0.0 (#35207) * feat: Update react-dev-utils for 9.0.0 * bump header version * add new files to tsconfig * lint * lint again... --- .../WebpackDevServerUtils.d.ts | 13 +- .../errorOverlayMiddleware.d.ts | 4 + .../formatWebpackMessages.d.ts | 14 +-- types/react-dev-utils/ignoredFiles.d.ts | 2 + types/react-dev-utils/index.d.ts | 2 +- types/react-dev-utils/test/webpack-utils.ts | 4 +- types/react-dev-utils/tsconfig.json | 2 + types/webpack/index.d.ts | 114 +++++++++++++++++- 8 files changed, 136 insertions(+), 19 deletions(-) create mode 100644 types/react-dev-utils/errorOverlayMiddleware.d.ts create mode 100644 types/react-dev-utils/ignoredFiles.d.ts diff --git a/types/react-dev-utils/WebpackDevServerUtils.d.ts b/types/react-dev-utils/WebpackDevServerUtils.d.ts index 08d2ae0ebe..fc86c927cd 100644 --- a/types/react-dev-utils/WebpackDevServerUtils.d.ts +++ b/types/react-dev-utils/WebpackDevServerUtils.d.ts @@ -18,17 +18,16 @@ export function choosePort(host: string, defaultPort: number): Promise // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/react-dev-utils/test/webpack-utils.ts b/types/react-dev-utils/test/webpack-utils.ts index d68483c0a2..c7c7cc44d1 100644 --- a/types/react-dev-utils/test/webpack-utils.ts +++ b/types/react-dev-utils/test/webpack-utils.ts @@ -39,9 +39,9 @@ WebpackDevServerUtils.choosePort('localhost', 3000); const urls = WebpackDevServerUtils.prepareUrls('http', 'localhost', 3000); // $ExpectType Compiler -WebpackDevServerUtils.createCompiler(webpack, {}, 'app', urls, true); +WebpackDevServerUtils.createCompiler({ webpack, config: {}, appName: 'app', urls, useYarn: true }); -// $ExpectType Configuration +// $ExpectType ProxyConfigArrayItem[] WebpackDevServerUtils.prepareProxy(undefined, 'build'); const loaderContext: webpack.loader.LoaderContext = null!; diff --git a/types/react-dev-utils/tsconfig.json b/types/react-dev-utils/tsconfig.json index dc5c861101..01022ecf4d 100644 --- a/types/react-dev-utils/tsconfig.json +++ b/types/react-dev-utils/tsconfig.json @@ -20,12 +20,14 @@ "index.d.ts", "checkRequiredFiles.d.ts", "clearConsole.d.ts", + "errorOverlayMiddleware.d.ts", "eslintFormatter.d.ts", "FileSizeReporter.d.ts", "formatWebpackMessages.d.ts", "getCacheIdentifier.d.ts", "getCSSModuleLocalIdent.d.ts", "getProcessForPort.d.ts", + "ignoredFiles.d.ts", "InlineChunkHtmlPlugin.d.ts", "InterpolateHtmlPlugin.d.ts", "launchEditor.d.ts", diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index d4b61d996c..050e250f79 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -1149,7 +1149,7 @@ declare namespace webpack { /** Returns true if there were warnings while compiling. */ hasWarnings(): boolean; /** Returns compilation information as a JSON object. */ - toJson(options?: Stats.ToJsonOptions): any; + toJson(options?: Stats.ToJsonOptions, forToString?: boolean): Stats.ToJsonOutput; /** Returns a formatted string of the compilation information (similar to CLI output). */ toString(options?: Stats.ToStringOptions): string; } @@ -1238,6 +1238,118 @@ declare namespace webpack { type ToJsonOptions = Preset | ToJsonOptionsObject; + interface ChunkGroup { + assets: string[]; + chunks: number[]; + children: Record; + childAssets: Record; + isOverSizeLimit?: boolean; + } + interface FnModules { + assets?: string[]; + built: boolean; + cacheable: boolean; + chunks: number[]; + depth?: number; + errors: number; + failed: boolean; + filteredModules?: boolean; + id: number | string; + identifier: string; + index: number; + index2: number; + issuer: string | undefined; + issuerId: number | string | undefined; + issuerName: string | undefined; + issuerPath: Array<{ + id: number | string; + identifier: string; + name: string; + profile: any; // TODO + }>; + modules: FnModules[]; + name: string; + optimizationBailout?: string; + optional: boolean; + prefetched: boolean; + profile: any; // TODO + providedExports?: any; // TODO + reasons: { + explanation: string | undefined; + loc?: string; + module: string | null; + moduleId: number | string | null; + moduleIdentifier: string | null; + moduleName: string | null; + type: any; // TODO + userRequest: any; // TODO + }; + size: number; + source?: string; + usedExports?: boolean; + warnings: number; + } + interface ToJsonOutput { + _showErrors: boolean; + _showWarnings: boolean; + assets?: Array<{ + chunks: number[]; + chunkNames: string[]; + emitted: boolean; + isOverSizeLimit?: boolean; + name: string; + size: number; + }>; + assetsByChunkName?: Record>; + builtAt?: number; + children?: ToJsonOptions[] & { name?: string }; + chunks?: { + children: number[]; + childrenByOrder: Record; + entry: boolean; + files: string[]; + filteredModules?: boolean; + hash: string | undefined; + id: number; + initial: boolean; + modules?: FnModules[]; + names: string[]; + origins?: Array<{ + moduleId: string | number | undefined; + module: string; + moduleIdentifier: string; + moduleName: string; + loc: string; + request: string; + reasons: string[]; + }>; + parents: number[]; + reason: string | undefined; + recorded: undefined; + rendered: boolean; + size: number; + siblings: number[]; + }; + entrypoints?: Record; + errors: string[]; + env?: Record; + filteredAssets?: number; + filteredModules?: boolean; + hash?: string; + modules?: FnModules[]; + namedChunkGroups?: Record; + needAdditionalPass?: boolean; + outputPath?: string; + publicPath?: string; + time?: number; + version?: string; + warnings: string[]; + } + type StatsExcludeFilter = string | string[] | RegExp | RegExp[] | ((assetName: string) => boolean) | Array<(assetName: string) => boolean>; interface ToStringOptionsObject extends ToJsonOptionsObject {