Skip to content

Commit 14c4d43

Browse files
rozelefacebook-github-bot
authored andcommitted
Add unstable_inlinePlatform option to transform config
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
1 parent ab33059 commit 14c4d43

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type ExtraTransformOptions = $ReadOnly<{
3737
| boolean,
3838
nonInlinedRequires?: $ReadOnlyArray<string>,
3939
unstable_disableES6Transforms?: boolean,
40+
unstable_inlinePlatform?: boolean,
4041
unstable_memoizeInlineRequires?: boolean,
4142
unstable_nonMemoizedInlineRequires?: $ReadOnlyArray<string>,
4243
}>,

packages/metro-config/types/configTypes.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface ExtraTransformOptions {
3232
| boolean;
3333
nonInlinedRequires?: ReadonlyArray<string>;
3434
unstable_disableES6Transforms?: boolean;
35+
unstable_inlinePlatform?: boolean;
3536
unstable_memoizeInlineRequires?: boolean;
3637
}>;
3738
}

packages/metro/src/lib/transformHelpers.js

+4
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ async function calcTransformerOptions(
113113

114114
return {
115115
...baseOptions,
116+
inlinePlatform:
117+
transform?.unstable_inlinePlatform != null
118+
? transform.unstable_inlinePlatform
119+
: true,
116120
inlineRequires: transform?.inlineRequires || false,
117121
experimentalImportSupport: transform?.experimentalImportSupport || false,
118122
unstable_disableES6Transforms:

0 commit comments

Comments
 (0)