Commit Graph

2108 Commits

Author SHA1 Message Date
Rafael Oleza f5bb45ffdd Do not transform Platform.select() calls using dynamic properties
Reviewed By: davidaurelio

Differential Revision: D7085775

fbshipit-source-id: 348e43312ecb8298c14b202f209850b54d9b7b12
2018-02-28 04:34:15 -08:00
David Aurelio 36cee35684 Remove `getOptions()` from `DeltaBundler`
Summary: More cleanup of `DeltaBundler` in order to move from `Bundler` to `ModuleGraph`. I am trying to remove all unrelated functionality to make the transition easier.

Reviewed By: rafeca

Differential Revision: D7100153

fbshipit-source-id: 2e0c2d4957dece27bd28d3cf7e4ff2e178c60fb2
2018-02-28 04:04:33 -08:00
Jean Lauliac 50356b7408 metro-resolver: simplify API with exceptions
Reviewed By: mjesun

Differential Revision: D7098249

fbshipit-source-id: 5eea3dfdc54a98d295b756296398fd3a1dd3890b
2018-02-28 03:08:23 -08:00
Jean Lauliac a66a231dfc metro: DeltaBundler-test: use memory-fs
Reviewed By: rafeca

Differential Revision: D7098504

fbshipit-source-id: 5c2c7b88b2a9b41f3c7d75613c7ab290622176ea
2018-02-28 02:29:26 -08:00
Rafael Oleza 2b32b08b13 Pass the sourcemap variable correctly to the transformer
Reviewed By: Hypuk

Differential Revision: D7102063

fbshipit-source-id: b6162e6f9052099afec02a67e3ea44da2a6ea8be
2018-02-27 14:37:55 -08:00
Jean Lauliac 019622ce50 metro: extract MemoryFS into its own package
Reviewed By: mjesun

Differential Revision: D7098381

fbshipit-source-id: 0ac9d71b7912c9d448468b64969d04a8cc9c853d
2018-02-27 10:51:13 -08:00
David Aurelio 4f35a6d8a1 Remove unused type import
Summary: Removes an unused type from `Bundler`

Reviewed By: jeanlauliac

Differential Revision: D7084608

fbshipit-source-id: 213a49466c9745c4bb85b8b16a8b2e4309b5a524
2018-02-27 09:31:47 -08:00
David Aurelio 958a147162 less mocks in `Serializer-test`
Summary: now that RAM bundle info building is an implementation detail, we make it part of the test rather than mocking it out.

Reviewed By: rafeca

Differential Revision: D7084580

fbshipit-source-id: edbb7b3d1aaca5513ea81d8d2c62b4b5c8e97756
2018-02-27 09:31:47 -08:00
David Aurelio 356d896c01 remove `getRamOptions` from `DeltaTransformer` and `Bundler`
Summary: Removes `getRamOptions` from `DeltaTransformer` and `Bundler` for better separation of concerns, and ultimately, porting delta functionality to `ModuleGraph`

Reviewed By: rafeca

Differential Revision: D7084487

fbshipit-source-id: e8a7ea4addbad9057e7d55627f77ebd01e64786b
2018-02-27 09:31:47 -08:00
Rafael Oleza 2393f849e3 Bump metro@0.28.0
Reviewed By: davidaurelio

Differential Revision: D7085296

fbshipit-source-id: 76032af022d37a28976b33176f9a573e39861a39
2018-02-26 09:59:01 -08:00
Rafael Oleza a645c21862 Add metro-minify-uglify dependency
Differential Revision: D7084802

fbshipit-source-id: bdc1eb1389f9caeb067240e221ebef7ceeb78cda
2018-02-26 09:01:10 -08:00
Peter van der Zee 2303f3b18d Make constant folding plugin use context for babel types
Summary: This makes the plugin use the passed on babel api rather than hardcoded pulling in babel 6 or 7. This is important since they are different packages now and we need to work with them side-by-side.

Reviewed By: mjesun

Differential Revision: D7083873

fbshipit-source-id: 2ce89e0627005bb29ff8d3e0e1ac51fe8ee4eabd
2018-02-26 07:58:33 -08:00
Christoph Nakazawa f179352292 Add `close` event to MetroClient
Reviewed By: rafeca

Differential Revision: D7083989

