Commit Graph

1612 Commits

Author SHA1 Message Date
David Aurelio b62669e2da Publish v0.9.0
Reviewed By: bestander

Differential Revision: D5310936

fbshipit-source-id: a4d1b5f273c3fd6ba631834175d7e37e8589ef16
2017-06-23 13:07:43 -07:00
David Aurelio 08699062d5 npm package has `src/` rather than `build/`
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
2017-06-23 09:06:33 -07:00
Pieter De Baets a0fcbd7f11 Always stub console object
Summary: In some execution environment there's no console object available.

Reviewed By: davidaurelio

Differential Revision: D5303105

fbshipit-source-id: 1d348640c966c9460105ea92ec8a5087ee1b75f1
2017-06-23 08:01:59 -07:00
Miguel Jimenez Esun 30458c15ae WIP: Adding an output to provide a dot file with the dependency graph
Reviewed By: davidaurelio

Differential Revision: D5284123

fbshipit-source-id: e7c7519c4fefb66245dab3c5f205a8643067693a
2017-06-21 07:06:30 -07:00
Miguel Jimenez Esun b462183830 Adding support for RAM bundles - multiple files version
Reviewed By: davidaurelio

Differential Revision: D5277684

fbshipit-source-id: 77041375026d5c186022c8108acace7b519902fb
2017-06-20 11:57:15 -07:00
James Ide be1843cddc Add font file extensions (otf and ttf) to default supported extensions
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
2017-06-20 11:08:28 -07:00
Jean Lauliac 089461c0a8 metor-bundler: DependencyGraph-test: fixes last remaining tests with proper end()-ing
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
2017-06-20 04:44:49 -07:00
Jean Lauliac 1566ae81dd metro-bundler: DependencyGraph-test: re-enable win32 test subset for any platform
Reviewed By: davidaurelio

Differential Revision: D5275358

fbshipit-source-id: c14b8a054a85bff0374c5f3ef7e4edc7a1d1f06d
2017-06-20 03:37:19 -07:00
James Ide 75fa67e14d Add the blacklist creation function to the list of exports
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
2017-06-19 10:51:08 -07:00
Jean Lauliac d60b783e82 metro-bundler: DependencyGraph-test: use processDgraph for 'file watch updating' section
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
2017-06-19 10:07:25 -07:00
Jean Lauliac 3248d9945a metro-bundler: DependencyGraph-test: use processDgraph for 'node_modules (win32)' section
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
2017-06-19 10:07:25 -07:00
Jean Lauliac 88f0f0acfc metro-bundler: DependencyGraph-test: use processDgraph for 'node_modules (posix)' section
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
2017-06-19 10:07:25 -07:00
Christoph Pojer 54c4aed3b4 Print proper error from uglify
Reviewed By: jeanlauliac

Differential Revision: D5264809

fbshipit-source-id: 2a2c7c9af74e8c87acf68e2e9205c85b7aea2fb9
2017-06-16 10:25:44 -07:00
David Aurelio 2a085f0c1b Display snippets of TransformErrors
Reviewed By: cpojer

Differential Revision: D5247080

fbshipit-source-id: a0c4515476246e6da4c33c9129f6273af838d04f
2017-06-16 09:39:03 -07:00
Miguel Jiménez Esún af67937bba Export source maps utilities
Reviewed By: kittens

Differential Revision: D5249991

fbshipit-source-id: e2ad21bfa3497bc08c5afdcb0c7d9b76dc5dcc25
2017-06-15 10:38:57 -07:00
Mark Vayngrib ee31015d5c add breaking test, fix edge case for replacing browser "main" field
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
2017-06-15 09:11:41 -07:00
Avik Chaudhuri 67669d7676 update xplat/js to flow 0.48.0
Reviewed By: zertosh

Differential Revision: D5243415

fbshipit-source-id: 78ea4f7f29bcd6a70650f24ceb05f06b18b39018
2017-06-14 15:52:32 -07:00
David Aurelio 1e6b34f415 Backed out changeset db8638eebe2d
Reviewed By: alexeylang

Differential Revision: D5246311

fbshipit-source-id: cb12964c27a6d1e6fa719a979a8f0ebcc8efae8a
2017-06-14 09:53:06 -07:00
David Aurelio 1a286a9945 Make preset a function to account for different dev settings
Summary: Makes `babel-preset-react-native` a factory function that allows to include/exclude dev tool transforms per transform.

Reviewed By: jeanlauliac

Differential Revision: D5237158

fbshipit-source-id: aa7be0fc0f471575b4ee1c5a0e266e2ed2477fc6
2017-06-14 09:38:25 -07:00
David Aurelio 20ed5b8d3a Remove `retainLines` and `sourceMaps` options
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
2017-06-14 09:38:25 -07:00
Jean Lauliac d437b31fea metro-bundler: DependencyGraph-test: switch a bunch of tests to processDgraph()
Reviewed By: davidaurelio

Differential Revision: D5245656

fbshipit-source-id: 276e7406af2f6afb361d14b5c6e1dd5b9f1f6ddb
2017-06-14 08:08:44 -07:00
Jean Lauliac 4012f96c25 metro-bundler: DependencyGraph-test: proof of concept for proper test cleanup
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
2017-06-14 07:13:19 -07:00
David Aurelio e87a8205d8 Handle synchronous errors in `worker.transformCode`
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
2017-06-14 05:06:20 -07:00
David Aurelio fdc8f37a5b Replace `RNP:` debug prefix with `Metro:`
Reviewed By: jeanlauliac

Differential Revision: D5236970

fbshipit-source-id: 8bd1d38f009018e9cafef13188bee82351614890
2017-06-14 04:54:42 -07:00
Jean Lauliac 7e9f368ee5 metro-bundler: recreate temp dir if does not exist
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
2017-06-14 04:36:31 -07:00
Lxxyx 32e0d2c0d7 upgrade image-size version fix caculate webp image size bugs
Summary:
When I try to use webp for app. But some webp images get an error message `unsupported file type` by image-size@0.3.5.

And I in image-size repo I found a issue https://github.com/image-size/image-size/issues/65.
This is the same problem.

And try image-size^0.5.1 the error fixed.

