-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(babel): rewrite babel-preset-expo to use TypeScript (#24328)
# 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. --------- Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
- Loading branch information
Showing
23 changed files
with
334 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @generated by expo-module-scripts | ||
module.exports = require('expo-module-scripts/eslintrc.base.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
__tests__/ | ||
# @generated by expo-module-scripts | ||
|
||
# Exclude all top-level hidden directories by convention | ||
/.*/ | ||
|
||
__mocks__ | ||
__tests__ | ||
|
||
/babel.config.js | ||
/android/src/androidTest/ | ||
/android/src/test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
packages/babel-preset-expo/__tests__/__snapshots__/disable-ambiguous-requires-test.js.snap
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
packages/babel-preset-expo/__tests__/disable-ambiguous-requires-test.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = function (api) { | ||
api.cache(true); | ||
return { | ||
// Only transpile our source code | ||
include(filename) { | ||
// Ignore tests and the `unknown` name used in tests | ||
return !filename.match(/samples/) && filename.match(/src\/(.*)\.tsx?/); | ||
}, | ||
presets: ['@expo/babel-preset-cli'], | ||
}; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
testEnvironment: 'node', | ||
testRegex: '/__tests__/.*(test|spec)\\.[jt]sx?$', | ||
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'], | ||
clearMocks: true, | ||
rootDir: path.resolve(__dirname), | ||
displayName: require('./package').name, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
packages/babel-preset-expo/plugins/disable-ambiguous-requires.js
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.