Skip to content

Commit

Permalink
Remove unused inlineRequires params from BabelTransformer API
Browse files Browse the repository at this point in the history
Summary:
X-link: facebook/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
  • Loading branch information
motiz88 authored and facebook-github-bot committed Aug 7, 2023
1 parent 96c7f5c commit e339c8f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ it('exposes the correct absolute path to a source file to plugins', () => {
enableBabelRCLookup: false,
globalPrefix: '__metro__',
hot: false,
inlineRequires: false,
minify: false,
platform: null,
publicPath: 'test',
Expand Down
3 changes: 1 addition & 2 deletions packages/metro-babel-transformer/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ type BabelTransformerOptions = $ReadOnly<{
experimentalImportSupport?: boolean,
hermesParser?: boolean,
hot: boolean,
inlineRequires: boolean,
nonInlinedRequires?: $ReadOnlyArray<string>,
minify: boolean,
unstable_disableES6Transforms?: boolean,
platform: ?string,
projectRoot: string,
publicPath: string,
unstable_transformProfile?: TransformProfile,
globalPrefix: string,
inlineRequires?: void,
...
}>;

Expand Down
2 changes: 0 additions & 2 deletions packages/metro-babel-transformer/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export interface BabelTransformerOptions {
readonly experimentalImportSupport?: boolean;
readonly hermesParser?: boolean;
readonly hot: boolean;
readonly inlineRequires: boolean;
readonly nonInlinedRequires?: ReadonlyArray<string>;
readonly minify: boolean;
readonly unstable_disableES6Transforms?: boolean;
readonly platform: string | null;
Expand Down
8 changes: 2 additions & 6 deletions packages/metro-transform-worker/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,19 +570,15 @@ function getBabelTransformArgs(
{options, config, projectRoot}: TransformationContext,
plugins?: Plugins = [],
): BabelTransformerArgs {
const {inlineRequires: _, ...babelTransformerOptions} = options;
return {
filename: file.filename,
options: {
...options,
...babelTransformerOptions,
enableBabelRCLookup: config.enableBabelRCLookup,
enableBabelRuntime: config.enableBabelRuntime,
globalPrefix: config.globalPrefix,
hermesParser: config.hermesParser,
// Inline requires are now performed at a secondary step. We cannot
// unfortunately remove it from the internal transformer, since this one
// is used by other tooling, and this would affect it.
inlineRequires: false,
nonInlinedRequires: [],
projectRoot,
publicPath: config.publicPath,
},
Expand Down

0 comments on commit e339c8f

Please sign in to comment.