[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...
This commit is contained in:
Brad Zacher 2019-05-05 01:38:54 -07:00 committed by John Reilly
parent 7fe167420c
commit ee9bf2dc97
8 changed files with 136 additions and 19 deletions

View File

@ -18,17 +18,16 @@ export function choosePort(host: string, defaultPort: number): Promise<number |
/**
* Creates a Webpack compiler instance for WebpackDevServer with built-in
* helpful messages. Takes the `require('webpack')` entry point as the first
* argument. To provide the `urls` argument, use `prepareUrls()` described
* below.
* helpful messages. Takes the `require('webpack')` entry point.
* To provide the `urls` argument, use `prepareUrls()` described below.
*/
export function createCompiler(
_webpack: typeof webpack,
export function createCompiler(opts: {
webpack: typeof webpack,
config: webpack.Configuration,
appName: string,
urls: Urls,
useYarn: boolean,
): webpack.Compiler;
}): webpack.Compiler;
/**
* Creates a WebpackDevServer `proxy` configuration object from the `proxy`
@ -37,7 +36,7 @@ export function createCompiler(
export function prepareProxy(
proxySetting: any,
appPublicFolder: string,
): WebpackDevServer.Configuration;
): WebpackDevServer.ProxyConfigArray;
/**
* Returns an object with local and remote URLs for the development server.

View File

@ -0,0 +1,4 @@
import { RequestHandler } from 'express';
declare function errorOverlayMiddleware(): RequestHandler;
export = errorOverlayMiddleware;

View File

@ -1,16 +1,14 @@
declare namespace formatWebpackMessages {
interface WebpackMessages {
errors: string[];
warnings: string[];
}
}
import { Stats } from 'webpack';
/**
* Extracts and prettifies warning and error messages from webpack
* [stats](https://github.com/webpack/docs/wiki/node.js-api#stats) object.
*/
declare function formatWebpackMessages(
json: formatWebpackMessages.WebpackMessages,
): formatWebpackMessages.WebpackMessages;
json: Stats.ToJsonOutput,
): {
errors: string[];
warnings: string[];
};
export = formatWebpackMessages;

View File

@ -0,0 +1,2 @@
declare function ignoredFiles(appSrc: string): RegExp;
export = ignoredFiles;

View File

@ -1,4 +1,4 @@
// Type definitions for react-dev-utils 7.0
// Type definitions for react-dev-utils 9.0
// Project: https://github.com/facebook/create-react-app#readme
// Definitions by: ark120202 <https://github.com/ark120202>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

View File

@ -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!;

View File

@ -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",

View File

@ -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<string, {
assets: string[];
chunks: number[];
name: string;
}>;
childAssets: Record<string, string[]>;
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<string, Record<string, string[]>>;
builtAt?: number;
children?: ToJsonOptions[] & { name?: string };
chunks?: {
children: number[];
childrenByOrder: Record<string, number[]>;
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<string, ChunkGroup>;
errors: string[];
env?: Record<string, any>;
filteredAssets?: number;
filteredModules?: boolean;
hash?: string;
modules?: FnModules[];
namedChunkGroups?: Record<string, ChunkGroup>;
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 {