mirror of https://github.com/status-im/metro.git
metro-bundler: stricter TransformedCodeFile type and fix use sites
Summary: Here's a good example why Flow "exact types" are useful: there are a few place where we were adding unusused fields in the objects. As these fields end up in JSON files used to communicate with Buck, this can amount to a waste of resources. This changeset make the type exact and removes the unused fields. Reviewed By: mjesun Differential Revision: D6159350 fbshipit-source-id: 8cdf29d5729253f119778943ad961eacb8990c04
This commit is contained in:
parent
0e764686e1
commit
c293f4bfab
|
@ -152,13 +152,13 @@ export type TransformResults = {[string]: TransformResult};
|
|||
|
||||
export type TransformVariants = {+[name: string]: {}, +default: {}};
|
||||
|
||||
export type TransformedCodeFile = {
|
||||
export type TransformedCodeFile = {|
|
||||
+file: string,
|
||||
+hasteID: ?string,
|
||||
package?: PackageData,
|
||||
+transformed: TransformResults,
|
||||
+type: CodeFileTypes,
|
||||
};
|
||||
|};
|
||||
|
||||
export type ImageSize = {|+width: number, +height: number|};
|
||||
|
||||
|
|
|
@ -49,12 +49,11 @@ describe('transforming JS modules:', () => {
|
|||
ast: t.file(t.program(body)),
|
||||
});
|
||||
|
||||
it('passes through file name and code', () => {
|
||||
it('passes through file name', () => {
|
||||
const result = transformModule(sourceCode, options());
|
||||
expect(result.type).toBe('code');
|
||||
expect(result.details).toEqual(
|
||||
expect.objectContaining({
|
||||
code: sourceCode,
|
||||
file: filename,
|
||||
}),
|
||||
);
|
||||
|
|
|
@ -99,8 +99,6 @@ function transformModule(
|
|||
|
||||
return {
|
||||
details: {
|
||||
assetContent: null,
|
||||
code,
|
||||
file: filename,
|
||||
hasteID: hasteID || null,
|
||||
transformed,
|
||||
|
@ -129,8 +127,6 @@ function transformJSON(json, options): TransformedSourceFile {
|
|||
);
|
||||
|
||||
const result: TransformedCodeFile = {
|
||||
assetContent: null,
|
||||
code: json,
|
||||
file: filename,
|
||||
hasteID: value.name,
|
||||
transformed,
|
||||
|
|
Loading…
Reference in New Issue