Move type definitions used for metro bundler from React Native
Summary: Moves type definitions for uglify and babel from React Native to Metro Bundler. We need it there. Reviewed By: cpojer Differential Revision: D5217795 fbshipit-source-id: 9ec349cd8caf077eaa3c6fa3d090ffd47893e967
This commit is contained in:
parent
9d4cc7cce4
commit
4990c5c5b3
|
@ -1,139 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
type _SourceMap = {
|
||||
file?: string,
|
||||
mappings: string,
|
||||
names: Array<string>,
|
||||
sourceRoot?: string,
|
||||
sources: Array<string>,
|
||||
sourcesContent?: Array<?string>,
|
||||
version: number,
|
||||
};
|
||||
|
||||
// based on babylon v6.13.1
|
||||
type BabylonOptions = {
|
||||
allowImportExportEverywhere?: boolean,
|
||||
allowReturnOutsideFunction?: boolean,
|
||||
allowSuperOutsideMethod?: boolean,
|
||||
sourceType?: 'script' | 'module',
|
||||
sourceFilename?: 'string',
|
||||
plugins?: Array<
|
||||
'jsx' | 'flow' | 'doExpressions' | 'objectRestSpread' | 'decorators' |
|
||||
'classProperties' | 'exportExtensions' | 'asyncGenerators' |
|
||||
'functionBind' | 'functionSent' | 'dynamicImport'
|
||||
>,
|
||||
};
|
||||
|
||||
// based on babel-generator v6.18.0
|
||||
type GeneratorOptions = {
|
||||
auxiliaryCommentBefore?: string,
|
||||
auxiliaryCommentAfter?: string,
|
||||
shouldPrintComment?: (comment: string) => boolean,
|
||||
retainLines?: boolean,
|
||||
retainFunctionParens?: boolean,
|
||||
comments?: boolean,
|
||||
compact?: boolean | 'auto',
|
||||
minified?: boolean,
|
||||
concise?: boolean,
|
||||
quotes?: 'single' | 'double',
|
||||
filename?: string,
|
||||
sourceMaps?: boolean,
|
||||
sourceMapTarget?: string,
|
||||
sourceRoot?: string,
|
||||
sourceFileName?: string,
|
||||
};
|
||||
|
||||
type InlinePlugin = string | {} | () => {};
|
||||
type _Plugins = Array<string | Object | [InlinePlugin] | [InlinePlugin, mixed]>;
|
||||
|
||||
// based on https://babeljs.io/docs/usage/options/ -- 2016-11-11
|
||||
type __TransformOptions = {
|
||||
filename?: string,
|
||||
filenameRelative?: string,
|
||||
presets?: Array<string | Object>,
|
||||
plugins?: _Plugins,
|
||||
parserOpts?: BabylonOptions,
|
||||
generatorOpts?: GeneratorOptions,
|
||||
highlightCode?: boolean,
|
||||
only?: string | RegExp | Array<string | RegExp>,
|
||||
ignore?: string | RegExp | Array<string | RegExp>,
|
||||
auxiliaryCommentBefore?: boolean,
|
||||
auxiliaryCommentAfter?: boolean,
|
||||
sourceMaps?: boolean,
|
||||
inputSourceMap?: ?Object,
|
||||
sourceMapTarget?: string,
|
||||
sourceFileName?: string,
|
||||
sourceRoot?: string,
|
||||
moduleRoot?: string,
|
||||
moduleIds?: boolean,
|
||||
moduleId?: string,
|
||||
getModuleId?: (moduleName: string) => string,
|
||||
resolveModuleSource?: (source: string, filename: string) => string,
|
||||
code?: boolean,
|
||||
babelrc?: boolean,
|
||||
ast?: boolean,
|
||||
compact?: boolean | 'auto',
|
||||
minified?: boolean,
|
||||
comments?: boolean,
|
||||
shouldPrintComment?: (comment: string) => boolean,
|
||||
retainLines?: boolean,
|
||||
extends?: string,
|
||||
};
|
||||
|
||||
type _TransformOptions =
|
||||
__TransformOptions & {env?: {[key: string]: __TransformOptions}};
|
||||
declare class _Ast {}
|
||||
type TransformResult = {
|
||||
ast: _Ast,
|
||||
code: ?string,
|
||||
ignored: boolean,
|
||||
map: ?_SourceMap,
|
||||
};
|
||||
type VisitFn = <State>(path: Object, state: State) => any;
|
||||
|
||||
declare module 'babel-core' {
|
||||
declare type Plugins = _Plugins;
|
||||
declare type SourceMap = _SourceMap;
|
||||
declare type Ast = _Ast;
|
||||
declare type TransformOptions = _TransformOptions;
|
||||
declare function transform(
|
||||
code: string,
|
||||
options?: _TransformOptions,
|
||||
): TransformResult;
|
||||
declare function traverse<State>(
|
||||
ast: _Ast,
|
||||
visitor: {[key: string]: VisitFn<State> |
|
||||
{enter?: VisitFn<State>, exit?: VisitFn<State>}},
|
||||
scope?: ?Object,
|
||||
state?: State,
|
||||
parentPath?: ?Object,
|
||||
): void;
|
||||
declare var types: {[key: string]: Function};
|
||||
declare function transformFromAst(
|
||||
ast: _Ast,
|
||||
code?: ?string,
|
||||
babelOptions?: _TransformOptions,
|
||||
): TransformResult;
|
||||
}
|
||||
|
||||
type RawMapping = {
|
||||
generated: {column: number, line: number},
|
||||
name?: string,
|
||||
original?: {column: number, line: number},
|
||||
source?: string,
|
||||
};
|
||||
|
||||
declare module 'babel-generator' {
|
||||
declare type RawMapping = RawMapping;
|
||||
declare function exports(
|
||||
ast: _Ast,
|
||||
options?: GeneratorOptions,
|
||||
): TransformResult & {rawMappings: ?Array<RawMapping>};
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
type _SourceMap = {
|
||||
file?: string,
|
||||
mappings: string,
|
||||
names: Array<string>,
|
||||
sourceRoot?: string,
|
||||
sources: Array<string>,
|
||||
sourcesContent?: Array<?string>,
|
||||
version: number,
|
||||
};
|
||||
|
||||
type _Result<MapT> = {
|
||||
code: string,
|
||||
map: MapT,
|
||||
};
|
||||
|
||||
type _Options = {
|
||||
compress?: false | {||},
|
||||
fromString?: boolean,
|
||||
inSourceMap?: string | ?_SourceMap,
|
||||
mangle?: boolean | {|
|
||||
except?: Array<string>,
|
||||
toplevel?: boolean,
|
||||
eval?: boolean,
|
||||
keep_fnames?: boolean,
|
||||
|},
|
||||
mangleProperties?: boolean | {|
|
||||
regex?: RegExp,
|
||||
ignore_quoted?: boolean,
|
||||
debug?: false | string,
|
||||
|},
|
||||
outFileName?: string,
|
||||
output?: {|
|
||||
ascii_only?: boolean,
|
||||
screw_ie8?: boolean,
|
||||
|},
|
||||
parse?: {|
|
||||
strict?: boolean,
|
||||
bare_returns?: boolean,
|
||||
filename?: string,
|
||||
|},
|
||||
sourceMapUrl?: string,
|
||||
sourceRoot?: string,
|
||||
warnings?: boolean,
|
||||
};
|
||||
|
||||
type _Input =
|
||||
| string // code or file name
|
||||
| Array<string> // array of file names
|
||||
| {[filename: string]: string}; // file names and corresponding code
|
||||
|
||||
declare module 'uglify-js' {
|
||||
declare function minify(
|
||||
fileOrFilesOrCode: _Input,
|
||||
options?: _Options & {outSourceMap?: ?false | ''},
|
||||
): _Result<void>;
|
||||
declare function minify(
|
||||
fileOrFilesOrCode: _Input,
|
||||
options?: _Options & {outSourceMap: true | string},
|
||||
): _Result<string>;
|
||||
}
|
|
@ -210,7 +210,6 @@
|
|||
"stacktrace-parser": "^0.1.3",
|
||||
"temp": "0.8.3",
|
||||
"throat": "^3.0.0",
|
||||
"uglify-js": "2.7.5",
|
||||
"whatwg-fetch": "^1.0.0",
|
||||
"wordwrap": "^1.0.0",
|
||||
"write-file-atomic": "^1.2.0",
|
||||
|
|
Loading…
Reference in New Issue