Skip to content

Commit a07c823

Browse files
motiz88facebook-github-bot
authored andcommitted
Make all getTransformOptions result properties optional
Summary: Types `getTransformOptions` as returning an object with all-optional properties. There's no need to force Metro config authors to return a bunch of empty properties when they just want to set `transform.inlineRequires` to `true`. (Also, as a practical matter, these are already treated as optional almost everywhere, including in the React Native template.) In an upcoming diff I will document `getTransformOptions` on the Metro website and explain what all these options are for. Changelog: * **[Fix]:** Make all `getTransformOptions` result properties optional Reviewed By: huntie Differential Revision: D41400791 fbshipit-source-id: c30dfa57ec257f079fdb4e78863fdf0dc8f968d4
1 parent a6b8620 commit a07c823

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/metro-config/src/configTypes.flow.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ export type PostProcessBundleSourcemap = ({
4040
};
4141

4242
export type ExtraTransformOptions = {
43-
+preloadedModules: {[path: string]: true, ...} | false,
44-
+ramGroups: Array<string>,
45-
+transform: {
46-
+experimentalImportSupport: boolean,
47-
+inlineRequires: {+blockList: {[string]: true, ...}, ...} | boolean,
43+
+preloadedModules?: {[path: string]: true, ...} | false,
44+
+ramGroups?: Array<string>,
45+
+transform?: {
46+
+experimentalImportSupport?: boolean,
47+
+inlineRequires?: {+blockList: {[string]: true, ...}, ...} | boolean,
4848
+nonInlinedRequires?: $ReadOnlyArray<string>,
4949
+unstable_disableES6Transforms?: boolean,
5050
},

packages/metro/src/lib/transformHelpers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ async function calcTransformerOptions(
101101

102102
return {
103103
...baseOptions,
104-
inlineRequires: transform.inlineRequires || false,
105-
experimentalImportSupport: transform.experimentalImportSupport || false,
104+
inlineRequires: transform?.inlineRequires || false,
105+
experimentalImportSupport: transform?.experimentalImportSupport || false,
106106
unstable_disableES6Transforms:
107-
transform.unstable_disableES6Transforms || false,
107+
transform?.unstable_disableES6Transforms || false,
108108
nonInlinedRequires:
109-
transform.nonInlinedRequires || baseIgnoredInlineRequires,
109+
transform?.nonInlinedRequires || baseIgnoredInlineRequires,
110110
type: 'module',
111111
};
112112
}

0 commit comments

Comments
 (0)