Commit Graph

419 Commits

Author SHA1 Message Date
Mark Vayngrib b86f14738e support react-native field with fallback to browser field
Summary: React Native is a lot more powerful an environment than the browser, so we need an alternate mapping, as specified [here](https://github.com/defunctzombie/node-browser-resolve#browser-field)

An example:
```js
{
  "browser": {
     "./lib/server": false
   },
   "react-native": {
     "dgram": "react-native-udp",
     "fs": "react-native-level-fs"
   },
   "chromeapp": {
     "dgram": "chrome-dgram",
     "fs": "level-filesystem"
   }
}
```

on the other hand, if "react-native" is not present in package.json, you should fall back to "browser"

other than the one (nesting) test added, the tests are unchanged, just done for both "react-native" and "browser"

(I've implemented [react-native-udp](https://npmjs.org/package/react-native-udp) and [react-native-level-fs](https://npmjs.org/package/react-native-level-fs), but they obviously don't belong in the traditional "browser" field as they won't run anywhere except in React Native.)
Closes https://github.com/facebook/react-native/pull/2208

Reviewed By: svcscm

Differential Revision: D2691236

Pulled By: vjeux

fb-gh-sync-id: 34041ed50bda4ec07f31d1dc50dcdfa428af2512
2015-11-24 11:10:41 -08:00
David Aurelio ffea7793af Add babel helpers necessary for es2015 imports
Summary: public

Adding the babel helpers that are necessary to support ES2015 imports.

Fixes: https://gist.github.com/ehd/49cb2465df9da6b39710

Reviewed By: mkonicek

Differential Revision: D2690772

fb-gh-sync-id: b1b6c0c048bad809a5c58cdd0a2cbeaa11c72ea7
2015-11-24 09:17:29 -08:00
Tadeu Zagallo 16dd5d664b Add systrace markers to module require
Summary: public

Show modules' dependencies and time to load.

Reviewed By: davidaurelio

Differential Revision: D2603245

fb-gh-sync-id: a1d5067a8522b908b87fdfdd51ff4c4fdbc2edfc
2015-11-21 11:11:26 -08:00
Sebastian Markbage 43f18ffd08 Add infra for Prepack build option
Summary: This adds a build option for using Prepack (an experimental packager) to
build a bundle. It doesn't actually take on the npm package dependency
because it's not published/open source (yet).

This will be used while we experiment and should be maintained as the
build system changes so that we can continue getting fresh builds.

I found that saveBundleAndMap and processBundle were over abstracted and
got in my way so I inlined it and removed the unit tests because the unit
test was testing trivial code that is likely to change interface.

I went with a separate build phase and a separate Bundle class even though
there are a lot of commonalities. I imagine that the requirements for
Prepack will continue to diverge. Especially for source maps but a larger
refactor could try to unify these a bit more. The fact that modules are
wrapped before the write phase seems to be an unfortunate architecture
that makes this difficult.
Closes https://github.com/facebook/react-native/pull/4226

Reviewed By: amasad

Differential Revision: D2673760

Pulled By: sebmarkbage

fb-gh-sync-id: 299ccc42e4be1d9dee19ade443ea3388db2e39a8
2015-11-20 20:19:25 -08:00
Sebastian McKenzie 06e514076b Ensure correct Babel plugin locations in packager transform
Summary: Manually resolve all default Babel plugins. `babel.transform` will attempt to resolve all base plugins relative to the file it's compiling. This makes sure that we're using the plugins installed in the react-native package.

**NOTE:** Haven't tested this. Please don't merge until Travis has done CI.
Closes https://github.com/facebook/react-native/pull/4248

Reviewed By: svcscm

Differential Revision: D2679651

Pulled By: davidaurelio

fb-gh-sync-id: 0cdef1e738ba28c09c811432a71047f80540ed7b
2015-11-20 07:54:29 -08:00
Pieter De Baets 1a1c3f76a2 Port CatalystLoggingTestCase to iOS
Reviewed By: nicklockwood

Differential Revision: D2658485

fb-gh-sync-id: e6803aefee69ee058651fc4c8c202619543f0cd2
2015-11-20 04:41:24 -08:00
Tadeu Zagallo e623940b3e Add ternary elimination support to the WPO pass
Summary: public

Replaces

```
__DEV__ ? foo() : bar()
```

with

```
bar()
```

for non-dev builds.

Reviewed By: davidaurelio

Differential Revision: D2663838

fb-gh-sync-id: 30fdfa72dda89fc0d340da359e0f43db2917fcf5
2015-11-17 11:14:15 -08:00
Tadeu Zagallo 0b46a0c13b Add a naive WPO implementation
Summary: public

RFC: The minifier haven't been stripping dead-code, and it also can't kill unused
modules, so as a temporary solution this inlines `__DEV__`, kill dead branches
and kill dead modules. For now I'm just white-listing the dev variable, but we
could definitely do better than that, but as a temporary fix this should be
helpful.

I also intend to kill some dead variables, so we can kill unused requires,
although inline-requires can also fix it.

Reviewed By: vjeux

Differential Revision: D2605454

fb-gh-sync-id: 50acb9dcbded07a43080b93ac826a5ceda695936
2015-11-17 03:39:28 -08:00
Christoph Pojer 5b4244d755 Sync new haste features from upstream
Reviewed By: amasad

Differential Revision: D2644383

fb-gh-sync-id: 5225e6afb8e5b835865473b2880a77235e6bd6eb
2015-11-16 22:50:30 -08:00
Tadeu Zagallo 2fb03be046 Fix babelHelpers.extend
Summary: public

The recent change to move babelhelpers out of the module broke the extends method.

Reviewed By: spicyj

Differential Revision: D2656448

fb-gh-sync-id: 633433deea00ecb140afbb732bff0599e67b4d41
2015-11-14 13:51:25 -08:00
David Aurelio 21bae9b294 Unbreak jest tests (and travis e2e tests)
Reviewed By: mkonicek

Differential Revision: D2652002

fb-gh-sync-id: 8aab8da47dd737acc4ee9acddc484bd3bbdf1184
2015-11-14 03:26:24 -08:00
Giampaolo Bellavite 492412f177 Fix typo in console.error
Summary: Closes https://github.com/facebook/react-native/pull/4116

Reviewed By: svcscm

Differential Revision: D2652595

Pulled By: cpojer

fb-gh-sync-id: a46a19dcbb119b4e14df2e4418787ea232c32606
2015-11-13 11:02:42 -08:00
Tadeu Zagallo ce2bb0fe16 Update oss transformer
Summary: public

The inline-requires transform (from `fbjs-scripts`) is only used for oss tests, and wasn't updated, fix it.

Reviewed By: mkonicek

Differential Revision: D2641711

fb-gh-sync-id: 90a084082b9c55c5bcb776346f4655451a8a61f7
2015-11-12 07:05:07 -08:00
Ben Alpert b90fe8e2e8 Use external babel helpers
Reviewed By: vjeux

Differential Revision: D2643810

fb-gh-sync-id: a415e2449a98b6070c688c1c250eb8a908b40409
2015-11-12 07:04:55 -08:00
Tadeu Zagallo c6a3052c73 Fix launchCommand
Summary: public

Fixes #4055

Babel is failing to find the plugins when running scripts with the full path,
cd into the folder before starting the packager as a workaround.

Reviewed By: vjeux

Differential Revision: D2638529

fb-gh-sync-id: b57151d3091d56a2c070692fb6296184a8fc62de
2015-11-11 04:39:28 -08:00
Tadeu Zagallo b907f40957 Fix breakages when upgrading to babel 6
Reviewed By: vjeux

Differential Revision: D2628092

fb-gh-sync-id: 077a3572fe8b261d390be2bdc32d9d06c2b80a01
2015-11-10 10:56:48 -08:00
Tadeu Zagallo 6eec446106 Use the previously upgraded transforms
Summary: public

Move all the transforms that had been previously upgraded to be the default now.

Reviewed By: vjeux

Differential Revision: D2631308

fb-gh-sync-id: a2120a9850c98ce65784b77598baa123121246ab
2015-11-10 10:55:32 -08:00
Tadeu Zagallo b48964717e Upgrade transformers to be compatible babel 6
Reviewed By: vjeux

Differential Revision: D2626155

fb-gh-sync-id: e919c8fb8bbf139bcd979ee2738c7ec4fc9eba74
2015-11-10 10:55:23 -08:00
Christoph Pojer cbaf58a47d Use `debug` instead of `console.warn`
Reviewed By: voideanvalue

Differential Revision: D2636111

fb-gh-sync-id: d21ec56045461353317348c4da14c92be8015bd3
2015-11-10 02:30:34 -08:00
Christoph Pojer 6f57766d21 Defualts for platforms and assetExts
Reviewed By: voideanvalue

Differential Revision: D2635446

fb-gh-sync-id: 57e628cf5f917c7e2511d0c8bde696310ab0fc7a
2015-11-09 19:48:29 -08:00
Bhuwan Khattar c16574a0b4 Don't special case performanceNow
Summary: The previous version of `performanceNow` used to reassign to a `require(...)` alias, which our inline requires transform guarded against. Before the update to React 0.14, we were pulling `performanceNow` from a hardcoded `react-tools` version (b4e74e38e4/src/shared/vendor/performance/performanceNow.js), so we couldn't just fix the file and had to special case it. Now that we've updated to React 0.14, `performanceNow` is pulled from fbjs and no longer needs to be special cased.

public

Reviewed By: cpojer

Differential Revision: D2634940

fb-gh-sync-id: 7085cde3179c04f9ecfd87bdd472b19e370ee73c
2015-11-09 18:31:29 -08:00
James Ide 9a64f17de8 Source nvm.sh (best effort) when running react-native-xcode.sh
Summary: When Node is installed with nvm, scripts invoked from Xcode need to set up nvm. This can be done either by sourcing .profile/.bash_profile/.bashrc/etc... or by sourcing nvm.sh directly -- this diff does the latter and handles the case where nvm may have been installed the official way (under ~/.nvm/nvm.sh AFAIK) or via homebrew.
Closes https://github.com/facebook/react-native/pull/4015

Reviewed By: svcscm

Differential Revision: D2633301

Pulled By: frantic

fb-gh-sync-id: 3c2b9b0d21887ba21d6f85f5d279314d50c1db28
2015-11-09 16:42:30 -08:00
Christoph Pojer 666706b0da Inline cache mock for DependencyGraph-test
Reviewed By: davidaurelio

Differential Revision: D2629211

fb-gh-sync-id: ade0bf4e486b58ecbc9a29eb3bdb61286eebb3d5
2015-11-09 13:34:55 -08:00
Christoph Pojer 44b051d98d Use a mock for FileWatcher
Reviewed By: davidaurelio

Differential Revision: D2628885

fb-gh-sync-id: f8b96c483eb7deb52a7ca4897801e2d0ef9e4f4c
2015-11-09 13:34:50 -08:00
Christoph Pojer 8c59866b69 Fix lint errors
Reviewed By: davidaurelio

Differential Revision: D2628366

fb-gh-sync-id: 8d849e2deb038842475e66ef641fa1d4f7b78d8f
2015-11-09 13:34:45 -08:00
Christoph Pojer b4fb6c2f61 Remove usage of declareOpts
Reviewed By: martinbigio

Differential Revision: D2619798

fb-gh-sync-id: ddc58233c06899017dbb98b3d8258eb0fe61cda3
2015-11-09 13:34:38 -08:00
Christoph Pojer 34f8a6e56f Move `getPlatformExtension` and `getAssetDataFromName` into `DependencyResolver`
Reviewed By: martinbigio

Differential Revision: D2619690

fb-gh-sync-id: 04ca68a1fa2dc7b77a49c38ea1515d7afbdee603
2015-11-09 13:34:32 -08:00
Christoph Pojer 145a72df80 Don't require Activity inside of DependencyResolver
Reviewed By: martinbigio

Differential Revision: D2619364

fb-gh-sync-id: 7947388c8041e5d6cbc1e20c8eb9fc7325dc46e0
2015-11-09 13:33:29 -08:00
Ben Alpert 2db10e3e72 Fix open source
Summary: Unfortunately ReactTestUtils requires ReactDOM (for renderIntoDocument), and ReactTestUtils is required by ReactNative. This worked internally because we already shimmed ReactDOM for Relay; now we shim it externally too, at least until we figure out a better solution for this in React.

public

Reviewed By: vjeux

Differential Revision: D2629811

fb-gh-sync-id: 94aac2c4eda39d039fdcedd88295e7afb0f5c5b2
2015-11-07 11:41:20 -08:00
Ben Alpert bbee3c6f60 Update core libraries for React 0.14 final
Summary: All minor changes since we were already on the beta: most notable is that destructors are required in pooling to help prevent memory leaks.

public

Reviewed By: sebmarkbage

Differential Revision: D2608692

fb-gh-sync-id: acdad38768f7f48c0f0e7e44cbff6f0db316f4ca
2015-11-06 19:52:34 -08:00
Joe Savona 1ae7a77934 Add polyfills to jest setup scripts
Reviewed By: cpojer

Differential Revision: D2627866

fb-gh-sync-id: 6d2c95ebc1fe05da3a90f8f6df3287bdbac870bd
2015-11-06 17:20:35 -08:00
Joe Savona c4739746ba Polyfill Array.from
Reviewed By: cpojer

Differential Revision: D2627437

fb-gh-sync-id: 6a7c94e13db772d96cbd8ebab37eccb0826963bc
2015-11-06 14:14:28 -08:00
Pieter De Baets d9b4c57e12 Remove log level 'log' from JS
Summary: Log level 'log' from JS should be equivalent to 'info'. Also added knowledge of 'trace' log level in RCTLog.

public

Reviewed By: vjeux

Differential Revision: D2615500

fb-gh-sync-id: 7a02f49bf7953c1a075741c21e984470c44b5551
2015-11-05 12:51:41 -08:00
Frédéric Sagnes f5670f8ab5 Set ASCII as the default bundle encoding
Reviewed By: davidaurelio

Differential Revision: D2596387

fb-gh-sync-id: deadb8e9a44bbe7b12ce9e6bb5e3c96d4f646074
2015-11-05 07:31:55 -08:00
Christoph Pojer 7f93548489 Remove dependency on underscore
Reviewed By: davidaurelio

Differential Revision: D2614853

fb-gh-sync-id: 706fb0db6852f599a1b3dd022dbc22aabb76539a
2015-11-04 19:02:47 -08:00
Christoph Pojer d3599d0a88 Start pulling DependencyResolver apart
Summary: I'm planning to split up `DependencyResolver` into the react-native specific implementation of it and a new, generic resolver that is going to replace `node-haste` for jest and other places where we might need JS dependency resolution.

The plan is to split the two folders up so that:

* `Resolver` is the folder for all the react-native specific resolver code
* `DependencyResolver` will become a standalone library, eventually moving into a package called `node-haste`.

There is still a lot to be figured out. This is just the first diff of likely many. The current goal is to make `DependencyResolver` standalone to be able to create an instance of a resolver and resolve all dependencies for a file. This is when I can start integrating it more seriously with jest.

This diff simply moves a bunch of things around and turns `HasteModuleResolver` into an ES2015 class ( :) ).

bypass-lint
public

Reviewed By: davidaurelio

Differential Revision: D2614151

fb-gh-sync-id: ff4e434c4747d2fb032d34dc19fb85e0b0c553ac
2015-11-04 16:59:30 -08:00
Christoph Pojer 7041a22bd0 Update jest to 0.7.1
Reviewed By: frantic

Differential Revision: D2614935

fb-gh-sync-id: 64cc4fb439f0c53f0eb0588c22e0291813a7e334
2015-11-04 14:42:13 -08:00
Tadeu Zagallo 70c9ee8b1b Convert System.import transform to babel 6
Reviewed By: martinbigio

Differential Revision: D2615286

fb-gh-sync-id: 4f0e8e3359413d972ab4d0da291870768a77e361
2015-11-04 08:53:26 -08:00
Tadeu Zagallo 441995fa6a Log minification time
Summary: public

Add an activity to log minification time.

Reviewed By: vjeux

Differential Revision: D2604863

fb-gh-sync-id: cbdf0297f0611c87b589b87928af235f9ba81172
2015-11-03 01:20:26 -08:00
Bhuwan Khattar 47b124436f require InitializeJavaScriptAppEngine in bundle
Reviewed By: martinbigio

Differential Revision: D2582794

fb-gh-sync-id: d6cfdda81f556ef0cefb2e9dc58f5978b651bd5b
2015-10-28 21:09:24 -07:00
Martín Bigio 44af0d3dec Infer platform from extension
Summary: public
Aparently this used to work on 0.11, lets fix it :)

