Skip to content

Commit

Permalink
Add unstable_inlinePlatform option to transform config
Browse files Browse the repository at this point in the history
Summary:
Metro resolver logic can be customized in various ways to support bespoke platform-style extensions in modules. In certain cases, these kinds of bespoke platform overrides can switch Platform.select behaviors. However, when used in conjunction with the default inlinePlatform transform for Metro, this kind of override may not be possible.

This change introduces an unstable API that can be used to disable inlinePlatform transforms.

Reviewed By: robhogan

Differential Revision: D68346407

fbshipit-source-id: d3042554b21b437e85ced7adf5156ecad81263d5
  • Loading branch information
rozele authored and facebook-github-bot committed Jan 21, 2025
1 parent ab33059 commit 14c4d43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/metro-config/src/configTypes.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type ExtraTransformOptions = $ReadOnly<{
| boolean,
nonInlinedRequires?: $ReadOnlyArray<string>,
unstable_disableES6Transforms?: boolean,
unstable_inlinePlatform?: boolean,
unstable_memoizeInlineRequires?: boolean,
unstable_nonMemoizedInlineRequires?: $ReadOnlyArray<string>,
}>,
Expand Down
1 change: 1 addition & 0 deletions packages/metro-config/types/configTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface ExtraTransformOptions {
| boolean;
nonInlinedRequires?: ReadonlyArray<string>;
unstable_disableES6Transforms?: boolean;
unstable_inlinePlatform?: boolean;
unstable_memoizeInlineRequires?: boolean;
}>;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/metro/src/lib/transformHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ async function calcTransformerOptions(

return {
...baseOptions,
inlinePlatform:
transform?.unstable_inlinePlatform != null
? transform.unstable_inlinePlatform
: true,
inlineRequires: transform?.inlineRequires || false,
experimentalImportSupport: transform?.experimentalImportSupport || false,
unstable_disableES6Transforms:
Expand Down

0 comments on commit 14c4d43

Please sign in to comment.