-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate function map via Babel plugin, remove transformer->source ma…
…p dependency Summary: ## Motivation As part of work to decouple `metro-react-native-babel-transformer` from Metro, and allow more integration with React Native (in particular, for Static ViewConfigs), we'd like to obviate the current dependency of the transformer on `metro-source-map`. This will isolate the transformer and `metro-react-native-babel-preset` so that they're only loosely coupled to Metro via stable interfaces, and frees them up to be moved together into RN. ## Function maps Metro uses "function maps" to augment source maps and provide richer symbolication. They are derived from the source AST (ideally before any mutation) - consequently, they're currently generated between parsing and transformation by *each* transformer via an imperative API, and returned explicitly alongside the transform result. ## This change Invert the dependency on `metro-source-map` by extracting function map metadata in a plugin pass, with a new Babel plugin, rather than with a call to `generateFunctionMap`. We take advantage of the existing API to pass a `plugins` array to the transformer implementation. ### Changes to contracts - Transformer implementations (`transformer.babelTransformerPath`) *may* return a `metadata` object from Babel's transform result metadata. (As an implementation detail, this may contain a `functionMap` property added by the plugin, but the transformer doesn't need to know about this or handle it explicitly.) - Returning a top-level `functionMap` from `transform()`, which was always optional, is now deprecated. It will be temporarily used as a fallback so that this change is non-breaking. ``` * **[Feature]** `metro-babel-transformer` and `metro-react-native-babel-transformer` will return `metadata` from Babel transform results. ``` Reviewed By: motiz88 Differential Revision: D46149279 fbshipit-source-id: e8629be9a90d6b1bec6c2d60d97859d3febaa897
- Loading branch information
1 parent
a064fbf
commit 42fdbc2
Showing
10 changed files
with
212 additions
and
86 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
Oops, something went wrong.