Commit Graph

1911 Commits

Author SHA1 Message Date
Christoph Pojer 3d6b143d72 Add .npmignore
Reviewed By: davidaurelio

Differential Revision: D5190512

fbshipit-source-id: 7ab4b19f5b2c0f2ed5b1c28f3818e988313d96a4
2017-06-06 08:41:04 -07:00
Christoph Pojer 7085ed9f93 Update README
Reviewed By: jeanlauliac

Differential Revision: D5183348

fbshipit-source-id: d71bd7a6c5f20cd8954072814918adf4194abc57
2017-06-06 03:29:08 -07:00
Jean Lauliac 9dad135be1 Revert D5129231: packager: enable throwOnModuleCollision for jest-haste-map
Differential Revision: D5129231

fbshipit-source-id: 23e7f9246b55773dab98ee0cbcf38b1c8d5b4f30
2017-06-05 04:07:18 -07:00
Jean Lauliac c1ed0d872b add fake AssetRegistry module 2017-06-02 18:37:14 +01:00
Christoph Pojer 8977650ba3 New README
Summary: This is a basic README for the new repo. We'll eventually expand on this as more pieces get open sourced and we'll evolve the three identifying tags over time.

Reviewed By: jeanlauliac

Differential Revision: D5172314

fbshipit-source-id: 8e5dd8567eadbcb839ee9860a22929fd6a77ee2e
2017-06-02 09:37:05 -07:00
Jean Lauliac 3b705a1124 react-native: attachHMRServer: make it generic
Reviewed By: cpojer

Differential Revision: D5172344

fbshipit-source-id: ab8b39e1924d66d37da9734455ed9a72cf59906e
2017-06-02 09:37:05 -07:00
Kevin Gozali de70d376ca add --dev flag to the packager's dependencies command
Summary:
The packager dependencies CLI command always operates on --dev=true today. This means any tooling that needs to get the production dependencies (--dev=false) will always get the dev-mode list instead. For instance:

```
if (__DEV__) {
  require('Foobar');
}
```

Previously, `Foobar.js` will always be listed in the CLI output. With this change, setting `--dev false` option will correctly skip `Foobar.js` in the output.

Reviewed By: cpojer

Differential Revision: D5163184

fbshipit-source-id: 203221ee5d6ecb7df575442f12f6c4c489bfbd46
2017-06-01 14:06:30 -07:00
Jean Lauliac 7974a5b745 metro-bundler: AssetServer: remove fs timeouts
Reviewed By: cpojer

Differential Revision: D5164550

fbshipit-source-id: 2d294906c7deb67468dd9f85aa5ca998bdadcef3
2017-06-01 10:08:23 -07:00
Jean Lauliac 9095fd12bf metro-bundler: fix integration test for OSS
Summary: This should fix the e2e test for OSS.

Reviewed By: cpojer

Differential Revision: D5164267

fbshipit-source-id: d858b4811f0eb80ca7363177f4f384b66af13994
2017-06-01 10:08:23 -07:00
cpojer 574b427c7c Ship flow types with the bundle. 2017-06-01 18:07:31 +01:00
Christoph Pojer bbdc4b8152 Update to metro-bundler from npm
Reviewed By: kittens

Differential Revision: D5163718

fbshipit-source-id: c21d3b9b6201d1a9509686cf235b611549652975
2017-06-01 04:38:32 -07:00
cpojer a1e616d80e Repo fixes. 2017-06-01 11:48:34 +01:00
Jean Lauliac 98847474cd metro-bundler: Terminal: remove global state
Reviewed By: cpojer

Differential Revision: D5155075

fbshipit-source-id: 1d64bdd0ae13087aca620b65892832e3a1229c4a
2017-06-01 03:06:28 -07:00
Jean Lauliac 8af0267fdf make jest include polyfills so that it works on node 6 2017-06-01 10:47:51 +01:00
Christoph Pojer 921005d44d Move remaining Metro Bundler files around.
Reviewed By: jeanlauliac

Differential Revision: D5154653

fbshipit-source-id: 482bf9829263d5d8f3d0b951ee58e2020236cc2c
2017-05-31 11:08:01 -07:00
Jean Lauliac db5e2e5a8a metro-bundler: ResolutionRequest: extract FileNameResolver
Summary: I want to untangle `ResolutionRequest` once and for all, that starts by pulling stuff out :-)

Reviewed By: cpojer

Differential Revision: D5155316

