Skip to content

Commit

Permalink
Make all getTransformOptions result properties optional
Browse files Browse the repository at this point in the history
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
  • Loading branch information
motiz88 authored and facebook-github-bot committed Nov 18, 2022
1 parent a6b8620 commit a07c823
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions packages/metro-config/src/configTypes.flow.js
Expand Up @@ -40,11 +40,11 @@ export type PostProcessBundleSourcemap = ({
};

export type ExtraTransformOptions = {
+preloadedModules: {[path: string]: true, ...} | false,
+ramGroups: Array<string>,
+transform: {
+experimentalImportSupport: boolean,
+inlineRequires: {+blockList: {[string]: true, ...}, ...} | boolean,
+preloadedModules?: {[path: string]: true, ...} | false,
+ramGroups?: Array<string>,
+transform?: {
+experimentalImportSupport?: boolean,
+inlineRequires?: {+blockList: {[string]: true, ...}, ...} | boolean,
+nonInlinedRequires?: $ReadOnlyArray<string>,
+unstable_disableES6Transforms?: boolean,
},
Expand Down
8 changes: 4 additions & 4 deletions packages/metro/src/lib/transformHelpers.js
Expand Up @@ -101,12 +101,12 @@ async function calcTransformerOptions(

return {
...baseOptions,
inlineRequires: transform.inlineRequires || false,
experimentalImportSupport: transform.experimentalImportSupport || false,
inlineRequires: transform?.inlineRequires || false,
experimentalImportSupport: transform?.experimentalImportSupport || false,
unstable_disableES6Transforms:
transform.unstable_disableES6Transforms || false,
transform?.unstable_disableES6Transforms || false,
nonInlinedRequires:
transform.nonInlinedRequires || baseIgnoredInlineRequires,
transform?.nonInlinedRequires || baseIgnoredInlineRequires,
type: 'module',
};
}
Expand Down

0 comments on commit a07c823

Please sign in to comment.