Commit Graph

166 Commits

Author SHA1 Message Date
Rafael Oleza f8f1870248 Make the --transformer CLI argument override the babelTransformerPath
Summary: D9070810 introduced a breaking change, making the `--transformer` CLI argument able to override the generic transformer instead of `babelTransformer`. Since we still have some scripts that assume `--transformer` is being used for overriding the babelTransformer path, we cannot do this breaking change yet, so this diff reverts the CLI handling to the old behaviour.

Reviewed By: jrwats

Differential Revision: D9550157

fbshipit-source-id: 8b4e26fcb5bca6e4b2f63b1e1a014bce23a31452
2018-08-28 19:01:57 -07:00
Rafael Oleza e4621f4ce1 Expose the actual transformer in the config
Summary:
This diff exposes the new more generic way to configure transformers in `Metro` via the config parameter `transformerPath`.

The new generic transformers can be used to transform any kind of file, since they don't call any JS-specific method and their API is generic. They only need to implement a single `transform` method:

```
async function transform(
  absolutePath: string,
  relativePath: string,
  fileContents: Buffer,
  options: TransformOptions, // very soon these will be configurable
): Promise<{
  output: Array<mixed>,
  dependencies: Array<{
    name: string,
    data: mixed, // very soon
  }>,
}> {
  // ...
}
```

Metro already had a `transformModulePath` config param, which was used to configure how babel was called in order to generate the AST. In order to avoid confusion, but keep the current open source transformer worker, I've renamed this param to `babelTransformerPath`. We can add a layer of compatibility and detect old config params in order to show a deprecation warning.

Reviewed By: pvdz

Differential Revision: D9070810