![image](https://cloud.githubusercontent.com/assets/13161470/23597366/403a3070-026d-11e7-8666-f4357f1eee73.png)
Closes https://github.com/facebook/react-native/pull/14238

Reviewed By: davidaurelio

Differential Revision: D5145534

Pulled By: javache

fbshipit-source-id: a2aeeae19e928ffefbd0b32501d34069ed37386d
2017-06-13 09:44:02 -07:00
Christoph Pojer 9127fce33c Add --maxWorkers flag and allow transformers to run in-band.
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
2017-06-13 09:21:40 -07:00
Jean Lauliac 626fe47667 metro-bundler: fix percent progress output
Reviewed By: davidaurelio

Differential Revision: D5236226

fbshipit-source-id: efbbf46f4212a66a6357b7d87059f89354b6f50b
2017-06-13 08:40:52 -07:00
Jean Lauliac d3195fa528 ResolutionRequest: extract module resolution
Reviewed By: davidaurelio

Differential Revision: D5218015

fbshipit-source-id: 6e34df5913d96a0b518f9403309658ea0b559730
2017-06-13 07:27:24 -07:00
Miguel Jiménez Esún b559412a08 Pass bundle options to the reporter to provide additional information
Reviewed By: jeanlauliac

Differential Revision: D5172384

fbshipit-source-id: f2e4cf677f8113060b257ddec6b585870786a336
2017-06-12 10:52:16 -07:00
David Aurelio 573d9edfd0 Upgrade uglify to v3 + es support
Summary: Upgrades uglify to version 3 with (experimental) ES6 support turned on.

Reviewed By: cpojer

Differential Revision: D5227245

fbshipit-source-id: db8638eebe2daf40b60570cac34905e9a7288705
2017-06-12 10:11:20 -07:00
David Aurelio 2678b8fb0d Add nested yarn.lock 2017-06-12 18:07:19 +01:00
Jean Lauliac 5bae61e611 metro-bundler: fix DependencyGraph-test
Reviewed By: cpojer

Differential Revision: D5227270

fbshipit-source-id: 3d36394cafa658070d84d7b5ace2af48d20cc9d7
2017-06-12 07:09:12 -07:00
Jean Lauliac 62bbacafb5 metro-bundler: fix yarn.lock
Reviewed By: cpojer

Differential Revision: D5227317

fbshipit-source-id: b976365bcf06bc0dba4b247c1b4f35f8e11c66ef
2017-06-12 07:09:12 -07:00
Jean Lauliac d4bb0d3282 metro-bunder: caching: when using project dir, keep cache itself in temp
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
2017-06-12 04:50:58 -07:00
David Aurelio 4460ed5307 Unify invocations to `uglify.minify`
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
2017-06-12 02:22:13 -07:00
Miguel Jiménez Esún bc654954a7 Add prettier to metro-bundler, fixing code styling issues
Reviewed By: cpojer

Differential Revision: D5215552

fbshipit-source-id: 64106d322ccd3a39701a41e4efda4975db9aa52c
2017-06-12 01:20:50 -07:00
David Aurelio 1ce818dafc Move type definitions used for metro bundler from React Native
Summary: Moves type definitions for uglify and babel from React Native to Metro Bundler. We need it there.

Reviewed By: cpojer

Differential Revision: D5217795

fbshipit-source-id: 9ec349cd8caf077eaa3c6fa3d090ffd47893e967
2017-06-09 13:56:51 -07:00
David Aurelio d7461f1bc4 Don’t ignore `/build/` in `node_modules`
Summary: …or flow cannot find `jest-haste-map`

Reviewed By: cpojer

Differential Revision: D5218014

fbshipit-source-id: b361d262594ff4f75c334375b0677865c6a03915
2017-06-09 09:56:52 -07:00
David Aurelio 03dbae36d7 Ignore `build` directories
Summary: Makes it so that flow ignores `build/` directories throughout the code base

Reviewed By: cpojer

Differential Revision: D5217522

fbshipit-source-id: 1f3f0363e21b8bf504d31380e4a63c895c600f55
2017-06-09 07:37:39 -07:00
Christoph Pojer 150aa19fcb Remove babelRegisterOnly call in workers
Reviewed By: jeanlauliac

Differential Revision: D5208950

fbshipit-source-id: 093c1a67ed830480b42f556ee2d6be4ecfce9f0d
2017-06-09 07:22:26 -07:00
Jean Lauliac c1ff8b5b81 metro-bundler: rename Terminal back to normal
Summary: The 'class' suffix was just to workaround case-insensitivity on macOS.

Reviewed By: cpojer

Differential Revision: D5208747

fbshipit-source-id: 46bff156145880b9a894ff70b0c3dff0895a6d6c
2017-06-08 12:54:15 -07:00
David Aurelio 127f3312ed Fix mock inclusion
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
2017-06-08 10:15:23 -07:00
Jean Lauliac 795c436cb1 FBGlobalTransformCache: retry 3 times, wait between retries
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
2017-06-08 09:36:39 -07:00
Jean Lauliac 71275b4018 metro-bundler: ResolutionRequest: remove dep on HasteFS type
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
2017-06-08 09:08:30 -07:00
Christoph Pojer 802094c6f0 @format JSTransformer
Reviewed By: jeanlauliac

Differential Revision: D5208868

fbshipit-source-id: 3b80197c4e879974f9129ccfc4e4a7ca7d4b4258
2017-06-08 07:37:49 -07:00
Christoph Pojer 5e6d70d4d6 Disable automocking from tests
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
2017-06-08 05:52:18 -07:00
Jean Lauliac 01ecd43c62 FBGlobalTransformCache: retry on server-side errors
Reviewed By: cpojer

Differential Revision: D5200923

fbshipit-source-id: 9fd0d65e8d663437d27a3837580b07e386f70120
2017-06-07 11:22:12 -07:00
Christoph Pojer ef7965df63 Update package.json
Reviewed By: jeanlauliac

Differential Revision: D5183469

fbshipit-source-id: 89c17c80398afb7755d8e7dec5116e62fbbc520e
2017-06-06 12:37:37 -07:00
Jean Lauliac de34d9677c metro-bundler: fix integration test
Reviewed By: cpojer

Differential Revision: D5192165

fbshipit-source-id: 9ec8c8e5b6580e72c94771ff865337eb20e5dc94
2017-06-06 11:56:16 -07:00