mirror of
https://github.com/status-im/metro.git
synced 2025-02-05 07:43:49 +00:00
Fix Flow type for babel-generator
Reviewed By: rafeca Differential Revision: D6682632 fbshipit-source-id: befc2fe51c8e3b542b0f2b8b595ed78b39bd1801
This commit is contained in:
parent
1b37017eb1
commit
8815c8329d
@ -98,6 +98,12 @@ type TransformResult = {
|
|||||||
ignored: boolean,
|
ignored: boolean,
|
||||||
map: ?_SourceMap,
|
map: ?_SourceMap,
|
||||||
};
|
};
|
||||||
|
// https://github.com/babel/babel/blob/master/packages/babel-generator/src/buffer.js#L42
|
||||||
|
type GeneratorResult = {
|
||||||
|
code: string,
|
||||||
|
map: ?_SourceMap,
|
||||||
|
rawMappings: ?Array<RawMapping>,
|
||||||
|
};
|
||||||
type VisitFn = <State>(path: Object, state: State) => any;
|
type VisitFn = <State>(path: Object, state: State) => any;
|
||||||
|
|
||||||
declare module 'babel-core' {
|
declare module 'babel-core' {
|
||||||
@ -132,10 +138,12 @@ type RawMapping = {
|
|||||||
source?: string,
|
source?: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// https://github.com/babel/babel/tree/master/packages/babel-generator
|
||||||
declare module 'babel-generator' {
|
declare module 'babel-generator' {
|
||||||
declare type RawMapping = RawMapping;
|
declare type RawMapping = RawMapping;
|
||||||
declare module.exports: (
|
declare module.exports: {default: (
|
||||||
ast: Ast,
|
ast: Ast,
|
||||||
options?: GeneratorOptions,
|
options?: GeneratorOptions,
|
||||||
) => TransformResult & {rawMappings: ?Array<RawMapping>};
|
code?: string | {[string]: string},
|
||||||
|
) => GeneratorResult};
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,9 @@ function generate(
|
|||||||
sourceCode,
|
sourceCode,
|
||||||
);
|
);
|
||||||
|
|
||||||
delete generated.map.sourcesContent;
|
if (generated.map) {
|
||||||
|
delete generated.map.sourcesContent;
|
||||||
|
}
|
||||||
return generated;
|
return generated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ function optimize(transformed: TransformResult, file, options) {
|
|||||||
|
|
||||||
const min = minify.withSourceMap(
|
const min = minify.withSourceMap(
|
||||||
gen.code,
|
gen.code,
|
||||||
inputMap && mergeSourceMaps(file, inputMap, gen.map),
|
inputMap && gen.map && mergeSourceMaps(file, inputMap, gen.map),
|
||||||
file,
|
file,
|
||||||
);
|
);
|
||||||
return {code: min.code, map: min.map, dependencies};
|
return {code: min.code, map: min.map, dependencies};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user