Summary: Internally when adding `format` we have a lint rule that automatically reformat using `prettier` and the project rule. I'm concerned how we can ensure this stays consistent when merging PRs though. It's not a big issue because the volume of PRs is low, but we'll have to figure it out later on.
Reviewed By: davidaurelio
Differential Revision: D5035830
fbshipit-source-id: 6f2bc9eb8212938ff785a34d2684efd1a9813e1a
Summary: That module is not used anymore, remove it and its dependency `joi`.
Reviewed By: cpojer
Differential Revision: D5028909
fbshipit-source-id: 90b9b156fbfe642cce93a530faf8ce91c5b848f5
Summary: Adds flow type defs for uglify, and fixes the two issues found
Reviewed By: jeanlauliac
Differential Revision: D5029190
fbshipit-source-id: eb5947b051844938da241e002b727edc1384e3a6
Summary: This removes the single-use "garbage collection" class and make a single `TransformCache` instead. The reason for doing this is that I'd like to experiment with using a local dir based on the root path instead of the `tmpdir()` folder, because on some platform using the temp dir is subject to permissions problem, sometimes it is empty, and on all platform it is vulnerable to concurrency issues.
Reviewed By: davidaurelio
Differential Revision: D5027591
fbshipit-source-id: e1176e0e88111116256f7b2b173a0b36837a887d
Summary: I'm continuing my changes to avoid `lstat`-ing the folders when we don't really need to. That changeset in particular proposes to remove the check in `_loadAsDir`. The rationale is that right after that we try for the presence of the `package.json`. If that file exists, the folder necessarily exist so we can switch these two `if` blocks for sure without changing the logic. Finally, at the end we look for the "index" file. By removing the folder check, packager would now report "file `foo/index` does not exist" rather than "directory `foo` does not exist" if the folder does not exist. I think it's not much worse, especially as both of these are unhelpful for what I believe to be a large number of cases already anyway. Indeed, the whole algo is based on a series of try/catch, and only the very last try will see its error surfaced. But, most often, it'd be useful for earlier tries to be surfaced to the user. I do want to improve that; meanwhile, however, I sense it's not a big deal to remove that folder check for all these reasons. If you don't agree, I do have another proposition: we could catch errors generated by the last `_loadAsFile` call, and rethrow them as directory errors instead (if `dirExists` return `true`). That way, the call to `dirExists` would only happen in case of errors (but that could still happen quite a lot as a result).
Reviewed By: davidaurelio
Differential Revision: D5028341
fbshipit-source-id: 2d4c99c0f352b71599482aa529728559466b76fd
Summary: I think we don't really need to check the directory beforehand, the function to find asset will just return an empty array. As for the error message, I tried adding a require of an asset file somewhere, but due to the way the ResolutionRequest algo work, it generates a final error message that unrealted ("Directory ... does not exist", instead of the "asset does not exist"). I plan to revamp the way errors are handled such as the error message clearly identifies what file paths have been inspected.
Reviewed By: davidaurelio
Differential Revision: D5028118
fbshipit-source-id: 496472001c0a3d4192bfef4a0c8a0dc8a9a0fa82
Summary: This is not used by live code anymore.
Reviewed By: cpojer
Differential Revision: D5029114
fbshipit-source-id: 9ab9f6075407623debfe23bc121cc48ae8903917
Summary: I've been confused for a long time by this, and I think it's better late than never. I propose we rename that file to make it more explicit where that class lives, and so that it's consistent with the test file, name `DependencyGraph-test.js`
Reviewed By: davidaurelio
Differential Revision: D5020556
fbshipit-source-id: d54a501c3995f3fea16a5bfc6ca72993f73c4873
Summary: Moves custom transform options into their own property when returning custom properties. This helps both transitioning to a `select` function as well as implementing RAM bundle support for the new buck integration
Reviewed By: jeanlauliac
Differential Revision: D5028075
fbshipit-source-id: 25fe3072023cc063deef537a12012d4bb3173579
Summary: Afaik. the list of asset types is hardcoded for the Buck worker so far, and I'm not sure how that would be customizable. For now, let's include all the default asset extensions.
Reviewed By: davidaurelio
Differential Revision: D5002607
fbshipit-source-id: 41069e817d2b73156bca684bc2f73077132928a7
Summary:
There was an error with packager symbolization on Windows because it looks like `allowHalfOpen: true` doesn't work properly when using named sockets. This uses a random port on localhost for the connection instead on Windows as a workaround.
**Test plan**
Tested that symbolization works on both mac and windows by triggering a warning in UIExplorer.
Closes https://github.com/facebook/react-native/pull/13828
Differential Revision: D5019537
Pulled By: davidaurelio
fbshipit-source-id: 62c5b5f270e553a7d413bb4d1bab2406380f1d4f
Summary:
- [x] Explain the **motivation** for making this change.
- [x] Provide a **test plan** demonstrating that the code is solid.
- [x] Match the **code formatting** of the rest of the codebase.
- [x] Target the `master` branch, NOT a "stable" branch.
I have a need to bundle a pre-optimized external lib with my RN application. Until RN 0.42 I had been using a .babelignore to prevent the packager from trying to optimize this file and choke.
It seems in 0.42 and higher I'm no longer allowed to ignore the file.
This issue has also been reported as #12071
Details on the reasoning for this patch can be found in the issue I originally filed: https://github.com/facebook/react-native/issues/13168
What existing problem does the pull request solve?
This PR restores the functionality with babel ignoring files that existed in 0.41 before this patch:
0849f84df2 (diff-4676ea0b3c55c65c3929aa993144f07f)
Here's a screenshot of this patch properly ignoring the file I referenced in https://github.com/facebook/react-native/issues/13168 to be ignored.
![screen shot 2017-04-27 at 12 48 32 am](https://cloud.githubusercontent.com/assets/21967/25469653/524dbc0c-2ae3-11e7-81a6-faca2f4d21fe.png)
The patch relies on the `ignored` value of the call to `babel.transform` and if true returns the src in a object per instruction from loganfsmyth from BabelJS core team.
To test, add a file to the `ignore` array of a `.babelrc` file in a React Native project with this fork.
I was unable to locate a test file for the transformer.js
Fixes#12071, #13168
Closes https://github.com/facebook/react-native/pull/13681
Differential Revision: D5017565
Pulled By: davidaurelio
fbshipit-source-id: 421f57b5ce192eedd46fae4285d8a741cb5f8e71
Summary: Well that's silly but I noticed with faster terminal progress updates, packager *feels* a bit faster :D
Reviewed By: davidaurelio
Differential Revision: D5002528
fbshipit-source-id: 8a3d5e929dd7fb09ebafda3422886c631016a40f
Summary: Fixes building release builds with the new buck integration.
Reviewed By: jeanlauliac
Differential Revision: D5002441
fbshipit-source-id: e7716324c7c8dd0bfcaf5b39cf716ac589e948e8
Summary: Enforces a `'default'` property to be present on the transform variant mapping. This will allow us to simplify transforms of assets and json to only provide one variant for the new Buck build system.
Reviewed By: jeanlauliac
Differential Revision: D5002052
fbshipit-source-id: 2a7240c1b2450f62de686c46ab2c2e5a75dea399
Summary:
I suggest we grab our own version of worker-farm, since there are a few changes we'd like to do. There are two reasons for forking:
* the original project does not seem maintained anymore, with a PR remaining unanswered (https://github.com/rvagg/node-worker-farm/pull/42);
* we don't need to keep the level of genericity of the original project: for example, we don't need the option `maxConcurrentCallsPerWorker`, that we always keep to one.
Forking gives us opportunity to simplify the code for our use case. Later on we could reuse it for other projects such as `jest`.
A few things we'd like to do:
* remove special node options from the forks, such as `--inspect`, or even, allow adding special options (if you want to debug a worker specifically for example);
* allow us to pipe `stdout` and `stderr` instead of having transform spit stuff out to the parent process output;
* remove code managing `maxConcurrentCallsPerWorker` and clean up the code in general;
* add `flow` typing.
Reviewed By: davidaurelio
Differential Revision: D4993300
fbshipit-source-id: 10f0c2a18b010c2a8b2e2afebcb3aab3504d7923
Summary: `no-alert` doesn’t play nice with flow type spreads. We don’t need it for node, anyway.
Reviewed By: jeanlauliac
Differential Revision: D4993096
fbshipit-source-id: 95785843d3263520c063a43864c8053cbaa5083d
Summary:
`declareOpts` prevents strong Flow typing, and promotes default values, that may be different from a function to another (my goal is to remove defaults from the whole codebase except perhaps the public API). This changeset replaces it by Flow types and fixes callsites to be explicit on values.
This is the last callsite of `declareOpts` so I'll remove it, in a separate diff.
Reviewed By: cpojer
Differential Revision: D4970650
fbshipit-source-id: e5ea2e06febde892d28c9dc59dc2920d4033bb01
Summary: Separates the polyfills used for node.js from the configuration of `babel-register`, to make pretransforming packager before invoking it easier.
Reviewed By: cpojer
Differential Revision: D4978047
fbshipit-source-id: 45d3d49d0a714a8257be8d244a01e41b68bbce3d
Summary: Fixes support for haste packages in `ModuleGraph`. As `HasteMap` is no longer used for anything else, we can probably strip it down completely.
Reviewed By: cpojer
Differential Revision: D4967367
fbshipit-source-id: d40cbe46c1e8b05690c0a2c71955479c28607c01
Summary: deduplicates / unifies types for source maps across the code base
Reviewed By: jeanlauliac
Differential Revision: D4955924
fbshipit-source-id: 25cb71031dce835dd7d2bc1c27d6b20050906e81
Summary:
Two things in there:
* Using `base64` was kinda broken, as it can contain slashes, invalid in file names. It would still work however because it would just create a second level folder when doing `mkdirp`. Still I think it's better to fix that correctness.
* Include the UID in the hash, so that different users have different folders for sure, and that we reduce potiential permissions issues. `tmpdir()` already returns a folder that's user-specific on OS X, but this is not a guarantee on all platforms.
Reviewed By: cpojer
Differential Revision: D4969856
fbshipit-source-id: 4a9be35104ac9698edf2c84c58d395ee171ce2a8
Summary: Oftentimes packager stalls for several seconds after requiring a bundle, because it's busy cleaning up old cache files. We shouldn't do that when, for example, we just restarted packager. This changeset stores the micro-timestamp of the last collection so that we don't waste time next time.
Reviewed By: cpojer
Differential Revision: D4969832
fbshipit-source-id: 3aa0495b18d5a8efa1b8f87dbf7a40b0673fd9fd
Summary: Adds a stronger type for the inline plugin to help with future refactors
Reviewed By: jeanlauliac
Differential Revision: D4945842
fbshipit-source-id: f9bde75bf47271d80d2420d985a6a5609cee8952