Reviewed By: foghina

Differential Revision: D2557719

fb-gh-sync-id: dcbca077431c1356c89dfc55b71eecff64c7ad3d
2015-10-27 17:47:28 -07:00
Martín Bigio d23e622426 Improve error logging when rebuild fails
Summary: public

We're seeing intermittent errors on the packager when rebasing. Since this is very hard to repro lets add more logging to the warning we show just before starting to rebuild the entire haste map again

Reviewed By: frantic

Differential Revision: D2585427

fb-gh-sync-id: fbfa953f6c8ae78cbee2f3ab19ad494b084165c8
2015-10-27 10:33:29 -07:00
Martín Bigio bcf762af60 Move files from `packager/` to `local-cli`
Summary: public

This is not only to put the files on a place where it makes more sense but also to allow to use ES6 features on them as `/packager` is not whitelisted on `babel`.

Reviewed By: mkonicek

Differential Revision: D2577267

fb-gh-sync-id: b69a17c0aad349a3eda987e33d1778d97a8e1549
2015-10-26 15:38:14 -07:00
Christoph Pojer 725de1d236 Update to 0.6.1
Summary: This version should be more stable and has the `moduleNameMapper` feature that frantic was asking for - I will send a follow-up diff for that. I also fixed an issue with `module.parent` and a module inside of yeoman that thought it was owning the universe.