fbshipit-source-id: 7a4d4913d32e58a1efc6210dd7118b03b6ad6b2b
2018-02-26 07:19:54 -08:00
Christoph Nakazawa 063a6867b1 Cleanup HMR code, rename to MetroClient, add test
Reviewed By: BYK

Differential Revision: D7083982

fbshipit-source-id: ac8193b8025e8ff37d7316e11cafc09b58b7d358
2018-02-26 05:57:05 -08:00
Peter van der Zee 45dfd925fc Enable @flow in the inline tests
Summary: Enable the flow directive for the inline tests. Changes are related to getting Flow to green.

Reviewed By: jeanlauliac

Differential Revision: D7083814

fbshipit-source-id: f5efa35181663b30d9da437ffa727b3fa8f99b5a
2018-02-26 04:54:39 -08:00
Peter van der Zee 56e7aed7cb Let the inline plugin use the babel types from arg
Summary:
Before the inline plugin was explicitly requiring babel itself. With the babel upgrade path that's a problem since it will try to pull in babel 6 even when we want babel 7 (because it's a different package name). To remedy this the plugin is now a function which will use the `types` api from the given context rather than the required global.

I also moved out the `inline` function that only seems to be used in tests. They're now just living in the tests.

Had to add some flow annotations to generic objects since Flow was complaining about missing types and that would require adding the full babel api which is outside of the scope of this task.

Reviewed By: jeanlauliac

Differential Revision: D7083815

fbshipit-source-id: 59b8365d8c3c3dc00b23a3735037dcc9483c0b2c
2018-02-26 04:54:39 -08:00
Miguel Jimenez Esun 8292958c00 Allow passing custom configs through the CLI ("js1 run")
Reviewed By: jeanlauliac

Differential Revision: D7081913

fbshipit-source-id: f5952599c840f2c65213bd2928b21f0c1d84f510
2018-02-26 03:39:24 -08:00
Miguel Jimenez Esun d83903f614 Add "PersistedMapStore" cache
Reviewed By: davidaurelio

Differential Revision: D7050539

fbshipit-source-id: 78191ae25c7b28869ebedb4b0f90300bac52c580
2018-02-25 16:35:45 -08:00
Miguel Jimenez Esun 5edc2acc80 Add "FileStore" cache
Reviewed By: davidaurelio

Differential Revision: D7037483

fbshipit-source-id: b7517f2b3c8df3e5653dd1a756dfbee5bb2bd656
2018-02-25 16:35:45 -08:00
Rafael Oleza a62eaa0d3b Make the inline platform transform support string keys
Summary:
This diff makes the platform inline transformer support string keys, for example:

```
Platform.select({
  'ios': 'ios',
  'default': 'default',
});
```

This fixes https://github.com/facebook/metro/issues/134

Reviewed By: mjesun

Differential Revision: D7079013

fbshipit-source-id: 3e47bb4a28f2ac776475842982e089d5954d6521
2018-02-25 11:05:46 -08:00
Vladimir Timofeev 886c9b986c Fix npm deps
Summary:
**Summary**

