Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(babel): rewrite babel-preset-expo to use TypeScript #24328

Merged
merged 16 commits into from Sep 12, 2023

Conversation

EvanBacon
Copy link
Contributor

@EvanBacon EvanBacon commented Sep 7, 2023

Why

I found that if we increase the complexity and logic in our babel preset, then we can easily get to 30% faster web builds. Before doing this I'd like to ensure we have a better foundation to build against.

This PR converts babel-preset-expo to TypeScript and drops some safely unused features.

Plans

  • We'll use the caller to determine if a module should be compiled for Node.js, if so, we'll use a much cheaper babel plugin.
  • We'll add an additional caller parameter to detect if the module is inside the node_modules folder, if so, then we'll use a cheaper babel plugin. We'll also add the ability to allow certain node modules to be transpiled as application code.
    • The first version of this will be rolled out behind a flag to ensure we aren't breaking apps, since apps will more than likely break, as most React Native modules are shipped untranspiled.
    • Perhaps it makes sense to roll this out as a web-only feature.

Test Plan

Tests should keep passing.

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Sep 7, 2023
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Sep 7, 2023
@EvanBacon EvanBacon marked this pull request as ready for review September 9, 2023 03:54
packages/babel-preset-expo/.babelrc Outdated Show resolved Hide resolved
packages/babel-preset-expo/babel.config.js Outdated Show resolved Hide resolved
packages/babel-preset-expo/jest.config.js Show resolved Hide resolved
packages/babel-preset-expo/package.json Show resolved Hide resolved
packages/babel-preset-expo/src/index.ts Outdated Show resolved Hide resolved
Comment on lines +139 to 140
// TODO: Remove
[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth making a plan to remove this over time? My understanding is that because developers can specify their own Babel configuration, we don't need to implement a flag to opt back in to adding this plugin as long as we explain the migration path.

[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }],
platform === 'web' && [require.resolve('babel-plugin-react-native-web')],
isWebpack && platform !== 'web' && [require.resolve('./plugins/disable-ambiguous-requires')],
require.resolve('@babel/plugin-proposal-export-namespace-from'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope of this PR but I think Brent mentioned this plugin causes warnings on installation, and there is a new plugin. Makes me think it is worth publishing a minor version upgrade of babel-preset-expo with these fixes, but would need to separate out the breaking changes around webpack.

packages/babel-preset-expo/src/index.ts Outdated Show resolved Hide resolved
packages/babel-preset-expo/src/index.ts Outdated Show resolved Hide resolved
packages/babel-preset-expo/src/index.ts Show resolved Hide resolved
@EvanBacon EvanBacon requested a review from ide September 12, 2023 17:52
@EvanBacon EvanBacon merged commit 1e7a47e into main Sep 12, 2023
7 checks passed
@EvanBacon EvanBacon deleted the @evanbacon/babel-preset-expo/compile branch September 12, 2023 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants