Commit Graph

1075 Commits

Author SHA1 Message Date
Jean Lauliac fbe6d9321e packager: worker-farm: isolate stdout/stderr
Reviewed By: davidaurelio

Differential Revision: D5011034

fbshipit-source-id: 81d3d49156775f9781427d3c103d768ccc30fe20
2017-05-08 11:31:20 -07:00
Jean Lauliac 7d6fec0a39 packager: optimize assets' JS
Reviewed By: davidaurelio

Differential Revision: D5010186

fbshipit-source-id: 3c26d8b8792df1dbc24e5200f28f63e017cb0173
2017-05-08 11:31:20 -07:00
Jean Lauliac 2a5959ae6e packager: buck assets: wrap in __d
Reviewed By: davidaurelio

Differential Revision: D5003464

fbshipit-source-id: 59800dded389d133394b60530eb97642d67a5c89
2017-05-08 11:31:20 -07:00
Jean Lauliac e69b81313f packager: ModuleGraph: include all possible asset types
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
2017-05-08 11:31:20 -07:00
Janic Duplessis 074fd33725 Packager - Fix symbolicate on windows
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
2017-05-08 11:31:20 -07:00
Kevin Old 7932b93fef Properly handle babel ignored files, returning only the contents
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
2017-05-08 11:31:19 -07:00
Jean Lauliac bc4de008d3 worker-farm: pass explicit execArgv to workers
Reviewed By: davidaurelio

Differential Revision: D5002197

fbshipit-source-id: 8f556626321963c103d38ec9865110a39f1a5109
2017-05-04 10:20:19 -07:00
Jean Lauliac 2de6e546bd worker-farm/lib/fork.js: cleanup
Reviewed By: davidaurelio

Differential Revision: D5002190

fbshipit-source-id: 07230f3e4fb059430124f44a82a928921904ed7b
2017-05-04 10:20:19 -07:00
Jean Lauliac 76d6f904b1 packager: faster terminal feedback
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
2017-05-04 09:20:55 -07:00
David Aurelio 1a0e78c4e4 Fix release / minified bundle builds
Summary: Fixes building release builds with the new buck integration.

Reviewed By: jeanlauliac

Differential Revision: D5002441

fbshipit-source-id: e7716324c7c8dd0bfcaf5b39cf716ac589e948e8
2017-05-04 08:31:10 -07:00
David Aurelio 11eef69936 Force `'default'` transform variant to be present
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
2017-05-04 08:31:10 -07:00
Jean Lauliac 4a86f93982 packager: add support for relative files with custom extensions
Reviewed By: cpojer

Differential Revision: D4994139

fbshipit-source-id: 5e47c5bc6f8b2cd750f1ca0df940c23234c66600
2017-05-04 05:21:44 -07:00
Andres Suarez 37f3ce1f2c Fix parseFloat mistaken uses of "radix"
Summary: It doesn't take a radix. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat

Reviewed By: yungsters

Differential Revision: D5000954

fbshipit-source-id: fe13896196f0369b1dce132cd4f30d086638740e
2017-05-03 23:00:39 -07:00
David Aurelio 382e633f78 Make bundle building function async
Reviewed By: jeanlauliac

Differential Revision: D4993758

fbshipit-source-id: b466e0d8d494914357f38eac1a0ef3c2ec7d4edd
2017-05-03 13:19:01 -07:00
David Aurelio 7eb005b4df Fix paths of module system and polyfills
Reviewed By: cpojer

Differential Revision: D4993289

fbshipit-source-id: d689ed8921c0d07ce2c1301cef3f5a75ff3a6e15
2017-05-03 13:19:00 -07:00
Jean Lauliac e5920e710c packager: fork local version of worker-farm
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
2017-05-03 09:46:04 -07:00
David Aurelio d2505e7615 disable `no-alert` eslint rule for node code
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
2017-05-03 06:51:47 -07:00
David Aurelio 66d51bb5d1 pull reusable logic out of `Bundler`
Reviewed By: jeanlauliac

Differential Revision: D4978045

fbshipit-source-id: 8e2ea14c983d4812e84ab644484380c98eb8da36
2017-05-03 04:00:50 -07:00
Lukas Piatkowski 976a181a1c Add additional post process of SourceMap after the minification of JS
Reviewed By: davidaurelio

Differential Revision: D4955229

fbshipit-source-id: ac4e5f917839d43d73b80d98b4813d8ccf1d41ef
2017-05-03 03:45:41 -07:00
Jean Lauliac e135bacb48 packager: Server: remove last declareOpts usage and replace by Flow types
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
2017-05-03 03:31:30 -07:00
David Aurelio 1adb318589 Separate node polyfills from runtime transforms
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
2017-05-02 05:35:22 -07:00
Jean Lauliac 91ff2159d9 packager: buck worker: better types
Reviewed By: davidaurelio

Differential Revision: D4970025

fbshipit-source-id: 77db309befebe539d25bd8df1039e2304176ca3f
2017-05-02 03:55:28 -07:00
Jean Lauliac cf4a98b053 packager: buck worker: output assets
Reviewed By: davidaurelio

Differential Revision: D4962816

fbshipit-source-id: 4ce4eacb28528c96829ac35134aff18a72063370
2017-05-02 03:55:23 -07:00
Jean Lauliac cc5997a2b1 packager: ResolutionRequest: keep option object as it is
Reviewed By: davidaurelio

Differential Revision: D4970219

fbshipit-source-id: 0e8a0b5e29452497e162d548229b086e0f91a516
2017-05-02 03:41:44 -07:00
David Aurelio a26e042784 Fix support for haste packages
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
2017-04-28 17:01:18 -07:00
Karol Kuczmarski 8fe24da6c2 Add getCacheKey() to the open source transformer
Reviewed By: davidaurelio

Differential Revision: D4965737

fbshipit-source-id: a343d0cd2e8832567e4e2eed1e2ac0b1657d91a0
2017-04-28 16:45:57 -07:00
Jean Lauliac fddb3b0737 packager: GlobalTransformCache: fix non-bound function
Reviewed By: cpojer

Differential Revision: D4972905

fbshipit-source-id: c9aaaba47f2c74bf48b7cbbc1255992d36ae32b1
2017-04-28 15:04:40 -07:00
David Aurelio 58ba7fc075 Unify source map types
Summary: deduplicates / unifies types for source maps across the code base

Reviewed By: jeanlauliac

Differential Revision: D4955924

fbshipit-source-id: 25cb71031dce835dd7d2bc1c27d6b20050906e81
2017-04-28 12:35:23 -07:00
Karol Kuczmarski 6202e02326 Pass only the first projectRoot to transform options
Reviewed By: davidaurelio

Differential Revision: D4955013

fbshipit-source-id: c07254f54a61ad71bf4cf153c97c8e4149fd4809
2017-04-28 11:19:04 -07:00
David Aurelio 414d5a3023 Change postprocessing hook to work on `ModuleTransport` instances
Reviewed By: amnn

Differential Revision: D4962283

fbshipit-source-id: 25b609bcd4b8d7a881e35426010f15530548e301
2017-04-28 10:03:07 -07:00
Jean Lauliac 1e6bca22db packager: TransformCache: include UID + do not use base64
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
2017-04-28 10:03:07 -07:00
Jean Lauliac eb72d5091a packager: TransformCache: store last cache collection time
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
2017-04-28 10:03:07 -07:00
Ashok Menon 978592faab Order modules in bundle by path.
Reviewed By: davidaurelio

Differential Revision: D4835227

fbshipit-source-id: 4974036fed7452447501fc07445afaa349e521c9
2017-04-27 17:46:40 -07:00
Jean Lauliac 1f8d1002ef packager: buck library: expose asset content
Reviewed By: davidaurelio

Differential Revision: D4945778

fbshipit-source-id: ea132a3d284ed09c59c69afbdd7b707af9e521b9
2017-04-25 12:04:01 -07:00
David Aurelio 3afbcfcd6b inline plugin: type options
Summary: Adds a stronger type for the inline plugin to help with future refactors

Reviewed By: jeanlauliac

Differential Revision: D4945842

fbshipit-source-id: f9bde75bf47271d80d2420d985a6a5609cee8952
2017-04-25 11:45:45 -07:00
David Aurelio 3e08a28987 Remove irrelevant options from cache key
Reviewed By: jeanlauliac

Differential Revision: D4938131

fbshipit-source-id: 88b686bc5ee6946297e1fd1b91d46fa618f0d9d7
2017-04-25 04:02:06 -07:00
David Aurelio 291a497bc4 make test independent from side effects
Reviewed By: jeanlauliac

Differential Revision: D4939025

fbshipit-source-id: cc7f811484cba0db4df394edef294cabe7343c8b
2017-04-25 04:02:06 -07:00
Jean Lauliac b6a7a711de packager: buck library: aggregate assets
Reviewed By: davidaurelio

Differential Revision: D4938032

fbshipit-source-id: afc4f4f97b7cc513eca9c925e09fbee4871216f4
2017-04-24 09:34:41 -07:00
David Aurelio 13f89f4e38 Stronger typing for transform options / remove duplication
Reviewed By: jeanlauliac

Differential Revision: D4929276

fbshipit-source-id: 0b23435a1502c72377425cae775e258106a5bf14
2017-04-21 08:57:03 -07:00
Jean Lauliac 9bbbfb46ea packager: AssetServer: @flow
Reviewed By: davidaurelio

Differential Revision: D4921672

fbshipit-source-id: 6405275bbd04550d7dd87cd5b8ef35a6cf5904f2
2017-04-21 04:01:02 -07:00
Jean Lauliac 2403b42cf9 packager: getAssetDataFromName: @flow
Reviewed By: davidaurelio

Differential Revision: D4921247

fbshipit-source-id: 47c516257cde5de6b69604d714e45310d00afe19
2017-04-20 07:35:15 -07:00
Jean Lauliac 79d9fd8f83 packager: correct transform for assets to avoid string
Reviewed By: davidaurelio

Differential Revision: D4913509

fbshipit-source-id: 9997da819483056d896fedecdc47510ecd381c03
2017-04-20 03:00:10 -07:00
Jean Lauliac f519f16180 packager: GlobalTransformCache: throat() the file fetching function
Reviewed By: cpojer

Differential Revision: D4914187

fbshipit-source-id: ae3b8aa4ed4dbd1896ca35cf498b7c02fd109f58
2017-04-19 11:00:41 -07:00
Jean Lauliac 0b339362ff packager: buck: fix messed up file types
Reviewed By: cpojer

Differential Revision: D4913706

fbshipit-source-id: 792d78e1baf7d9bea4eba90f791a1dc593087b55
2017-04-19 08:51:14 -07:00
Jean Lauliac 0001d3ce4e packager: worker: strenghten TransformOptions
Reviewed By: davidaurelio

Differential Revision: D4906499

fbshipit-source-id: e7948d09c678d3e270ddd9fd355597eb5d535781
2017-04-19 06:33:52 -07:00
Jean Lauliac de3478c1b1 packager: GlobalTransformCache: cache the transform options digest
Reviewed By: davidaurelio

Differential Revision: D4906974

fbshipit-source-id: b6cf83ba6a072400685948329070e171f65c837d
2017-04-19 03:15:38 -07:00
David Aurelio 50f0ade13d `getTransformOptions` can only return promises
Summary: Changes the contract for `getTransformOptions` so that it has to return a promises. That allows call sites to get rid of special logic / wrapping.

Reviewed By: jeanlauliac

Differential Revision: D4905959

fbshipit-source-id: c7d434c0766984e25987de1d769594e7c922d691
2017-04-18 11:21:10 -07:00
Jean Lauliac c6f5717d2b packager: ResolutionRequest: stronger option typing
Reviewed By: cpojer

Differential Revision: D4906382

fbshipit-source-id: 1696c3e7fe07c84a3a497740dc87a237d9b71d1e
2017-04-18 10:18:58 -07:00
Jean Lauliac 4ab4df07af packager: buck: transform-module: add support for assets
Reviewed By: davidaurelio

Differential Revision: D4868312

fbshipit-source-id: 44d20a5ed73637a9b3f43a99b5c82931f3e15dc6
2017-04-18 09:39:32 -07:00
Jean Lauliac 1c53c9b20f packager: Module: remove dead cacheTransformResults option
Reviewed By: davidaurelio

Differential Revision: D4884343

fbshipit-source-id: ae29757690d9b56d6f166bc86573aca9b1b6b65c
2017-04-18 09:39:32 -07:00