Summary:
Adding a Babel plugin that will analyze the file looking for any potential candidate to use `regenerator-runtime`, and if so, will inject dynamically the module. The module is injected per file, so we avoid polluting the global environment. The plugin is also able to inject the `require` call beforehand, so that the inliner can pick them and inline them.
The Babel plugin is part of `react-native-babel-preset`, so as long as you are using this preset you are safe. If not, you should include the specific transformer into your list of plugins, as `react-native-babel-preset/transforms/transform-regenerator-runtime-insertion.js`.
Reviewed By: davidaurelio
Differential Revision: D5388655
fbshipit-source-id: dc403f3d5e2d807529eb8569a85c45fec36a6a3e
Summary:
I corrupted the yarn.lock when trying to downgrade that module. This change brings the correct resolution in the `yarn.lock`.
Closes https://github.com/facebook/metro-bundler/pull/29
Differential Revision: D5452305
Pulled By: jeanlauliac
fbshipit-source-id: 54026cfd9cf269e2b432dd92f16bd6db9fa4603c
Summary: Downgrade the locked version of Babel block scoping, kinda temporarily until we upgrade internally. This makes in on par with the version we use internally, so that the `basic_bundle` test had the same results on both infrastructures. This doesn't change a single thing for `metro-bundler` consumers, because this `yarn.lock` file is only used for testing/CI, not when the library is installed as part of a project.
Reviewed By: cpojer
Differential Revision: D5442368
fbshipit-source-id: f3033e450855f7d61ac775a46719d7b1743960c5
Summary: Now we have a nice specific error type for duplicates errors. This changeset have been commited before but was reverted as part of a stack, so here we go again.
Reviewed By: cpojer
Differential Revision: D5442363
fbshipit-source-id: 068c8decaf20cd4f9a73d9d54984030c79cff606
Summary: I appears `Object.assign` is not properly typed-checked by Flow, and silently so, so I propose we switch to an explicit list until we find an alternative solution. I prefer to have strong typing especially for options, and as the lack of typing has caused breakage before.
Reviewed By: cpojer
Differential Revision: D5442319
fbshipit-source-id: 82b0ec760c7dea6da6f7932896243147ce12ebf9
Summary: I'd like to get rid of the function as blacklist, because it's impossible to process properly at the `jest-haste-map` level (https://github.com/facebook/jest/pull/4047). The reason we use a function in Metro bundler is because we excludes all the `__tests__` modules. However, I removed this exclusion completely, and I could build our package without any problem and with no difference in the final bundle. I can only assume, then, that this line is only here for slightly increasing performance. Therefore, I think it's reasonnable to move it as part of the default blacklist shipped with Metro bundler instead.
Reviewed By: cpojer
Differential Revision: D5434351
fbshipit-source-id: dea39f6299985143d25fcb3b7b365d793acd64a9
Summary: Now we have a nice specific error type for duplicates errors.
Reviewed By: cpojer
Differential Revision: D5433438
fbshipit-source-id: 47cad9ca6bf0bdec91a158ccb2807b6c5571966a
Summary: This put it on par with the version we use on other projects. This new version breaks assumptions about the way Promise/ticks/timers use to work, and I was not able to make it work properly synchronously. Since it's fragile anyway (because rely on Promise and feature internals), I propose the switch to async as done in this changeset. If `res.end` is not called, tests will just timeout instead.
Reviewed By: cpojer
Differential Revision: D5423823
fbshipit-source-id: 015e808a2cf2b8297a36b16feeb811a6e745a835
Summary: Going one step further, we can start working around the throwing version. To simply some code, I also piggybacked the addition of helper functions `resolvedAs` and `failedFor` in this changeset, hope it's okay. I can split if necessary.
Reviewed By: davidaurelio
Differential Revision: D5415196
fbshipit-source-id: 1bd5955b5733866af52fa873bcd1d9e4ce8215cf
Summary:
Adding a Babel plugin that will analyze the file looking for any potential candidate to use `regenerator-runtime`, and if so, will inject dynamically the module. The module is injected per file, so we avoid polluting the global environment. The plugin is also able to inject the `require` call beforehand, so that the inliner can pick them and inline them.
The Babel plugin is part of `react-native-babel-preset`, so as long as you are using this preset you are safe. If not, you should include the specific transformer into your list of plugins, as `react-native-babel-preset/transforms/transform-regenerator-runtime-insertion.js`.
Reviewed By: davidaurelio
Differential Revision: D5321193
fbshipit-source-id: fd4805b28c8a2b986842e23570a64003370d2067
Summary:
This fixes https://github.com/facebook/react-native/issues/14530 on my local repro. The reason the original problem appears is because when requiring the preset itself, what I think is a bug in babel-register kicks in and it starts transforming the presets themselves. That fails because these preset don't actually have the correct transforms plugins installed/specified in their `package.json` (they do it at prepublish time).
Closes https://github.com/facebook/metro-bundler/pull/21
Reviewed By: cpojer
Differential Revision: D5380795
Pulled By: jeanlauliac
fbshipit-source-id: 023fd6b36dc7ebd26961878edd71d423ea9856b5
Summary: Bump dependencies to the same version that react native uses
Reviewed By: jeanlauliac
Differential Revision: D5364009
fbshipit-source-id: 302db951a5509584da13a18a7fab6965e0b1e394
Summary: Restores the ability to write the expected header for indexed RAM bundles by avoiding to stringify buffers as utf8. Some minor cleanups included
Reviewed By: javache
Differential Revision: D5351839
fbshipit-source-id: 056661b064336ff74571b9f44c16d709fc59145b
Summary:
Remove our internal docbloc module and use `jest-docblock` instead.
The development server is using `jest-haste-map` exclusively, which in turn relies on `jest-docblock`, which differs slightly from our own docblock module.
Depending on only one version greatly reduces the number of edge cases
Reviewed By: cpojer
Differential Revision: D5328472
fbshipit-source-id: 4a31d8159519e01a83fda04b76e8f14f0beb16af
Summary:
Trims doc block annotations. This mitigates problems with leading and trailing spaces in `providesModule` annotations.
This module doesn’t have tests, but it is exclusively used for `providesModule` annotations right now.
Reviewed By: mjesun
Differential Revision: D5319814
fbshipit-source-id: de55df5b4b199738f9b01151eb86f3c863485b15
Summary: Given a file `test.android.png`, this allows it to be found as `test.android` for arbitrary platforms.
Reviewed By: bestander
Differential Revision: D5305807
fbshipit-source-id: d869a1da0cc502f853314790385734897f269d6a
Summary:
We use custom npm scripts (`prepare-release`, `cleanup-release`) to
- move `src` to `src.orig`, and `build` to `src` before creating the tarball
- move everything back afterwards
We run these scripts with lerna before and after publishing. Custom hooks avoid problems with `prepublishOnly` and `postpublish` not being run at opportune times, `prepack` and `postpack` not being supported by npm v4 and yarn, and using `lerna run prepublishOnly` resulting in duplicated execution of the command.
This ensures that development is closer to what is pulled in from npm.
Reviewed By: jeanlauliac
Differential Revision: D5310133
fbshipit-source-id: 6b9885c88b936ef3fe5f1858738ad63d581a8731
Summary:
This makes it a little more convenient to dynamically load font files. We currently do with help from the "assetExts" config flag and find that we specify it a lot. Would you be interested in taking this PR?
Closes https://github.com/facebook/metro-bundler/pull/14
Differential Revision: D5284158
Pulled By: jeanlauliac
fbshipit-source-id: d102cf4776b9e3659c33e15d9d72f7ea0ea52d57
Summary:
With these last fixes, the test is now finishing properly instead of hanging up forever! This means tests should now hopefully pass on CircleCI, amazing!
I had to disable a test that was actually broken, I'd like to fix that in a separate changeset.
Reviewed By: davidaurelio
Differential Revision: D5282917
fbshipit-source-id: d61b13ed40da7cd43a542ad916158a2aefecda18
Summary:
We use a custom rn-cli.config.js file that specifies a custom blacklist. In addition to blacklisting some of our own directories, we still want to keep RN's default rules for what to blacklist so we also call into the packager's blacklist.
Closes https://github.com/facebook/metro-bundler/pull/13
Differential Revision: D5275117
Pulled By: davidaurelio
fbshipit-source-id: 0ad79fa47b8730af5a2c4e9ecbedf02b7d673b6c
Summary: Use `processDgraph` so that the instance is properly ended. Tested using `yarn jest DependencyGraph-test`
Reviewed By: davidaurelio
Differential Revision: D5274139
fbshipit-source-id: 82e919e0f7248ddd01de9c8fa3908c3943184016
Summary: Use `processDgraph` so that the instance is properly ended. Tested using `yarn jest DependencyGraph-test`
Reviewed By: davidaurelio
Differential Revision: D5274137
fbshipit-source-id: d4f46d9b2c02622c81bd178c2b76c9cea89b6dd0
Summary: Use `processDgraph` so that the instance is properly ended. Tested using `yarn jest DependencyGraph-test`
Reviewed By: davidaurelio
Differential Revision: D5274132
fbshipit-source-id: 9a19482f969f105d4e2ec6dffc5ae901a5a7da32
Summary:
**Summary**
fixes edge case for replacing browser "main" field, when "main" field value is a file name rather than a file path
**Test plan**
added breaking test in 1st commit, fix in 2nd commit
Closes https://github.com/facebook/metro-bundler/pull/3
Reviewed By: cpojer
Differential Revision: D5255292
Pulled By: jeanlauliac
fbshipit-source-id: 65764144adfcda9f6dbdf8f5f754186b05e1a8bb
Summary:
`retainLines` is no longer necessary with the much improved source map generation.
`sourceMaps` is handled by the transformer itself.
Reviewed By: cpojer
Differential Revision: D5237103
fbshipit-source-id: e5c6bf5aa9d553fce9c3f4d59b3ea0057d45cfdc
Summary: The `DependencyGraph-test` hangs forever if run in isolation because the watch mode is not properly ended. I propose we just wrap each test in a function that does the correct thing, and also migrate tests to `async`/`await`.
Reviewed By: cpojer
Differential Revision: D5245477
fbshipit-source-id: ea30c0e637e0c7b85afe4c76c5e985846ae9b243
Summary: `worker.transformCode` is a callback-taking function, but did not properly guard against errors thrown in its body.
Reviewed By: cpojer
Differential Revision: D5245253
fbshipit-source-id: 3fd08b68dd8605f664b316652ebd1f9497b2dac9
Summary: That happens after a reboot on macOS for example, because temp dir is wiped.
Reviewed By: davidaurelio
Differential Revision: D5236249
fbshipit-source-id: be19cd97a7488850e3195b3fc419779ed0df2c38
Summary:
This diff cleans up some cruft and adds some features:
* It removes the usage of an env variable to control workers.
* It removes the lazy and handwavy calculation on how many workers to use for jest-haste-map. Jest itself uses the maximum amount of workers available and it has never been reported as an issue – especially since it is a one-time startup cost of about 3 seconds on a cold cache only.
* It adds a `--max-workers` flag to replace the env variable. This one is able to control both the number of workers for `jest-haste-map` as well as the transformers.
* It makes the transformers run in the parent process if 1 or fewer workers are are specified. This should help with debugging.
Once you approve this diff, I will publish a new version of metro to npm and update the version used in RN and remove the use of the env variable altogether: https://our.intern.facebook.com/intern/biggrep/?corpus=xplat&filename=&case=false&view=default&extre=&s=REACT_NATIVE_MAX_WORKERS&engine=apr_strmatch&context=false&filter[uninteresting]=false&filter[intern]=false&filter[test]=false&grep_regex=
Note: the process of adding a CLI option is really broken. Commander also has a weird API. We should consider building a better public API for Metro and then consider how to build a new CLI on top of it and simplify our internal integration. I really don't like how Metro is integrated across pieces of the RN cli in ways that is hard to manage. But that is a larger task for another time :)
Reviewed By: jeanlauliac
Differential Revision: D5217726
fbshipit-source-id: 74efddbb87755a9e744c816fbc62efa21f6a79bf
Summary: Upgrades uglify to version 3 with (experimental) ES6 support turned on.
Reviewed By: cpojer
Differential Revision: D5227245
fbshipit-source-id: db8638eebe2daf40b60570cac34905e9a7288705
Summary: I wanted to settle #18056064 once and for all. This solution both uses (1) random generation of temp dir, and (2) minimal overhead in the repo. The reason random generation of temporary folder directory names should always be used is the same as why [`mktemp(3)` should never be used](http://man7.org/linux/man-pages/man3/mktemp.3.html#BUGS). The reason we don't want the cache to be fully stored locally (2) is because watchman would catch too many change events we don't care about, hitting performance. Additionally, (1) has the benefit that when one clones the repo from fresh, it'll also always start with a fresh cache. (1) uses a function equivalent to [`mkdtemp(3)`](http://man7.org/linux/man-pages/man3/mkdtemp.3.html), that we cannot use here because it's POSIX and not exposed by the Node.js API.
Reviewed By: davidaurelio
Differential Revision: D5199698
fbshipit-source-id: a660ebbc470e1fe90ed1ab9d0c9fda063b06f90c
Summary: Puts all invocations of `uglify.minify` into one place to facilitate the upgrade to Uglify 3
Reviewed By: cpojer
Differential Revision: D5218415
fbshipit-source-id: 8085255205f80bfda06e0092c9e268a85947763b
Summary: The 'class' suffix was just to workaround case-insensitivity on macOS.
Reviewed By: cpojer
Differential Revision: D5208747
fbshipit-source-id: 46bff156145880b9a894ff70b0c3dff0895a6d6c
Summary:
The 'fs' mock was set up to require 'graceful-fs', which used to delegate to the corresponding mock. After turning off automocking, this no longer necessarily works.
This moves the mock to `fs.js` and makes the mock for graceful-fs require the fs mock via a relative path.
Reviewed By: cpojer
Differential Revision: D5209130
fbshipit-source-id: d468577e09d18382d0b9602ad0964dd880ec2366
Summary: That should improve the hit rate a little bit, notably for the cache-filling script. On OSS side, this changeset only adds the sleep() function as `FBGlobalTransformCache` is not exposed.
Reviewed By: cpojer
Differential Revision: D5201196
fbshipit-source-id: c2d8e1a1b03edd9e7747b3202c574b0783f4117d
Summary: We don't actually need this object anymore, just the function to test a file existence. This simplification allows us to phase out the 'old' HasteFS object easier, as well as adding retry logic using the real filesystem.
Reviewed By: cpojer
Differential Revision: D5208550
fbshipit-source-id: a03317e4385d793643e2dbee5d6782491d20e33c
Summary: We are flipping the switch all over Facebook, now that this part of the code is isolated we can do it in Metro as well.
Reviewed By: davidaurelio
Differential Revision: D5199449
fbshipit-source-id: 20c1bacc6dd2d314bd76bc5cc0ecd13266bf81c6
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
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
Summary: This should fix the e2e test for OSS.
Reviewed By: cpojer
Differential Revision: D5164267
fbshipit-source-id: d858b4811f0eb80ca7363177f4f384b66af13994
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
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
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
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
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
Summary: This allows us to get the new fix for recovery on duplicate modules.
Reviewed By: cpojer
Differential Revision: D5128975
fbshipit-source-id: 5a2b60430bbca1806a97798c482af8522366e071
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
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
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
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
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
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
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
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
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
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
Summary: Because we don't want to test for `empty-module.ios.js`, etc. We know the module is supposed to be here. This simpler version makes it easier for me to switch the rest of the `loadAsFile` callsites to the "candidates" system to the "candidates" system.
Reviewed By: davidaurelio
Differential Revision: D5103816
fbshipit-source-id: 7e7d9be27573a1f33d562aeb850759e073fbc72f
Summary: For the Buck integration (work-in-progress), we want to add the ability to do some custom preprocessing similar to the packager server. The signature is different so I prefer to have a separate function for that. Also we don't need the transform options right now, I suggest we don't add them for now and add them later if necessary.
Reviewed By: davidaurelio
Differential Revision: D5094632
fbshipit-source-id: 1775ddef90b331deabc5be3e57a67436bce06c82
Summary:
'source' is not available in all shells on Linux (e.g. dash) and will silently fail launchPackager.command when called from runAndroid.js.
react-native run-android will thus silently fail to start the developement server ('JS server').
What existing problem does the pull request solve?
When running "react-native run-android" on the below reasonably vanilla Ubuntu system, the development server / packager script fails to start. It fails because sh defaults to dash (not bash) which doesn't know the command 'source'. dot (.) does the same as source, but works in all shells.
$ uname -a
Linux dallas 4.8.0-52-generic #55~16.04.1-Ubuntu SMP Fri Apr 28 14:36:29 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ which sh
/bin/sh
$ readlink -f /bin/sh
/bin/dash
react-native-cli: 2.0.1
react-native: 0.44.0
$ ps aux | grep packager
(nothing)
ps aux | grep packager
sh /home/xxx/code/react-native/AwesomeProject/node_modules/react-native/packager/launchPackager.command
node /home/xxx/code/react-native/AwesomeProject/node_modules/react-native/packager/../local-cli/cli.js start
Closes https://github.com/facebook/react-native/pull/14040
Differential Revision: D5096298
Pulled By: hramos
fbshipit-source-id: 88466e802c9bc4358840391edb37e153f0a6b1f7
Summary: Changes the `sourceMappingURL` comment from multi line to single line.
Reviewed By: johnislarry
Differential Revision: D5094791
fbshipit-source-id: f8fa2efd7f173290cac985564c06b4a118a80aae
Summary: separates modules of the dependency graph from the generated require calls to kick of the app. This is required to make RAM bundle generation work properly'
Reviewed By: jeanlauliac
Differential Revision: D5094635
fbshipit-source-id: fca69a3e2d9b030cdc4d4405c2b5e795b0d55f87
Summary: Releases the dependency map of modules after running the factory in release mode in order to save memory.
Reviewed By: cpojer
Differential Revision: D5086693
fbshipit-source-id: 68c57a2f98182ed1a732e1336e6d4fe5ce27abc3
Summary: RN configuration allows to specify a post-minify hook. This wasn’t called in the new Buck integration so far. Added here.
Reviewed By: cpojer
Differential Revision: D5087325
fbshipit-source-id: 74b58bd3a203716d8f01b5d7ba552b6ad1b575ce
Summary: Internally we use `multipart/form-data` to upload transformed files to the global cache, using the keys as file names. Unfortunately the server would read that and consider only the basename as the key, not the full path. So we wouldn't store the data under the right key. This is definitely a bug in the way upload is implemented: we should transmit the keys separately. But, this changeset offers a quick mitigation by avoiding slashes in the key, so that the whole key is a valid base file name.
Reviewed By: davidaurelio
Differential Revision: D5087780
fbshipit-source-id: 9e4a698c1f57c4c3b91b56b43eef82c1c7dd862b
Summary: Better to have *some* Flow coverage (I'd like 100% of packager covered from when we split it apart) than none.
Reviewed By: davidaurelio
Differential Revision: D5077757
fbshipit-source-id: b23169b3edf2bd3eb0e8a399d099151aa705b198
Summary:
It was hard to type the resolution main algo, I had to put type annotations explicitely everywhere, otherwise Flow would get in some kind of loop and do weird errors. I think it's because the algo is recursive and Flow tries to infer types too deeply because of the generics.
Anyway, apart from that it's good to get this extra type security in the few other places. We require Node v4 minimum, that according to the internets supports the `class` syntax without transform, and I verified that inheriting from `Map` actually works as expected.
Reviewed By: davidaurelio
Differential Revision: D5078023
fbshipit-source-id: 05dfc4acf5b07cdda8a7b36ec9cba216d1810643
Summary: Or, a case in point that Flow doesn't saves us from all the ills. I think it didn't complain because `MapWithDefaults` doesn't have proper typing. I'll deal with that separately.
Reviewed By: davidaurelio
Differential Revision: D5077707
fbshipit-source-id: c43623c5046d2dea9964685a44ad4877d060232e
Summary: I'd like to start typing the front-end so that it's easier to track adding new options, etc.
Reviewed By: davidaurelio
Differential Revision: D5069868
fbshipit-source-id: 9a18dca52efd486ca18f17d0ec434a5ec1c1649c
Summary: This makes it easier to verify correctness when adding new config/args.
Reviewed By: davidaurelio
Differential Revision: D5069537
fbshipit-source-id: 4d8058851900b23163d0f2744e91dd14dfcdd461
Summary:
The existing resolution logic of assets:
* goes over all the files of the asset's directory for every resolution request;
* duplicates the parsing logic of `AssetPaths` by building up a custom regex for each resolution request.
This changeset proposes to tweak this by building an index for each particular directory in which we're looking for assets, so that we don't have to crawl a single directory twice, and so that it reuses the logic of `AssetPaths.tryParse()` for determining variants.
Reviewed By: davidaurelio
Differential Revision: D5062435
fbshipit-source-id: 708fc5612f57b14565499fad741701269438c806
Summary:
We appended a `sourceMappingURL` in the same place where we write out the files. This will break output that is not a plain text file, like Random Access Bundles.
This moves the corresponding logic into the function that builds the bundle.
Reviewed By: cpojer
Differential Revision: D5061039
fbshipit-source-id: 17fadb5a687c8d4b1f29439e8bf946bae58eb2d9
Summary:
Not only is this function is building a custom Regex for every single file, but it's also duplicating some of the work of the inner function, that is already splitting up the platform/extension. This changeset refactors both function to have a more strict and legible logic to extract asset information. We extract the base name first, then we extract the resolution from it, instead of rematching platform and extension.
I stumbled on this while looking into refactoring the asset resolution logic of `ResolutionRequest#_loadAsAssetFile()`. The next step would be to reuse the exact same function for resolving assets instead of using a custom regex there as well.
Reviewed By: davidaurelio
Differential Revision: D5060589
fbshipit-source-id: b48d9a5d8e963be76cad5384c6bfb3e214a73587
Summary: Add Flow types, revealing a few problems, such as `isHaste` having the wrong return value in the "pseudo-mocks". But since the buck worker is in fact working, I guess these functions were never called... The point of typing this file is that I'm going to start aggressively pruning dead code in `node-haste` and hopefully, eventually, get rid of `Moduleish` and `Packageish`.
Reviewed By: davidaurelio
Differential Revision: D5052379
fbshipit-source-id: dab3f18f05fcf43fbbc48b589170b1cf367d6a48
Summary: This does not appear to be used anywhere anymore.
Reviewed By: cpojer
Differential Revision: D5052224
fbshipit-source-id: 142fdcdf48f4ad16a04bb747b41d623f214f7a68
Summary: Default arguments are dangerous, and it shows here again. `Server` was calling that function without passing down the platforms, meaning custom platform would not be accounted for, possibly causing all kinds of bugs for OSS use cases. Additional, the typing of `platform` across the stack was wrong: it can be `null`, in which case we resolve the files without extension. The reason Flow didn't detect that issue before is because we use `Object.assign` to re-export the function from `DependencyGraph`, but Flow is not smart enough to propagate the types in that particular case. I'll remove all the other re-export, as it may uncover further type errors.
Reviewed By: davidaurelio
Differential Revision: D5052070
fbshipit-source-id: 7b427ec036ca74b5dcd7c88f7dfa0df541b8eb6b
Summary: in new-style builds, the prelude is not wrapped into an IIFE, so `global` is not available. Since the bundle as a whole is not running in strict mode, we can access the global object with `this`.
Reviewed By: jeanlauliac
Differential Revision: D5051731
fbshipit-source-id: 4003b5e57ba8626e38e68e92d5778c2c59ca69a5