fbshipit-source-id: aebde879736026c09537f5d236eae24c06640abf
2018-08-23 15:48:04 -07:00
Eric Rozell 7062e5bdb5 Apply `--reset-cache` argument to `bundle` command (#20706)
Summary:
The `--reset-cache` argument was not working correctly with the `bundle` command. This ensures the `--reset-cache` arg is passed to metro.

Fixes #20703

Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.

If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
Pull Request resolved: https://github.com/facebook/react-native/pull/20706

Differential Revision: D9400548

Pulled By: hramos

fbshipit-source-id: 2c7ed0226cfcdffa8cc77506500c314552baef3f
2018-08-20 10:02:58 -07:00
Héctor Ramos cf190bf601 Fix Flow errors (#20696)
Summary:
Revert change to flow strict-local in OSS.
Pull Request resolved: https://github.com/facebook/react-native/pull/20696

Differential Revision: D9367630

Pulled By: hramos

fbshipit-source-id: 17e4d1ab6d00b2e14033b223d878d5fcd1c098f4
2018-08-16 17:32:08 -07:00
Wayne Cheng f536a0c268 Adding flow strict local to remaining possible files in xplat/JS
Summary:
ag -L --ignore __snapshots__ 'flow strict|noflow|generated|The controller you requested could not be found.' | ag '\.js$' | xargs ag -l 'flow' | sort > ~/temp
  cat ~/temp | xargs ag -L 'flow strict' | xargs sed -i '' 's/flow$/flow strict-local/'
  until flow check; do flow check --json | jq -r '.errors[].message[0].path' | sort | uniq | xargs hg revert; done

allow_many_files
The controller you requested could not be found.
The controller you requested could not be found.

Reviewed By: TheSavior

Differential Revision: D9004573

fbshipit-source-id: 936bd5741706b781be06bf08b6ad805a69407dfd
2018-08-09 08:54:44 -07:00
Ives van Hoorne aaf797ad67 Use new config internally in Metro
Summary: Change the internals of Metro to use the new configuration instead of `ServerOptions`.

Reviewed By: rafeca

Differential Revision: D8734685

fbshipit-source-id: 1215f799419fcaa0e5fb7814683da1cbba96795c
2018-07-25 05:47:58 -07:00
Ives van Hoorne a32620dc3b Use new configuration in react-native public cli
Summary: Change the public react-native CLI to use the new configuration of Metro.

Reviewed By: rafeca

Differential Revision: D8801217

fbshipit-source-id: 112e4812b430ebee1ed41489f803b90c182ccdb4
2018-07-25 05:47:58 -07:00
Ives van Hoorne f0daaf3568 Convert internal react-native-cli
Summary: In this diff I change the internal react-native cli to use our new configuration. Another change here is that Metro starts using the new configuration already as its entry points (like `metro#runMetro`).

Reviewed By: rafeca

Differential Revision: D8728612

fbshipit-source-id: 9f43dee31ebaccd35cf6274d5c4dec0a227a6eec
2018-07-25 05:47:57 -07:00
Jean Lauliac ebf5aeab28 BREAKING: metro: rename 'unbundle' to 'ram bundle'
Summary:
@public

Let's get rid of the "unbundle" terminology and instead use "RAM bundle", short for "Random Access Bundle" format. THIS IS A BREAKING CHANGE FOR OSS, as the command becomes `ram-bundle` instead of `unbundle`. It realy shouldn't be a command to start with (only a "format" specifier for the `bundle` command), but I don't want to do that change at this point.

Reviewed By: davidaurelio

Differential Revision: D8894433

fbshipit-source-id: 5565f9ae94c7c2d7f6b25f95ae45b64f27f6aec8
2018-07-20 09:33:57 -07:00
Rafael Oleza 8ef90df28c Clean metro server correctly after bundle errors
Summary:
This is a very similar fix than D8858846, but done in the RN CLI (soon we'll be able to just call `Metro.runBuild()` from RN which will remove this duplication).

This actually fixes the issues in the integtration tests (t31612131). It's just funny that two unrelated problems that are caused by the same issue located in two different places have been reported at the same time.

Differential Revision: D8859276

fbshipit-source-id: 805e111a406f2a7c1b3df3ab02accf4c4041a464
2018-07-17 03:16:52 -07:00
Eli White eea4842972 Flow strictify possible files in RN core
Summary:
This was done by running the command on: https://our.intern.facebook.com/intern/wiki/Flow_Strict/

```
ag -L --ignore __snapshots__ 'flow strict$|noflow|generated|partially-generated' | ag '\.js$' | xargs ag -l 'flow' | sort > ~/temp
cat ~/temp | xargs ag -L 'flow strict' | xargs sed -i 's/flow$/flow strict/'
cat ~/temp | xargs ag -L 'flow strict$' | xargs sed -i 's/flow strict-local$/flow strict/'
until flow; do flow --json | jq -r '.errors[].message[0].path' | sort | uniq | xargs hg revert; done
```

Reviewed By: sahrens

Differential Revision: D8530207

fbshipit-source-id: c28c7ac5ed3e9b80f3d126d5f30463be8a8a744d
2018-06-20 00:47:21 -07:00
Alexey Kureev c5ce762697 Replace projectRoots with projectRoot + watchRoots
Summary:
We use projectRoots to limit crawling of jest-haste-map in large codebases. Since this implies multiple projects roots, it makes it very hard (or impossible) to reliably cache dependency resolutions.

If we can replace this with a single project root and a set of watch roots, we can have relative path resolutions for all dependencies which van be cached.

Reviewed By: rafeca

Differential Revision: D8450498

fbshipit-source-id: 830c21e847c3236e42d5414a8587508cb73864bd
2018-06-19 13:47:32 -07:00
Rafael Oleza 39d9d71adb Expose getResolverMainFields() config param
Reviewed By: mjesun

Differential Revision: D8380198

fbshipit-source-id: 3d5b7a5873095db2b90a23b5054fb94579df3f1a
2018-06-12 13:58:10 -07:00
Peter van der Zee 29fb2a8e90 Bump Prettier to 1.13.4 on xplat
Summary:
Bump Prettier to use version 1.13.4
All code changes are caused by running Prettier and should only affect files that have an `format` header.
All other changes caused by yarn.

Reviewed By: ryanmce

Differential Revision: D8251255

fbshipit-source-id: 0b4445c35f1269d72730f2000002a27c1bc35914
2018-06-06 05:32:06 -07:00
Eli White aba4ec0c09 Prettier RN local-cli
Reviewed By: yungsters

Differential Revision: D7962462

fbshipit-source-id: 0afe2092af8703895de91a6d1400315c3173aa6d
2018-05-11 13:00:50 -07:00
Miguel Jimenez Esun e2bea00c33 Remove TransformCaching.js
Reviewed By: jeanlauliac

Differential Revision: D7707146

fbshipit-source-id: 47f4c47b22cf65cfee05f63ad7dd81a5faf9c504
2018-04-27 06:47:26 -07:00
Rafael Oleza 06ec0f0fd1 Expose the asyncRequireModulePath param
Reviewed By: mjesun

Differential Revision: D7709569

fbshipit-source-id: 871dd9c178b1e5c81163558201ef983315561211
2018-04-20 14:23:23 -07:00
Miguel Jimenez Esun fc694fef66 Clean buildBundle.js, index.js and Flow types
Reviewed By: davidaurelio

Differential Revision: D7628725

fbshipit-source-id: 3873e5c7a0c9b988335dcf9b8a11fcf0598a9f50
2018-04-20 07:43:26 -07:00
Maël Nison 6be5d7827b Adds an experimental hook for custom resolutions
Reviewed By: mjesun

Differential Revision: D7337022

fbshipit-source-id: fea1ee345e4d3b5713fed6cdc33869fbba6f21e2
2018-04-05 09:00:04 -07:00
glevi@fb.com f3ef227904 Upgrade to Flow v0.69.0
Reviewed By: panagosg7

Differential Revision: D7437630

fbshipit-source-id: db9627afed89049c07a121296fbd52e2bfbf39bf
2018-03-29 06:54:06 -07:00
Rafael Oleza 15f0a7b76c Add getRunModuleStatement config param to configure the require() statements
Reviewed By: cpojer

Differential Revision: D7334078

fbshipit-source-id: c19340567c634e3173ee707e92389eaaa4e724e9
2018-03-20 07:24:56 -07:00
Rafael Oleza 6f339b6fcb Deprecate postProcessModules config param
Reviewed By: mjesun

Differential Revision: D7320671

fbshipit-source-id: 979108f0931f9ee0dd820025782137d4c726d19f
2018-03-20 07:24:56 -07:00
Miguel Jimenez Esun dabe8e0d01 Allow passing custom configs through the CLI ("js1 run")
Reviewed By: jeanlauliac

Differential Revision: D7081913

fbshipit-source-id: f5952599c840f2c65213bd2928b21f0c1d84f510
2018-02-26 03:48:43 -08:00
Jean Lauliac 33a893e18b react-native: prefer custom source extensions over default extensions
Reviewed By: mjesun

Differential Revision: D7066617

fbshipit-source-id: cdde7451cb817d62d6705071752fce0686cf04dc
2018-02-23 08:50:16 -08:00
Jean Lauliac 4454fdc219 fix Flow typing for OSS
Summary:
Add ignores for these requires, some of them mistakenly removed by da3424c929.

```
yarn flow
```

CircleCI should be green again.
Closes https://github.com/facebook/react-native/pull/18021

Differential Revision: D7025304

Pulled By: jeanlauliac

fbshipit-source-id: 731232093ae3ab39b3eff6fb2004ff4e7090d5ae
2018-02-19 10:41:33 -08:00
Caleb Meredith da3424c929 @allow-large-files Upgrade xplat/js to Flow v0.66
Reviewed By: gabelevi

Differential Revision: D7016717

fbshipit-source-id: 2bd2fd67074ba5d405ecd63a1aeb37354f8634c9
2018-02-16 20:24:57 -08:00
Sophie Alpert 1490ab12ef Update license headers for MIT license
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.

find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.

Reviewed By: TheSavior, yungsters

Differential Revision: D7007050

fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
2018-02-16 18:31:53 -08:00
Rafael Oleza 828cd78866 Pass cacheVersion param via the new API
Reviewed By: BYK

Differential Revision: D6980337

fbshipit-source-id: 72c01136b6720390ffec8593f0375c8756dc1d4a
2018-02-14 09:09:59 -08:00
Rafael Oleza 96ec2dcb71 Fix enableBabelRCLookup option in new CLI + global cache script
Reviewed By: BYK

Differential Revision: D6977885

fbshipit-source-id: 50245e046c7639f9fb4022a9cc5974d50831524c
2018-02-14 09:09:59 -08:00
Bhuwan Khattar 619a8c9f29 Pass hasteImplModulePath to JestHasteMap and everywhere else
Reviewed By: jeanlauliac

Differential Revision: D6641294

fbshipit-source-id: 36ebec95e69fe920c6cc10addd96406521cb4b82
2018-01-30 11:30:54 -08:00
Tom Duncalf 3f969cb1db Add minify flag to react-native bundle command
Summary:
We have found that it is useful to work with production rather than dev bundles when working on e.g. performance and animation tuning.

For a larger app, `react-native bundle` with `--dev false` can get very slow due to minification - in our case, this was especially true of library code (e.g. the AWS SDK taking nearly 15 secs to minify on a top-spec MBP 15"). This is fine when just building every now and then, but when making frequent changes and rebuilding, it becomes quite painful.

Currently there is no way to perform a release (non-dev) build, with minification disabled. This PR adds an optional `--minify` flag to enable developers to disable minification, reducing build times significantly for our use case.

Checked output bundle size, to ensure behaviour stays the same as the existing default when `--minify` is not specified, and that the `minify` flag gets passed through to Metro bundler correctly if specified.

N/A

[GENERAL] [ENHANCEMENT] [Bundler] - Added optional --minify flag to bundler
Closes https://github.com/facebook/react-native/pull/17702

Differential Revision: D6806356

Pulled By: shergin

fbshipit-source-id: c466a2dea692561f8b2002118662c3affc71b991
2018-01-30 00:42:54 -08:00
Jean Lauliac b5e19adc02 metro: allow dynamic dependencies from within node_modules
Summary: Tries to adress https://github.com/facebook/metro/issues/65. We need a reasonnable workaround to support modules like `moment.js` that do dynamic requires but only in some cases. By replacing the call by a function that throws, we move the exception at runtime instead of happening at compile time. We don't want to do that for non-node_modules file because they are fixable directly, while `node_modules` are not fixable by people and they get completely blocked by the error at compile time.

Reviewed By: rafeca

Differential Revision: D6736989

fbshipit-source-id: a6e1fd9b56fa83907400884efd8f8594018b7c37
2018-01-18 08:09:02 -08:00
Peter van der Zee bbbc18c4ee Remove unused `packagerInstance` option and rename it to `server`
Reviewed By: rafeca

Differential Revision: D6435505

fbshipit-source-id: e1912f20be517be49648b0eeb52c53f66e3fae55
2018-01-12 06:31:27 -08:00
Peter van der Zee 29dafa1a86 Move Terminal to metro-core
Reviewed By: rafeca

Differential Revision: D6532920

fbshipit-source-id: d1463aa0759a6b6d5cc46b05157518a4ce3eb9bf
2017-12-15 06:36:00 -08:00
Christoph Nakazawa 0091496891 Export Config/defaults on Metro's main module
Reviewed By: arcanis

Differential Revision: D6435529

fbshipit-source-id: a9549dc5900025fcc798ccb92b49e96c982c2e1e
2017-11-29 04:45:47 -08:00
Christoph Nakazawa 654fed46f4 Rename metro-bundler to metro
Reviewed By: davidaurelio

Differential Revision: D6413420

fbshipit-source-id: f13184b8157de2c3aeaa7f2647becc175f62cdbb
2017-11-29 03:35:29 -08:00
Peter van der Zee ae517307e7 Add a bundle type to logger output and type
Reviewed By: rafeca

Differential Revision: D6405599

fbshipit-source-id: 2f3da971d55fae28fbd94ed9f60d3bc2be176d6a
2017-11-28 04:46:25 -08:00
Rafael Oleza 0bbd9f042a BREAKING: Bump metro-bundler to v0.21.0
Summary:
`metro-bundler` v0.21 contains a rewritten bundling mechanism, with simplified logic and much faster rebuild times, called delta bundler. This release contains a couple of breaking changes:

* Now, when using a custom transformer, the list of additional babel plugins to apply are passed to the `transform()` method. These are used in non-dev mode for optimization purposes (Check 367a5f5db8 (diff-40653f0c822ac59a5af13d5b4ab31d84) to see how to handle them from the transformer).
* Now, when using a custom transformer outputting `rawMappings`, the transformer does not need to call the `compactMappings` method before returning (check d74685fd1d (diff-40653f0c822ac59a5af13d5b4ab31d84) for more info).
* We've removed support for two config parameters: `postProcessModules` and `postProcessBundleSourcemap`.

Reviewed By: davidaurelio

Differential Revision: D6186035

fbshipit-source-id: 242c5c2a954c6b9b6f339d345f888eaa44704579
2017-11-08 09:16:30 -08:00
Jean Lauliac 503b4521a6 metro-bundler: allow different run-before-main-module depending on entry point
Reviewed By: davidaurelio

Differential Revision: D6248242

fbshipit-source-id: 9471820fce926e676170e3024bd48c9d7335c1a7
2017-11-07 07:43:46 -08:00
Avik Chaudhuri a48da14800 @allow-large-files Flow 0.58 upgrade for xplat/js
Reviewed By: yungsters

Differential Revision: D6219339

fbshipit-source-id: f003111500ef5971b9a95f26d43cee6644c16abe
2017-11-02 10:51:14 -07:00
Miguel Jimenez Esun 834b9d4e6e Adding @email tags to most of the tests
Reviewed By: rafeca

Differential Revision: D6185623

fbshipit-source-id: 30df83288fe85516d8d5a1617a4fb8fea826ed6f
2017-11-02 06:25:03 -07:00
Rafael Oleza 01b941927c Update shared/output modules to accept the output from the Delta Bundler
Reviewed By: davidaurelio

Differential Revision: D6186386

fbshipit-source-id: 6160f5a02891dbfb56c6350239703ace91e53690
2017-10-31 10:23:20 -07:00
Alex Kotliarskyi cc86d12175 Android: put all non-drawable resources to `res/raw`
Summary: When we built packager asset system we were mostly concerned about images. However, this system can also be used to work with videos, animations and other binary resources. The code that sorts assets into Android resource folders currently just shoves all non-drawable resources under `drawable-mdpi`, which is not ideal. Talking to Android experts on the team, `raw` seems like a much better place for other resources.

Reviewed By: jeanlauliac

Differential Revision: D6026633

fbshipit-source-id: cc2199f60da411ea432972a02f52c459ff5c490a
2017-10-11 15:11:29 -07:00
Janic Duplessis 0cd69e8a02 Run eslint --fix
Summary:
CI is currently failing because of a lint issue, this fixes it and a bunch of other warnings that are auto-fixable.

**Test plan**
Quick manual test, cosmetic changes only.
Closes https://github.com/facebook/react-native/pull/16229

Differential Revision: D6009748

Pulled By: TheSavior

fbshipit-source-id: cabd44fed99dd90bd0b35626492719c139c89f34
2017-10-09 17:46:44 -07:00
Sam Goldman a16ef18a80 Upgrade Flow to v0.56.0
Reviewed By: calebmer

Differential Revision: D5958715

fbshipit-source-id: 7feda03a9540e69bf8d9b4eb89720248ff43294f
2017-10-02 21:11:05 -07:00
Rafael Oleza 34487c0591 Make the runBeforeMainModule config param to RN repo and make it absolute
Reviewed By: davidaurelio

Differential Revision: D5880700

fbshipit-source-id: 5df6781026030395900388c561283abadefa6511
2017-09-26 13:06:14 -07:00
Christoph Nakazawa 2f78d19df2 Use the Config type from Metro
Reviewed By: davidaurelio

Differential Revision: D5832633

fbshipit-source-id: 8e4e0e6a2907e485a5627c87161af2d0672b4f56
2017-09-15 05:00:10 -07:00
Marshall Roch 91b6b4efb9 @allow-large-files Flow v0.54.0
Reviewed By: leebyron

Differential Revision: D5773490

fbshipit-source-id: 2c54bb6326f23edbe9a969f3010f79da8189923e
2017-09-06 03:33:43 -07:00
Rafael Oleza eb6ba0b041 Enable delta bundler on metro-bundler behind a cli argument
Reviewed By: mjesun

Differential Revision: D5761110

fbshipit-source-id: 83127f63679caffbc4f335f52f6f5eda398e8c05
2017-09-04 13:45:25 -07:00
Jean Lauliac b6e0f4a12d RN local-cli: fix saveAsset scales filtering
Reviewed By: fkgozali

Differential Revision: D5688676

fbshipit-source-id: 2cf6d08b626a6e8c55db0b2293e13300f9606332
2017-08-24 06:40:45 -07:00