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 TransformVariants = {+[name: string]: {}, +default: {}};
|
||||||
|
|
||||||
export type TransformedCodeFile = {
|
export type TransformedCodeFile = {|
|
||||||
+file: string,
|
+file: string,
|
||||||
+hasteID: ?string,
|
+hasteID: ?string,
|
||||||
package?: PackageData,
|
package?: PackageData,
|
||||||
+transformed: TransformResults,
|
+transformed: TransformResults,
|
||||||
+type: CodeFileTypes,
|
+type: CodeFileTypes,
|
||||||
};
|
|};
|
||||||
|
|
||||||
export type ImageSize = {|+width: number, +height: number|};
|
export type ImageSize = {|+width: number, +height: number|};
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,11 @@ describe('transforming JS modules:', () => {
|
||||||
ast: t.file(t.program(body)),
|
ast: t.file(t.program(body)),
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes through file name and code', () => {
|
it('passes through file name', () => {
|
||||||
const result = transformModule(sourceCode, options());
|
const result = transformModule(sourceCode, options());
|
||||||
expect(result.type).toBe('code');
|
expect(result.type).toBe('code');
|
||||||
expect(result.details).toEqual(
|
expect(result.details).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
code: sourceCode,
|
|
||||||
file: filename,
|
file: filename,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
@ -99,8 +99,6 @@ function transformModule(
|
||||||
|
|
||||||
return {
|
return {
|
||||||
details: {
|
details: {
|
||||||
assetContent: null,
|
|
||||||
code,
|
|
||||||
file: filename,
|
file: filename,
|
||||||
hasteID: hasteID || null,
|
hasteID: hasteID || null,
|
||||||
transformed,
|
transformed,
|
||||||
|
@ -129,8 +127,6 @@ function transformJSON(json, options): TransformedSourceFile {
|
||||||
);
|
);
|
||||||
|
|
||||||
const result: TransformedCodeFile = {
|
const result: TransformedCodeFile = {
|
||||||
assetContent: null,
|
|
||||||
code: json,
|
|
||||||
file: filename,
|
file: filename,
|
||||||
hasteID: value.name,
|
hasteID: value.name,
|
||||||
transformed,
|
transformed,
|
||||||
|
|
Loading…
Reference in New Issue