fbshipit-source-id: a46ee9b40c6705edcac169adcfdffe25058ec810
2017-05-31 10:51:31 -07:00
Jean Lauliac 51da59f9e6 metro-bundler: use buildID instead of entry path for reporting
Summary: This fixes a longstanding bug that happens when 2 bundles with the same entry path but different options (dev, minify, etc.) get mixed up in the reporting. To prevent that we just use a unique build ID for each bundle that the Server handles separately.

Reviewed By: cpojer

Differential Revision: D5147049

fbshipit-source-id: da5c9cfe8c6a5d888b5be737947800d213081d86
2017-05-31 04:06:52 -07:00
cpojer 1a53b6b9a5 Remove setupBabel. 2017-05-31 11:28:05 +01:00
Jean Lauliac 90824bdd98 packager: Server: more consistent error handling
Reviewed By: cpojer

Differential Revision: D5137887

fbshipit-source-id: fe73f9a74ac7091fcad66d91859e2ff90733ce45
2017-05-30 06:23:33 -07:00
Jean Lauliac e554efaee4 packager: AsyncTaskGroup: @flow
Reviewed By: cpojer

Differential Revision: D5137195

fbshipit-source-id: 7d61d8f920ea5db7f70415e9f8fb7749a279bec8
2017-05-30 04:51:18 -07:00
Christoph Pojer 76ec909780 Stop requiring setupBabel from within packager/ folder.
Reviewed By: davidaurelio

Differential Revision: D5137246

fbshipit-source-id: 3072aaa6fd74a135980f1f0a7b078a82dd85f09d
2017-05-30 04:42:14 -07:00
Werner Roets e65e6a5da6 Fixed grammar/sentence structure
Summary:
Somebody had to fix it :)
Closes https://github.com/facebook/react-native/pull/13028

Differential Revision: D5145067

Pulled By: shergin

fbshipit-source-id: dc7a56824284c3a599b4b2a41a235e045510a013
2017-05-28 22:29:26 -07:00
Jean Lauliac 06732d9272 packager: Module: get rid of callbacks
Summary: By getting rid of callbacks, we get a code that's pretty halved in size, and much easier to read, but we also fix bugs! When some of the code of Module would throw, we wouldn't catch it, meaning that packager would crash entirely. That's the case for when we have a Haste name mistach, for example. This changeste fixes that by instead capturing exceptions through the Promise chain, that bubble up all the way to the `Server` and reasonnably handled. People can then fix the Haste nane mismatch and refresh right away, and it'll work as expected.

Reviewed By: davidaurelio

Differential Revision: D5137408

fbshipit-source-id: b9e938b93e8d23738af49106bbae1fce97d7a5db
2017-05-26 10:21:23 -07:00
Jean Lauliac 29d2aa65ac packager: add basic top-level integration test
Summary: I'd like us to start having some decent testing at the packager/bundler level to check that there are no major breakage hapenning. This changeset introduce a simple test that just test the `buildBundle` public API. On the same model, I'd like to test the server API and behavior, and things such as hot module reloading. I hope this will also highlight the gross inconsistencies of the API, for example the Bundle/BundleBase hierarchy, that we can proceed to fix later.

Reviewed By: davidaurelio, cpojer

Differential Revision: D5121817

fbshipit-source-id: e0f3758c7fbb7a85cf51fb3cbc34c12d5374b7d3
2017-05-26 03:20:57 -07:00
glevi@fb.com 5ad47b1a24 Deploy v0.47.0 to xplat/js
Reviewed By: zertosh

Differential Revision: D5135644

fbshipit-source-id: f979970f8d0c4e082ec1302084d4def6652557c8
2017-05-25 23:05:52 -07:00
David Aurelio 6ac824264d Fix code generation for indexed RAM bundles
Summary:
Code generation for indexed RAM bundles did not append module ID and dependencies. This fixes that.

Eventually, we only want to have the call to `addModuleIdsToModuleWrapper` in one place.

Reviewed By: jeanlauliac

Differential Revision: D5129255

fbshipit-source-id: 7f6148dd607bbf7c97e9df7936a07bde3f05b3aa
2017-05-25 10:21:31 -07:00
David Aurelio 683c8ddad8 Allow RAM bundle output
Summary: Hooks up indexed RAM bundle output for the build.

Reviewed By: jeanlauliac

Differential Revision: D5121515

fbshipit-source-id: 47a540d8ec016a36e21e1daa2876f582dbdb8504
2017-05-25 10:21:30 -07:00
Jean Lauliac 7f64874c7d packager: use tempdir by default
Reviewed By: davidaurelio

Differential Revision: D5129430

