Skip to content

Commit e339c8f

Browse files
motiz88facebook-github-bot
authored andcommitted
Remove unused inlineRequires params from BabelTransformer API
Summary: X-link: react/react-native#38771 Changelog: [Internal] Metro has been passing `inlineRequires: false` to Babel transformers for the last 5 years (D9636747), as the inline requires transform had been hoisted into the transform worker. Here we clean up the unused code paths in React Native's implementations of the Metro Babel transformer API, and the unused properties in the API itself. Reviewed By: GijsWeterings Differential Revision: D48034441 fbshipit-source-id: d24a793962942a3c87461ffbade847ea749dac95
1 parent 96c7f5c commit e339c8f

4 files changed

Lines changed: 3 additions & 11 deletions

File tree

packages/metro-babel-transformer/src/__tests__/transform-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ it('exposes the correct absolute path to a source file to plugins', () => {
4141
enableBabelRCLookup: false,
4242
globalPrefix: '__metro__',
4343
hot: false,
44-
inlineRequires: false,
4544
minify: false,
4645
platform: null,
4746
publicPath: 'test',

packages/metro-babel-transformer/src/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ type BabelTransformerOptions = $ReadOnly<{
3333
experimentalImportSupport?: boolean,
3434
hermesParser?: boolean,
3535
hot: boolean,
36-
inlineRequires: boolean,
37-
nonInlinedRequires?: $ReadOnlyArray<string>,
3836
minify: boolean,
3937
unstable_disableES6Transforms?: boolean,
4038
platform: ?string,
4139
projectRoot: string,
4240
publicPath: string,
4341
unstable_transformProfile?: TransformProfile,
4442
globalPrefix: string,
43+
inlineRequires?: void,
4544
...
4645
}>;
4746

packages/metro-babel-transformer/types/index.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ export interface BabelTransformerOptions {
2323
readonly experimentalImportSupport?: boolean;
2424
readonly hermesParser?: boolean;
2525
readonly hot: boolean;
26-
readonly inlineRequires: boolean;
27-
readonly nonInlinedRequires?: ReadonlyArray<string>;
2826
readonly minify: boolean;
2927
readonly unstable_disableES6Transforms?: boolean;
3028
readonly platform: string | null;

packages/metro-transform-worker/src/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -570,19 +570,15 @@ function getBabelTransformArgs(
570570
{options, config, projectRoot}: TransformationContext,
571571
plugins?: Plugins = [],
572572
): BabelTransformerArgs {
573+
const {inlineRequires: _, ...babelTransformerOptions} = options;
573574
return {
574575
filename: file.filename,
575576
options: {
576-
...options,
577+
...babelTransformerOptions,
577578
enableBabelRCLookup: config.enableBabelRCLookup,
578579
enableBabelRuntime: config.enableBabelRuntime,
579580
globalPrefix: config.globalPrefix,
580581
hermesParser: config.hermesParser,
581-
// Inline requires are now performed at a secondary step. We cannot
582-
// unfortunately remove it from the internal transformer, since this one
583-
// is used by other tooling, and this would affect it.
584-
inlineRequires: false,
585-
nonInlinedRequires: [],
586582
projectRoot,
587583
publicPath: config.publicPath,
588584
},

0 commit comments

Comments
 (0)