See https://github.com/facebook/jest/blob/master/CHANGELOG.md#061 for a changelog since 0.5.6.

public

allow-crlf-text

Reviewed By: javache

Differential Revision: D2579041

fb-gh-sync-id: cb918875557f219239f49fc0ad49ac61d0884173
2015-10-26 15:37:23 -07:00
Martin Bigio 271de0f9b6 Fix webSocketProxy.js
Summary: cc mkonicek ide
Closes https://github.com/facebook/react-native/pull/3638

Reviewed By: svcscm

Differential Revision: D2576536

Pulled By: martinbigio

fb-gh-sync-id: 27f53eedf2bd94f71f4e405d3d4bb193eaabc918
2015-10-23 13:58:31 -07:00
Spencer Elliott c1faabcdf6 Replace applescript with https://github.com/sindresorhus/opn
Summary: This allows opening the Chrome debugger on OS X, Linux, and Windows, and succeeds the previous PR which used [browser-launcher2](https://github.com/benderjs/browser-launcher2) and included a `--dangerouslyDisableChromeDebuggerWebSecurity` option: https://github.com/facebook/react-native/pull/2406

[opn](https://github.com/sindresorhus/opn) is cross-platform and much simpler than browser-launcher2 (since we don't have to manage the opened Chrome instance; the OS will just use the default instance).
Closes https://github.com/facebook/react-native/pull/3394

Reviewed By: mkonicek

Differential Revision: D2550996

Pulled By: frantic

fb-gh-sync-id: fa4cbe55542562f30f77e0a6ab4bc53980ee13aa
2015-10-23 11:32:35 -07:00
Martín Bigio dee96fbedc Update blacklist.js
Summary: Since we rely on a non npm version of `react-tools` which includes docs and other unnecessary files we need to make sure we blacklist some of them as otherwise the packager fails
Closes https://github.com/facebook/react-native/pull/3616

Reviewed By: svcscm

Differential Revision: D2572024

Pulled By: mkonicek

fb-gh-sync-id: 2082cd69e2ccddb275dfdc7db107d4ed6b826bbb
2015-10-22 14:20:26 -07:00
Martín Bigio 32aeeea313 Fix cli entry points
Reviewed By: frantic

Differential Revision: D2565954

fb-gh-sync-id: 6fde9e1dbefd71944e8f857e9a40619bf599ef75
2015-10-22 10:13:13 -07:00
Alex Kotliarskyi be70e32de2 Generate bundle and assets when building via Xcode
Summary: This integrates React Native into Xcode's build process, which lets us automatically handle bundling and packaging image assets.

Tested the script via https://github.com/frantic/ReactNativeAssetsExample

Loaded from packager:
<img width="432" alt="screen shot 2015-10-19 at 3 11 12 pm" src="https://cloud.githubusercontent.com/assets/192222/10593447/be5bc7e8-7678-11e5-8c70-ecc2a1ee24fc.png">

Loaded from offline bundle:
<img width="432" alt="screen shot 2015-10-19 at 3 10 58 pm" src="https://cloud.githubusercontent.com/assets/192222/10593448/be5d5194-7678-11e5-8b02-d492a26cfb81.png">

Android:
<img width="639" alt="screen shot 2015-10-19 at 3 11 20 pm" src="https://cloud.githubusercontent.com/assets/192222/10593449/be5de2d0-7678-11e5-8d3c-0378fc447f15.png">
Closes https://github.com/facebook/react-native/pull/3523

Reviewed By: mkonicek

Differential Revision: D2557923

Pulled By: frantic

fb-gh-sync-id: 19957e255993696e793b0162662772efd89f5c1a
2015-10-21 18:44:27 -07:00
Bhuwan Khattar 3a8f9e1080 split transformers
Reviewed By: martinbigio

Differential Revision: D2567545

fb-gh-sync-id: 2e6a341885c701c6a7da35830227dbff7705255c
2015-10-21 16:28:27 -07:00