Summary: Makes it so that the default transformer loads babel-preset-react-native again if no project `.babelrc` is defined. This makes tests like `react-native/scripts/run-android-local-integration-tests.sh` work again.
Reviewed By: mjesun
Differential Revision: D7766134
fbshipit-source-id: fa12a6e2a535c9f4b35e4b2b954b5be9d455a9cb
Summary: Moves the `buildRegExps` function from `react-native` to `metro-babel-register`. This way, it is easier to reuse, and we can remove FB-specific logic from React Native.
Reviewed By: jeanlauliac, mjesun
Differential Revision: D7727483
fbshipit-source-id: 0f7773ff044033c465f0712c523a0aef61bf8444
Summary: Moves the implementation of Buck’s worker protocol into its own package and babelRegisterOnly for better reusability.
Reviewed By: rafeca
Differential Revision: D7666896
fbshipit-source-id: ae297494ced3b8dd1f9d90983a640643d6ce7896
Summary: For specific cases, Metro will write the number of modules to the bundle. The require implementation can take advantage of that, and construct an array with the target size.
Reviewed By: mjesun
Differential Revision: D7696290
fbshipit-source-id: a7be74c02960dc089e4d3c1accd7c732b762c8b5
Summary: Now that the minifier is integrated inside the transformer, we can expose the param in the `buildGraph` method
Reviewed By: davidaurelio
Differential Revision: D7707542
fbshipit-source-id: 0125172b2ac90c7ceb477d5c55e9aea3c3867e02
Summary:
When moving the minification to the worker, I forgot to also minify JSON files (they have an early return).
This diff fixes this :)
Reviewed By: davidaurelio
Differential Revision: D7707317
fbshipit-source-id: 1114017b811861a6f2caebe79e1d79e6ad9a7b1e
Summary:
Since Babel is still in beta and breaking changes may happen between beta versions we need to lock this down and carefully consider upgrades.
For example, between .40 and .44 there seem to be at least two new mandatory options and who knows what else.
Once Babel 7 leaves beta we can go back to the caret (^).
Reviewed By: rafeca
Differential Revision: D7685783
fbshipit-source-id: ff6e19f5716b4c7fdfb8778c650309bb92966ff7
Summary:
This commit refactors the metro bundling logic to make the traversal of dependencies much more generic, to not depend on any assumption regarding dependency resolution, haste, or even about the transformer/caching system.
So, the actual API of the `DeltaBundler` module (which will be extracted as a separate package in the near future) ends up being like this:
```
const graph = await deltaBundler.buildGraph(
['/root/entryPoint1.js', '/root/entryPoint2.js', /* ... */],
{
dependencyResolver: (from, to) => require('resolve').sync(to, {from}), // Use the standard nodejs resolver
transformFn: filePath => await transformFileUsingWhateverIPrefer(filePath),
},
);
```
The only part that is still coupled with the `DependencyGraph` is the file listener (which is tied to JestHasteMap via `DependencyGraph`), which is going to be decoupled soon.
From here, and once we have the new caching system fully rolled out and the old cache logic removed, we'll incorporate `jest-worker` and the caching system directly into the build graph logic, to end up extracting the whole `DeltaBundler` logic into its own package.
From there we can potentially reuse it to create simpler/more focused bundlers for web/etc.
Reviewed By: davidaurelio
Differential Revision: D7617143
fbshipit-source-id: b7e1a71cd95043f6232b07f2e8c45dcd49f089f2