-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(metro-config): fork entire transform worker (#25833)
# Why - Alternative to #25774 -- we'll fork the transform worker and serializer (already done) and implement custom asset hashing that is platform-specific and won't modify native output. - I've been meaning to do this for a while since we already moved the inline constants plugin to babel-preset-expo to fix Platform shaking. Because of this, ~~we can remove an entire babel transform pass in development when inline requires and experimental export support are disabled (default, possibly forever).~~ need to keep this enabled for some mystery reason, will re-approach in the future. - To emulate the default behavior prescribed by the upstream tests, I've added support for automatically disabling the import/export transform based on if `experimentalImportSupport` is enabled. We do this by passing the Babel-standard caller flag `supportsStaticESM` to `babel-preset-expo`, which actually makes the entire cjs conversion bundler agnostic (for bundlers that support Babel). - I've locked the `babel/generator` version as there appears to be a bug (or fix?) in the newer patch that silently makes source maps only apply to the output code and not the input, which breaks the upstream tests. This could possibly be the missing solution to my tree-shaking branch and why I couldn't get the transforms to match in the serializer. - Most of this PR is just adding types for everything and porting the tests. - This PR adds built-in centralized hashing for production export assets on web-only. We don't need to modify the output pipeline anymore since everything is handled in the transformer logic. --------- Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
- Loading branch information
Showing
51 changed files
with
2,641 additions
and
130 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
module.exports = function (api) { | ||
api.cache(true); | ||
return { | ||
presets: [['babel-preset-expo', { web: { disableImportExportTransform: false } }]], | ||
presets: [ | ||
[ | ||
// `babel-preset-expo` from the monorepo. | ||
process.env.TEST_BABEL_PRESET_EXPO_MODULE_ID, | ||
{ web: { disableImportExportTransform: false } }, | ||
], | ||
], | ||
}; | ||
}; |
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
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
3 changes: 3 additions & 0 deletions
3
packages/@expo/cli/ts-declarations/metro-cache-key/index.d.ts
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,3 @@ | ||
declare module 'metro-cache-key' { | ||
export default function getCacheKey(files: string[]): string; | ||
} |
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
Oops, something went wrong.