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
Summary:
BREAKING CHANGE
This change upgrades the React Native build pipeline from Babel 6 to Babel 7
If you use a `.babelrc` then you'll need to update it to Babel 7 (note that some plugins are no longer relevant, some plugins are automatically upgraded, and some will need some manual love).
Note that you may also need to upgrade your dev env, tests etc, to make sure they work with Babel 7.
Reviewed By: mjesun
Differential Revision: D7591303
fbshipit-source-id: 29cef21f6466633a9c366d1f3c0d3cf874c714db
Summary:
Here, we move `index.js` files in directories one level up, and rename them to `<dirname>.js`.
This makes for a more pleasant development experience, as files are easier to identify even when only seeing the file name.
It also eliminates quite some `../` segments in imports.
Reviewed By: mjesun
Differential Revision: D7587186
fbshipit-source-id: cf7e6b417085435d731c5b6830309068035bcd19