fbshipit-source-id: 3277341226754fd0a86d2ba3c6d64f3fa1b86e84
2017-05-25 09:05:58 -07:00
Jean Lauliac e155303543 packager: enable throwOnModuleCollision for jest-haste-map
Reviewed By: davidaurelio

Differential Revision: D5129231

fbshipit-source-id: dbb8f0096c29efaca865a788fb25c21c9cbbc5cb
2017-05-25 07:59:10 -07:00
Jean Lauliac feec96b762 packager: docBlock: @flow
Reviewed By: cpojer

Differential Revision: D5129050

fbshipit-source-id: b77d535b2f5aefef28346709bc1bb9fea5edade9
2017-05-25 06:06:35 -07:00
Jean Lauliac f0ee61c438 packager: upgrade jest-haste-map version
Summary: This allows us to get the new fix for recovery on duplicate modules.

Reviewed By: cpojer

Differential Revision: D5128975

fbshipit-source-id: 5a2b60430bbca1806a97798c482af8522366e071
2017-05-25 05:07:05 -07:00
Jean Lauliac c03a76b01a packager: TransformCaching: make choice of cache explicit in the API
Summary:
This changeset moves the creation of the transform cache at the top-level of the bundler so that:

* we can use alternative folders, such as the project path itself, that I think will be more robust especially for OSS;
* we can disable the cache completely, that is useful in some cases (for example, the script that fills the global cache).

The reasons I believe a local project path is more robust are:

* there are less likely conflicts between different users and different projects on a single machine;
* the cache is de facto cleaned up if you clone a fresh copy of a project, something I think is desirable;
* some people have been reporting that `tmpDir` just returns nothing;
* finally, it prevents another user from writing malicious transformed code in the cache into the shared temp dir—only people with write access to the project have write access to the cache, that is consistent.

Reviewed By: davidaurelio

Differential Revision: D5113121

fbshipit-source-id: 74392733a0be306a7119516d7905fc43cd8c778e
2017-05-25 04:25:35 -07:00
Christoph Pojer 5db8ac9d48 Remove setupBabel call from main entry point
Summary:
* Internally, we already set up babel before calling into metro-bundler.
* Externally, I moved the setup calls to outside the packager/ folder.

If somebody has a custom integration with RN, they would need to setup babel themselves up until we make the open source split. By the time this is released in open source, an npm version of metro-bundler will be available for use.

Next step: also do this for the worker and remove setupBabel from the metro repo.

Reviewed By: davidaurelio

Differential Revision: D5121429

fbshipit-source-id: e77c6ccc23bef1d13fd74c4727be2d7e09d2d0ca
2017-05-24 11:59:46 -07:00
David Aurelio f0e629b8bf Move packager core logic from `local-cli` to `packager`
Summary: Moves packager core logic to `packager/...` to prepare the open source split.

Reviewed By: cpojer

Differential Revision: D5116162

fbshipit-source-id: 06ee2406026686789f67acc88df41773866c3cd3
2017-05-24 08:10:56 -07:00
David Aurelio 3e8991548b Add support for RAM bundle groups
Summary: Adds support for “RAM bundle groups” (common section for module groups) to the new Buck integration

Reviewed By: jeanlauliac

Differential Revision: D5112065

fbshipit-source-id: 038c06b8f4133c7fcd39aba8bb04a5ef42594f3e
2017-05-24 08:10:56 -07:00
Jean Lauliac 502f24a266 packager: TransformCache: extract choice of root path outside of class
Summary: This is a first step towards doing an experiment I was talking about, that is, using the local directory (the directory where the config file lives) instead of the tmp dir, that is fragile.

Reviewed By: davidaurelio

Differential Revision: D5112326

fbshipit-source-id: 819636209972115e41213867f3eb78fbdf6ed9df
2017-05-24 07:52:32 -07:00
Christoph Pojer 20f7633d53 Fix DependencyGraph-test in OS.
Reviewed By: davidaurelio

Differential Revision: D5113955

fbshipit-source-id: 892331815393ca314e84112551f516a20126068f
2017-05-23 16:25:48 -07:00
David Aurelio 06bb33eba0 Move packager launcher scripts outside of `packager/`
Summary: in order to prepare open sourcing React Native Packager, we have to move scripts specific to React Native to a directory that will continue to exist.

Reviewed By: javache

Differential Revision: D5112193

fbshipit-source-id: eac77d0d981aecef7ee52365a6856340420a5638
2017-05-23 16:08:29 -07:00
Jean Lauliac 607268001a packager: ResolutionRequest: refactor _loadAsDir and dependents
Summary:
Working on refactoring error handling in `_loadAsDir` I figured out it was oftentimes problematic to pass on the candidates out of the functions as an array, as in practice there's always a single "candidates" object passed out. Also, using an array prevented nice Flow typing and forced additional invariants to be added. So I replaced that by a return value that explicitely can be either a module, or resolution candidates. That way the semantic is more clear: we don't get any candidates if we did resolve properly, and at the same time we enforce returning candidates if we could not resolve any module.

