Summary:
The traverse dependencies logic was using the absolute path of the resolved dependency to group the module dependencies, so for example if there's a module like:
```
const a = require('./a');
const a1 = require('./a.js');
```
The traversal dependencies logic was just outputting a single dependency for that module.
Since we're transforming each `require()` call to replace the relative path by a dependencyMap, the code from above was transformed to:
```
const a = require(_dependencyMap[0]);
const a1 = require(_dependencyMap[1]);
```
But since the traverse dependencies logic could only find a single dependency, `_dependencyMap[1]` was undefined, causing a runtime error.
This fixes https://github.com/facebook/metro/issues/152 (more info in the task)
Reviewed By: jeanlauliac
Differential Revision: D7258093
fbshipit-source-id: 65c42b87e589430ecc96b906230dd7c4c55c2146
Summary:
<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->
**Summary**
Remove `request` from `metro`. It doesn't seem to be used.
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
**Test plan**
Everything works as it did before.
<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->
Closes https://github.com/facebook/metro/pull/151
Differential Revision: D7226502
Pulled By: rafeca
fbshipit-source-id: fc353292ba55ea9f98eba67f05f8f8f82794dd82
Summary:
In Node v6 there is no `final` function: https://nodejs.org/docs/v6.13.1/api/stream.html#stream_simplified_construction.
It's not a problem however because we can preferentially use the `finish` event, that makes it more consistent with how `createReadStream` is implemented. I also added closing the fs on `error` events, as specified in the docs.
**Test plan**
yarn jest
Closes https://github.com/facebook/metro/pull/150
Reviewed By: rafeca
Differential Revision: D7215708
Pulled By: jeanlauliac
fbshipit-source-id: 80921a245c8c87085a2ba83b84b1156a60aa1fb3
Summary:
This adds the babel register package for babel 7 to Metro
All changes are caused by yarn
Reviewed By: davidaurelio
Differential Revision: D7102279
fbshipit-source-id: a8a6db5600207b868bb10217884eb659de9778f4
Summary: Turns out we need an updated version of the babel 7 stack because the runtime depends on something in the newest version. This commit bumps various main package versions to beta.40
Reviewed By: davidaurelio
Differential Revision: D7104132
fbshipit-source-id: ff7db16f6ad82ea2a728ead63fe19b1c9dbd708c
Summary: More cleanup of `DeltaBundler` in order to move from `Bundler` to `ModuleGraph`. I am trying to remove all unrelated functionality to make the transition easier.
Reviewed By: rafeca
Differential Revision: D7100153
fbshipit-source-id: 2e0c2d4957dece27bd28d3cf7e4ff2e178c60fb2
Summary: Removes an unused type from `Bundler`
Reviewed By: jeanlauliac
Differential Revision: D7084608
fbshipit-source-id: 213a49466c9745c4bb85b8b16a8b2e4309b5a524
Summary: now that RAM bundle info building is an implementation detail, we make it part of the test rather than mocking it out.
Reviewed By: rafeca
Differential Revision: D7084580
fbshipit-source-id: edbb7b3d1aaca5513ea81d8d2c62b4b5c8e97756
Summary: Removes `getRamOptions` from `DeltaTransformer` and `Bundler` for better separation of concerns, and ultimately, porting delta functionality to `ModuleGraph`
Reviewed By: rafeca
Differential Revision: D7084487
fbshipit-source-id: e8a7ea4addbad9057e7d55627f77ebd01e64786b
Summary: This makes the plugin use the passed on babel api rather than hardcoded pulling in babel 6 or 7. This is important since they are different packages now and we need to work with them side-by-side.
Reviewed By: mjesun
Differential Revision: D7083873
fbshipit-source-id: 2ce89e0627005bb29ff8d3e0e1ac51fe8ee4eabd
Summary: Enable the flow directive for the inline tests. Changes are related to getting Flow to green.
Reviewed By: jeanlauliac
Differential Revision: D7083814
fbshipit-source-id: f5efa35181663b30d9da437ffa727b3fa8f99b5a
Summary:
Before the inline plugin was explicitly requiring babel itself. With the babel upgrade path that's a problem since it will try to pull in babel 6 even when we want babel 7 (because it's a different package name). To remedy this the plugin is now a function which will use the `types` api from the given context rather than the required global.
I also moved out the `inline` function that only seems to be used in tests. They're now just living in the tests.
Had to add some flow annotations to generic objects since Flow was complaining about missing types and that would require adding the full babel api which is outside of the scope of this task.
Reviewed By: jeanlauliac
Differential Revision: D7083815
fbshipit-source-id: 59b8365d8c3c3dc00b23a3735037dcc9483c0b2c
Summary:
**Summary**
This should fix install of the metro with npm (issue #142).
We can't have both babylon@6 and babylon@7 as deps for metro package, so as jeanlauliac suggested in https://github.com/facebook/metro/issues/142#issuecomment-368217279 lets create wrapper-package `metro-babylon7` and reexport babylon@7 from it.
**Test plan**
I do manually `yarn && yarn test` - all checks passed.
Closes https://github.com/facebook/metro/pull/143
Differential Revision: D7079144
Pulled By: rafeca
fbshipit-source-id: eeb4f6a01ad92d84dc14702dee07975e253bcf88
Summary:
<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->
**Summary**
Jest Worker accepts parameter `numWorkers`, not `maxWorkers`, see:
https://github.com/facebook/jest/tree/master/packages/jest-worker#numworkers-number-optional
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
**Test plan**
<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->
Closes https://github.com/facebook/metro/pull/136
Reviewed By: mjesun
Differential Revision: D7036411
Pulled By: rafeca
fbshipit-source-id: 5528ca4a9abe5a8e3668e83b214e10d97ba7a827
Summary: This diff allows Metro to throw an error when a configuration file cannot be found, by using a new strict: true option.
Reviewed By: rafeca
Differential Revision: D6998613
fbshipit-source-id: b704633be18d5c007f1a022fa811d0a74c636fc9
Summary: This diff makes the Metro CLI commands injectable into any Yargs object, so that we can override various aspects of it, add extra commands, etc.
Reviewed By: davidaurelio
Differential Revision: D6988250
fbshipit-source-id: 217c661e4c1b05282b6cdbf4d745d1b29f5cbbe0
Summary:
This exposes the `minifierPath` externally and allows it to be adjusted through the `--minifier-path` argument.
This works for both the server (when starting the server) and running a single build through the CLI.
In server mode, this can not be used per file request yet, though that should also be doable if need be.
Reviewed By: rafeca
Differential Revision: D6998562
fbshipit-source-id: 669b876c24fe117ec88b2200d48aa82658f568b4
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.
find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.
Reviewed By: TheSavior, yungsters
Differential Revision: D7007050
fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
Summary:
Argument was no longer used and is causing lint errors.
Dropping it simplifies the debounce function as well.
Reviewed By: davidaurelio
Differential Revision: D6999567
fbshipit-source-id: 8856ed40feb0fa23155c9d18e20c43550aac876b