This should fix install of the metro with npm (issue #142).
We can't have both babylon@6 and babylon@7 as deps for metro package, so as jeanlauliac suggested in https://github.com/facebook/metro/issues/142#issuecomment-368217279 lets create wrapper-package `metro-babylon7` and reexport babylon@7 from it.

**Test plan**

I do manually `yarn && yarn test` - all checks passed.
Closes https://github.com/facebook/metro/pull/143

Differential Revision: D7079144

Pulled By: rafeca

fbshipit-source-id: eeb4f6a01ad92d84dc14702dee07975e253bcf88
2018-02-24 09:21:43 -08:00
Rafael Oleza 41e7aa6f4a Improve readability of the traverse dependencies tests
Reviewed By: davidaurelio

Differential Revision: D7055471

fbshipit-source-id: dfac739159de0591d453511d4f4d7882beacb9bf
2018-02-24 04:29:24 -08:00
Rafael Oleza ff6f6ef1cf Make the delta protocol more robust by detecting when a client misses a delta
Reviewed By: davidaurelio

Differential Revision: D7031664

fbshipit-source-id: 22985ba45aa330780c8ddc44c07f5557e9e0d9c4
2018-02-24 04:29:24 -08:00
Burak Yigit Kaya a7fdc0f3c1 Add missing metro-cache dependency to metro
Reviewed By: rafeca, mjesun

Differential Revision: D7067918

fbshipit-source-id: 1d096dc3dc98c9ef7d6b47eee3b00e31a2427ec8
2018-02-23 10:45:41 -08:00
Jean Lauliac 0154fb32eb ModuleGraph/node-haste: remove dep over ResolutionRequest
Reviewed By: mjesun

Differential Revision: D7040976

fbshipit-source-id: 93d43342ee23b7f3496afbb532bbc12fefd6e61e
2018-02-23 10:36:52 -08:00
Burak Yigit Kaya 4670c08206 Bring metro-cache to 0.27.0 again
Reviewed By: rafeca

Differential Revision: D7067873

fbshipit-source-id: fa8d377c042f289c807160b8bb78392d00c8e1f4
2018-02-23 09:00:51 -08:00
Burak Yigit Kaya 4e33e7aa85 Release Metro 0.27.0
Reviewed By: davidaurelio

Differential Revision: D7067140

fbshipit-source-id: a2ae64a8049e5ef883c08f4abbe108401427b0aa
2018-02-23 07:51:31 -08:00
Miguel Jimenez Esun bd91fcf131 Add an "experimentalCaches" flag all the way down to Module
Reviewed By: jeanlauliac

Differential Revision: D6976974

fbshipit-source-id: fea0a3655fec924798567d690e2ee4f24465d5c5
2018-02-23 03:52:45 -08:00
Miguel Jimenez Esun 7486444a0a Pass cacheStores
Reviewed By: davidaurelio

Differential Revision: D7023425

fbshipit-source-id: 84d0d6585af4075bd7ac11ac3c97520caeae7b01
2018-02-23 03:52:44 -08:00
Miguel Jimenez Esun eab7030b2e Initial version of caches
Reviewed By: davidaurelio

Differential Revision: D7023408

fbshipit-source-id: 3411a34d7551f8c2e13087af6dae389c3468b1ee
2018-02-23 03:52:44 -08:00
Burak Yigit Kaya 3d061b34f7 Upgrade Jest to 22.4.2
Reviewed By: mjesun

Differential Revision: D7060484

fbshipit-source-id: 91cc7b6d66a2bb99242c144e011eef4393f87e9e
2018-02-23 03:52:44 -08:00
Miguel Jimenez Esun e4b1e773b1 Pass cache keys instead of cache props when talking to the GlobalTransformCache
Reviewed By: jeanlauliac

Differential Revision: D7031064

fbshipit-source-id: a99fb2775b84ce6b866c80be68f966dcd4ea57ca
2018-02-22 09:39:51 -08:00
Rafael Oleza 6da4bc4d30 Make sure that files that have been modified and deleted afterwards are marked as deleted
Reviewed By: davidaurelio

Differential Revision: D7030986

fbshipit-source-id: e00fc80ff6f5cb7bb49714d35c91361cb795ad0b
2018-02-22 09:39:51 -08:00
Michal Glaus 40c2449eec Pass numWorkers instead of maxWorkers to jest-worker
Summary:
<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->

**Summary**

Jest Worker accepts parameter `numWorkers`, not `maxWorkers`, see:
https://github.com/facebook/jest/tree/master/packages/jest-worker#numworkers-number-optional

<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

**Test plan**

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->
Closes https://github.com/facebook/metro/pull/136

Reviewed By: mjesun

Differential Revision: D7036411

Pulled By: rafeca

fbshipit-source-id: 5528ca4a9abe5a8e3668e83b214e10d97ba7a827
2018-02-22 08:31:07 -08:00
Burak Yigit Kaya a984719eef Upgrade Jest to 22.4.0 to pull fixes for jest-haste-map
Reviewed By: mjesun

Differential Revision: D7041111

fbshipit-source-id: 6dbd0cbf7b62a54d0b5f16bbf2fa81332542f14e
2018-02-22 06:15:23 -08:00
Maël Nison b354a81427 Uses Yargs instead of Command
Summary: This diff allows Metro to throw an error when a configuration file cannot be found, by using a new strict: true option.

Reviewed By: rafeca

Differential Revision: D6998613

fbshipit-source-id: b704633be18d5c007f1a022fa811d0a74c636fc9
2018-02-22 06:08:20 -08:00
Maël Nison eb72ad3794 Makes the Metro CLI commands injectable
Summary: This diff makes the Metro CLI commands injectable into any Yargs object, so that we can override various aspects of it, add extra commands, etc.

Reviewed By: davidaurelio

Differential Revision: D6988250

fbshipit-source-id: 217c661e4c1b05282b6cdbf4d745d1b29f5cbbe0
2018-02-22 06:08:20 -08:00
Peter van der Zee 60f16aafc2 Version bump babel-plugin-external-helpers
Reviewed By: cpojer

Differential Revision: D7054249

fbshipit-source-id: 5cb5619ab700e61a9f4feeceac0a5b803ddfdc15
2018-02-22 04:14:23 -08:00
Miguel Jimenez Esun 0f3f7daa4f Move mocking inside beforeEach for Transformer test
Reviewed By: rafeca

Differential Revision: D7040798

fbshipit-source-id: eece8c42e1368ead476c6d1495dad7e0abb4b0e3
2018-02-21 04:53:06 -08:00
Jean Lauliac d110c7b9ea metro: extract metro-resolver package
Reviewed By: rafeca

Differential Revision: D7011526

fbshipit-source-id: 523c54792cef1c31eef281e6e39bc25b20e2ceec
2018-02-21 04:53:06 -08:00
Peter van der Zee 5aa19c7626 Add minifier-path option to Metro
Summary:
This exposes the `minifierPath` externally and allows it to be adjusted through the `--minifier-path` argument.

This works for both the server (when starting the server) and running a single build through the CLI.

In server mode, this can not be used per file request yet, though that should also be doable if need be.

Reviewed By: rafeca

Differential Revision: D6998562

fbshipit-source-id: 669b876c24fe117ec88b2200d48aa82658f568b4
2018-02-20 04:22:00 -08:00
Peter van der Zee c080d70699 Start making the minifier an option for Metro
Reviewed By: jeanlauliac

Differential Revision: D6998187

fbshipit-source-id: 32e6fbb756ff119ed8a3070585e9f6c39fab1baa
2018-02-20 04:22:00 -08:00
Peter van der Zee e9e3a986c7 Add a minifier path option to the ModuleGraph path
Reviewed By: mjesun

Differential Revision: D6998189

fbshipit-source-id: 4876de98b9970088161d78e1b462688307ef477f
2018-02-20 04:22:00 -08:00
Rafael Oleza 25b201148b Refactor the traversal of dependencies logic
Reviewed By: jeanlauliac

Differential Revision: D7009928

fbshipit-source-id: a56e4d3b5a3b2c91f14affbc56cbca56c8526d06
2018-02-19 06:52:36 -08:00
Rafael Oleza cfe175254a Do not do unnecessary work when re-adding a file after deleting it
Reviewed By: mjesun

Differential Revision: D7009760

fbshipit-source-id: 18a93443226bdec4decb69f75539e27f528c128c
2018-02-19 06:52:36 -08:00
Rafael Oleza a5307e986e Make metro rely much less in the ModuleCache system
Reviewed By: jeanlauliac

Differential Revision: D6949157

fbshipit-source-id: cb5ef25aa582935f7c624375392be7fceefd87b6
2018-02-19 06:52:36 -08:00
Miguel Jimenez Esun 03c3b3d219 Fix JSTransformer/index test
Reviewed By: jeanlauliac

Differential Revision: D7019771

fbshipit-source-id: cbf232dc22f55d75dced3206b3c4ef1a472a7102
2018-02-19 04:59:47 -08:00
Peter van der Zee dd48bb1fa3 Improve Flow coverage
Reviewed By: mjesun

Differential Revision: D6999089

fbshipit-source-id: 5dfaef91909060b5a2bec0030048e97c2c2c3698
2018-02-19 04:24:08 -08:00
Sophie Alpert 2a327fb19d Update to MIT license
Summary: Manual changes.

Reviewed By: TheSavior, yungsters

Differential Revision: D7012152

fbshipit-source-id: de7459be3db13c687868b45059856f125c4f2eb1
2018-02-16 18:30:48 -08:00
Sophie Alpert 8242229b59 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:30:48 -08:00