At first I wanted to just have type `{module: TModule} | {candidate: TCandidate}`, but Flow would hit edge cases, so instead I added a field `type` that make it explicit what is the result of the resolution, and allows Flow to refine the type fully after we test that field. This allows us to remove the extraneous invariants. Also, a nice thing is that at a few places, even if the type of the candididate is different, Flow allows us to return the "resolved" object just as it is, that prevents using more memory and causing more garbage collection than necessary.

Since we're creating more objects with that solution, this will be slightly less performant than returning `Module` objects directly, but I don't think it is worth micro optimizing this at that point. If really we see this to be causing trouble later, I'd try to find solutions such as reusing a pool of objects. Ex. we could pass the result `Resolution` object as argument instead of returning a fresh one, but that would make the code less legible, more complex.

Reviewed By: davidaurelio

Differential Revision: D5111501

fbshipit-source-id: f41cdab00640124081cfdf07668169bb2d5c00be
2017-05-23 12:37:24 -07:00
Jean Lauliac d012a1fc84 packager: ResolutionRequest: use _loadAsFile from _loadAsDir
Summary: We can switch that case easily since it was already discarding the error if any would happen.

Reviewed By: davidaurelio

Differential Revision: D5103851

fbshipit-source-id: a0991f626e94a45efbf666561041af258fdbef0a
2017-05-23 12:37:24 -07:00
David Aurelio 05936a53d4 Covariant properties for `ModuleTransportLike`
Summary:
Make all properties of `ModuleTraansportLike` covariant to enforce read-only behavior at all sites using it.
The type only exists for compatibility reasons between old and new output functionality, and covariant properties give us stronger guarantees.

Reviewed By: jeanlauliac

Differential Revision: D5111667

fbshipit-source-id: 674658b07eb3a229cbc4344cb636e4a9ea4126d1
2017-05-23 10:37:40 -07:00
David Aurelio 132d71f0a3 Simplify `File` type: `map` is nullable, but not optional
Summary:
Simplifies the `File` type by making `map` a non-optional, but nullable property.
Also adds helper functions for empty/virtual modules

Reviewed By: jeanlauliac

Differential Revision: D5111580

fbshipit-source-id: 9cab6634a9bdb0522dc36aec2abccaef9cf35339
2017-05-23 10:37:40 -07:00
David Aurelio 7b5d91f359 Create an `OutputFn` that can build indexed RAM bundles
Summary: Adds functionality to assemble an indexed source map to the new Buck integration. This implementation supports startup section optimisations. Hooking it up, and grouping optimisations will be in follow-ups.

Reviewed By: jeanlauliac

Differential Revision: D5106985

fbshipit-source-id: cc4c6ac8cfe4e718fc8bb2a8a93cb88914c92e0b
2017-05-23 10:37:40 -07:00
Jean Lauliac 20d7a7cdc8 packager: add missing dep
Reviewed By: davidaurelio

Differential Revision: D5111613

fbshipit-source-id: bf3b574e6166601d52127540e7970839d7019b6c
2017-05-23 09:26:05 -07:00
Jean Lauliac 3529a955d1 add custom Promise def that accepts null arg for then() 2017-05-23 15:44:17 +01:00
Christoph Pojer f2572cf7b5 Minor lint fixes
Reviewed By: jeanlauliac

Differential Revision: D5111517

fbshipit-source-id: 5cf8884334b881fb9a2b1b490972faf45c0c569b
2017-05-23 06:53:42 -07:00
Jean Lauliac 926e42c1fc ignore specific node_module flow error 2017-05-23 13:52:20 +01:00
Christoph Pojer 4ebe1e70fc Properly mock `path` in DependencyGraph-test
Reviewed By: jeanlauliac

Differential Revision: D5111337

fbshipit-source-id: ceca2ec8917eda9ca34d65324d8b8c2a468eed1c
2017-05-23 05:11:29 -07:00
Christoph Pojer f8a724121b Add @format to a few files
Reviewed By: davidaurelio

Differential Revision: D5111297

fbshipit-source-id: bde11df412dd694edca78d6a61f4c69e5abba60a
2017-05-23 05:11:29 -07:00
cpojer 0eccb5ebf4 Add more packages. 2017-05-23 11:58:55 +01:00