Commit Graph

330 Commits

Author SHA1 Message Date
Jean Lauliac 029483d796 metro-bundler: tweak babel-register callsite
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
2017-07-07 04:10:28 -07:00
Jean Lauliac 7450484d94 metro-bundler: fix DependencyGraph-test
Reviewed By: mjesun

Differential Revision: D5371267

fbshipit-source-id: 689f7c5b2920cb15d7ba6c50c34a94344b2a686b
2017-07-07 03:23:27 -07:00
David Aurelio 7111cf6e4e Bump dependencies
Summary: Bump dependencies to the same version that react native uses

Reviewed By: jeanlauliac

Differential Revision: D5364009

fbshipit-source-id: 302db951a5509584da13a18a7fab6965e0b1e394
2017-07-06 14:36:22 -07:00
David Aurelio efa753c2e4 Restore file header for RAM bundles
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
2017-06-30 11:07:02 -07:00
Jean Lauliac b96d886982 metro-bundler: upgrade jest-haste-map
Reviewed By: cpojer

Differential Revision: D5346860

fbshipit-source-id: 16e9eeeb28804af81428745fda4ffc05a461845c
2017-06-29 08:36:14 -07:00
Christopher Chedeau e0ea0aae1d Codemod prettier to 1.5.2
Differential Revision: D5339725

fbshipit-source-id: 631338436a7d69b0ab0721507bdab4ae4e207065
2017-06-28 13:00:25 -07:00
David Aurelio 429c1e8032 Use `jest-docblock`
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
2017-06-27 03:51:37 -07:00
Chris Blappert f7ad406c23 Packager postprocessing hook
Reviewed By: davidaurelio

Differential Revision: D5244060

fbshipit-source-id: 3f5f9ab9aeeb63eca13d6dab089c2bda42f70c33
2017-06-26 10:36:25 -07:00
David Aurelio 3cf8242128 Trim doc block annotations after parsing
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
2017-06-26 06:11:42 -07:00
David Aurelio 01e1ff3b0a metro-bundler: fix e2e test
Reviewed By: jeanlauliac

Differential Revision: D5310764

fbshipit-source-id: 275285086f92e7cb6a4e94afeb8ec535c663097c
2017-06-24 17:08:15 -07:00
David Aurelio 5f0c5b231e Allow to resolve assets with explicit platform extension
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
2017-06-23 16:40:33 -07:00
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
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 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
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 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
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