Commit Graph

241 Commits

Author SHA1 Message Date
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
David Aurelio 523769faa7 Add `--verbose` flag to react native packager cli
Reviewed By: martinbigio

Differential Revision: D2517347

fb-gh-sync-id: 02e64f99120b6636d6e7649deb11d0b2f58d9285
2015-10-20 11:52:25 -07:00
David Aurelio fb46e39cad Make the modification time of the transformer file relevant for the cache.
Reviewed By: amasad

Differential Revision: D2554956

fb-gh-sync-id: cc76f083594aac04c74a4ef271305238b06710eb
2015-10-20 09:46:23 -07:00
Bhuwan Khattar 256f69f4e6 fix HasteDependencyResolver
Reviewed By: javache

Differential Revision: D2550444

fb-gh-sync-id: f978efdd73c09e58bcdbc4711ee2a7662a0b1bf3
2015-10-16 11:16:25 -07:00
Adam Miskiewicz 24bfdda499 Adds support for ES6 export syntax to the packager's DependencyResolver.
Summary: This PR includes:
- A regex that allows for the `export` syntax.
- Updated tests.
Closes https://github.com/facebook/react-native/pull/3465

Reviewed By: svcscm

Differential Revision: D2550322

Pulled By: vjeux

fb-gh-sync-id: 7d35f436af13cf5b6b1287835a18a9693ec1be8a
2015-10-16 10:57:32 -07:00
Bhuwan Khattar 15054ade7d Support cyclic dependencies in require polyfill
Reviewed By: @martinbigio

Differential Revision: D2548506

fb-gh-sync-id: fca534179a5f8fcf407917137cdd71d964f145e5
2015-10-16 03:41:08 -07:00
Bhuwan Khattar 83b8a30beb Simplify require polyfill
Reviewed By: @vjeux

Differential Revision: D2544415

fb-gh-sync-id: ab48b5fba169c43c68dd24dc95ea1d0322ed67c4
2015-10-16 03:40:58 -07:00
Martín Bigio 793c3564ff Fail loud when module is not resolved correctly
Summary: @​public
We've been forgiving unresolved modules errors in the past but we've realized that doing so makes the codebase a bit unstable as people don't make sure to fix these errors. From now on we'll early fail and stop the packager when any module cannot be resolved (including assets)

Reviewed By: @amasad

Differential Revision: D2518076

fb-gh-sync-id: e170d95b905cc29afbe46e24b65425ddd887f77c
2015-10-13 11:48:23 -07:00
Nick Lockwood 5b425278bb Removed references to isStatic from the codebase
Summary: @​public

The legacy 'isStatic' property for image sources is no longer used anywhere in our codebase, but was still being generated by the packager and referenced in the JS in various places.

This diff removes all the remaining references.

Reviewed By: @frantic

Differential Revision: D2531263

fb-gh-sync-id: 0bba0bb8473b1baa908ef7507cbf6d83efb0d9ee
2015-10-13 06:44:30 -07:00
Martín Bigio 5196ad102d fix E2E tests
Reviewed By: @mkonicek

Differential Revision: D2526310

fb-gh-sync-id: 1c04f56073dc5b393a36b258c039fdfd85ab83a2
2015-10-09 07:59:02 -07:00
Martín Bigio 32b62ef055 Unbreak packager on oss master
Summary: @​public
This was a hard one, bare with me on the full story of what happened.

We recently started writting additional JS scripts in ES6 for the cli. These code needs to be transformed by babel before we execute it as we don't run node with `--harmony`. To do so we removed the `only` attribute on the `babel-register`. Turns out this broke the packager on oss as if no `only` not `ignore` parameter is specified babel will ignore `node_modules`. Since on oss when a project is created `react-native-github` is located inside of `node_modules` we started getting syntax errors.

The fix is to include separately all the different paths we need to make sure babel transforms each of them. We cannot simply have a single `babel-core/register` as we need to include paths that belong both to oss and internal only. So, we need to have multiple `register` invocations. Since babel does not accumulate the `only` you send on every invocation we need to build a small wrapper to do so.

Reviewed By: @frantic

Differential Revision: D2522426

fb-gh-sync-id: 379a7bb169c7d5cb3002268742de269238bba766
2015-10-08 17:37:27 -07:00
Tadeu Zagallo ad622f20f2 Fix wrong source map test
Reviewed By: @javache
2015-10-05 11:15:20 -07:00
Martín Bigio 7ad418a396 Move fbobjc bundle command to cli
Reviewed By: @frantic

Differential Revision: D2457072
2015-10-05 09:21:27 -07:00
Tadeu Zagallo 753cc7683c Fix minified source maps
Summary: @​public

The source maps generated by uglify are already stringified, and therefore were
being stringified twice.

Reviewed By: @martinbigio

Differential Revision: D2498242
2015-10-05 08:48:25 -07:00
Amjad Masad 8356b609a5 Use different cache keys for Package objects (fixes #2949)
Summary: @​public

Dead-lock trying to read package.json because it's both a "module" and a "package". in `Module.getName` it uses the cache key "name" and tries to call `Package.getName` which uses the same cache key and we end up returning the same promise that we're trying to resolve resulting in a dead-lock.

This changes the cache keys for the packages that adds a prefix "package-".

Reviewed By: @vjeux

Differential Revision: D2506979
2015-10-04 12:37:25 -07:00
shlomiatar 535ee40818 Fix DependencyResolver to support ES6 multiline imports
Summary: *This is a PR to fix #1939 (DependencyResolver fails to handle ES6 modules import statements with new lines)*

**This PR includes:**
- A fix to the problematic regular expression
- Updated tests that support the new line style.

**Summary:**
We found out that while the packager does its module wrapping thing for lines like this:
```js
import theDefault, { named1, named2 } from 'src/mylib';
```
It fails to do the same for multi line imports:
```js
import theDefault, {
  named1,
  named2
} from 'src/mylib';
```
We've tracked done the issue to a [faulty regular expression in replacePatterns.js](https://github.com/facebook/react-native/blob/master/packager/react-packager/src/DependencyResolver/replacePatterns.js#L12)

You can see various import statements with the problematic regular expression [here](http://regexr.com/3bc8m)

We've figure out a better regular expression (you can play around with it [here](http://regexr.com/3bd3s))Closes https://github.com/facebook/react-native/pull/1940

Reviewed By: @​svcscm

Differential Revision: D2498519

Pulled By: @vjeux
2015-10-01 12:17:21 -07:00
Kyle Corbitt 9c4b476679 enable es6 module syntax
Summary: This is an updated copy of #1993, which was approved by @vjeux but hasn't been rebased. It whitelists the es6 module syntax and updates the JS Environment docs to match. cc @ide @​hkjorgensenCloses https://github.com/facebook/react-native/pull/3175

Reviewed By: @​svcscm

Differential Revision: D2498360

Pulled By: @vjeux
2015-10-01 10:57:23 -07:00
Amjad Masad 502d277ff2 Error on name collisions
Summary: @​public
This moves us from warnings on name collisions to errors. If the error happens in initialization it will fatal out.

However, if the error happens while working (after initialization) then I did my best to make it recoverable. The rational behind this is that if you're working and you're changing names, you may introduce a duplication while moving things around. It will suck if you have to restart the server every time you do that.

Reviewed By: @frantic

Differential Revision: D2493098
2015-09-30 21:02:50 -07:00
Amjad Masad 9211b9b3cf Introduce `getOrderedDependencyPaths` that gets all concrete dependecy paths
Summary: @​public
Since we added packager-managed assets -- internally we still think of asset dependency as a single "module". In reality there are multiple files that represent this module. This becomes important with the `getDependencies` API which is used by Buck to inform it on what to rebuild. Since `getDependencies` deals with modules, and is more of an internal API, I've introduced a new one and would go on to deprecate this.

Reviewed By: @frantic

Differential Revision: D2487207
2015-09-29 18:34:21 -07:00
Amjad Masad 42b5cd59e4 Fix debug namespaces
Summary: @​public
Have a top-level debug namespace: `ReactNativePackager`
And add a couple of debugs in the transformer. This is ground work for adding a verbose option.

Reviewed By: @DmitrySoshnikov

Differential Revision: D2489960
2015-09-29 16:10:22 -07:00
Amjad Masad 256fa18ab2 remove randomness
Reviewed By: @javache

Differential Revision: D2490001
2015-09-29 12:44:22 -07:00
Amjad Masad ca007aabb4 Pass in the platform options when loading dependencies
Reviewed By: @jingc

Differential Revision: D2488262
2015-09-29 09:22:00 -07:00
Pieter De Baets e885628245 Don't call originalConsole methods when they don't exist
Reviewed By: @vjeux

Differential Revision: D2485562
2015-09-29 09:21:48 -07:00
yiminghe 4978855d72 support es6.constants by default. Fixes #2932
Summary: In javascriptcore(ios9), this code will run as expected(output 0 1):

```js
for(let i=0; i<2; i++) {
  const data = i;
  console.log(data);
}
```

But when debug in chrome, the above code will fail without `use strict` prologue (if you add prologue, rn will fail with red screen `Const declarations are not supported in strict mode`): https://code.google.com/p/v8/issues/detail?id=4432.

So it's better to transpile contant by default.

Closes https://github.com/facebook/react-native/pull/2955

Reviewed By: @​svcscm

Differential Revision: D2483398

Pulled By: @vjeux
2015-09-26 15:50:24 -07:00
Amjad Masad fa0da5682b Fix haste resolution (and better warnings)
Summary: @​public

Fix the haste resolution algorithm. Changed the map data structure from a list of modules, to a list of modules grouped by platform.
This considerably simplifies the "getModule" method and makes it easy to properly warn about colliding module names.
This also fixes a bug where we used to include `.web` files when we shouldn't (see task).

Reviewed By: @vjeux

Differential Revision: D2482969
2015-09-25 20:35:45 -07:00
Justin Spahr-Summers 1487ebfe01 Revert packager randomization revert 2015-09-25 10:24:06 -07:00
Justin Spahr-Summers e2fdd59784 Revert packager module randomization 2015-09-25 07:41:25 -07:00
Amjad Masad 9293e54085 Warn and randomize colliding name selection
Summary: @​public

The issue of colliding haste modules have came up many times and have wasted countless engineering hours. This will start warning about it and will also start selecting modules at random so that people don't depend on undefined behavior.

Additionally, this surfaced an issue where with assets we may fatally throw if the directory doesn't exist. This is fixed by checking the existence of the directory before trying to match files in it.

Reviewed By: @jingc

Differential Revision: D2478480
2015-09-25 00:19:27 -07:00
Martin Bigio bf88e46ebb Print to console instead of debug uncaught exceptions
Reviewed By: @jingc

Differential Revision: D2478099
2015-09-24 15:57:26 -07:00
Martin Bigio eee11eaeed Log server state when client is unexpetedly closed
Reviewed By: @javache

Differential Revision: D2473036
2015-09-24 08:20:20 -07:00
Jan Kassens 974ec059e8 Fix for displayName transform
Summary: The `react.displayName` transform was added in 93b9329b75.

That diff missed to update the `.babelrc` where the comment says it should stay
in sync (I'm not sure where it's used though). I added a comment in the other
direction so this can be prevented in the future.

I also updated the `cacheVersion` so we actually transform the code again to add
the missing displayName properties to unchanged components.
Closes https://github.com/facebook/react-native/pull/2905

Reviewed By: @vjeux

Differential Revision: D2473447

Pulled By: @kassens
2015-09-24 08:20:02 -07:00
Charlie Cheever dc7681e946 Also call the original `console` methods if they exist
Summary: Ex. When `console.log` or similar is called, this will call
the original method, which can be quite useful.

For example, under iOS, this will log to the Safari console debugger,
which has an expandable UI for inspecting objects, etc., and is also
just useful if you are using that as a REPL.

I don't believe this incurs a meaningful performance penalty unless
the console is open, but it would be easy to stick behind a flag
if that is a problem.
Closes https://github.com/facebook/react-native/pull/2486

Reviewed By: @​svcscm

Differential Revision: D2472470

Pulled By: @vjeux
2015-09-23 19:29:24 -07:00
Martin Bigio 407247fe1e Don't swallow client errors
Reviewed By: @​swarr

Differential Revision: D2472285
2015-09-23 12:43:23 -07:00
Amjad Masad 45ed000d4b Remove server error listener so that it throws
Summary: @​public
We swallow errors like it's nobody's business :(
Having an error handler that `reject`s after the promise has been resolved is a no-op. In node, if there is no `error` event handler then the error would throw.

So after we start listening and we want to resolve the promise, we remove the error listener so that we make sure errors actually throw.

Finally, I made the `uncaughtError` handler log `error.stack` so we can get an idea of what's going on.

Reviewed By: @martinbigio

Differential Revision: D2468472
2015-09-22 15:48:29 -07:00
Amjad Masad 30cca276fa Return concrete file paths to the client
Reviewed By: @martinbigio

Differential Revision: D2465182
2015-09-22 15:45:25 -07:00
Martín Bigio c4cb95f2d7 Add logging information when client's socket gets closed unexpetedly
Reviewed By: @amasad

Differential Revision: D2468293
2015-09-22 15:21:35 -07:00
Amjad Masad f39e3fe113 Simplify over-engineered Activity module
Summary: @​public
I've noticed that the logs can be sometimes misleading, as when an Activity ends it doesn't log immediatly. A sync `console.log` would log before it although the Acitivity should've finished before.

Turns out we wait before writing out the logs to the console. I don't see any reason for this. Looking at the `Activity` module it's over-engineered. This diff makes logging sync and simplfies the module.

Reviewed By: @martinbigio

Differential Revision: D2467922
2015-09-22 14:25:37 -07:00
Amjad Masad 7806c0875b Log exit code
Reviewed By: @martinbigio

Differential Revision: D2467457
2015-09-22 12:40:25 -07:00
Christoph Pojer d088750163 Fix tests + enable inline requires on react-native
Reviewed By: @sahrens, @vjeux

Differential Revision: D2456607
2015-09-21 14:39:44 -07:00
Martin Bigio 8f5b2ccbe0 Log uncaught exceptions on the socket server
Reviewed By: @frantic

Differential Revision: D2462114
2015-09-21 12:08:29 -07:00
Pieter De Baets d94ed42e1c Enable Jest tests
Reviewed By: @amasad

Differential Revision: D2422290
2015-09-20 16:48:35 -07:00
Christoph Pojer fa01b2e4cb Codemod tests to use top-level-requires
Reviewed By: @DmitrySoshnikov

Differential Revision: D2456250
2015-09-19 15:41:29 -07:00
DengYun 450cd5c406 Generate module name seperated by '/' on Windows.
Summary: I think packager on different platform should generate same output if possible. So packager should replace '\\' in module name with '/' on Windows.

Closes https://github.com/facebook/react-native/pull/2813

Reviewed By: @​svcscm

Differential Revision: D2458634

Pulled By: @martinbigio
2015-09-18 15:15:28 -07:00
mqli f5409c1a51 Fixing the packager infinite loop on Windows
Summary: The issue here https://github.com/facebook/react-native/issues/2787

The root path '/' dosn't match windows root path
Closes https://github.com/facebook/react-native/pull/2789

Reviewed By: @​svcscm

Differential Revision: D2452718

Pulled By: @martinbigio
2015-09-18 06:05:22 -07:00
facebook-github-bot-6 0d09f22dbf Get back 100% in sync with fb codebase 2015-09-16 10:30:53 -07:00
Martín Bigio 41850a962f defeat race condition when replying to client
Summary: @​public

The server dies after 30 seconds if it has no jobs on it's queue. The problem is that the jobs counter gets decreased before returning the bytes to the client. As a consequence, it's possible that the server dies while it's returning the bytes to the client, or just after it finished returning the bytes to the client.

To avoid both issues lets move the counter decrease a few lines below and bump the timer to make sure we have time to fully write the bytes on the socket and let the client close the connection before the server dies.

Reviewed By: @vjeux

Differential Revision: D2445264
2015-09-15 16:25:25 -07:00
Amjad Masad 1bf7887322 Refactor DependencyResolver into request/response
Reviewed By: @martinbigio

Differential Revision: D2425842
2015-09-11 17:01:35 -07:00
Christopher Chedeau e9e3cd304b Revert internal files that didn't get pulled internally first
See all the packager files in this commit:
f83675d191 (diff-7b5603771e245e5b0cd7223277db3db4)

cc @foghina
2015-09-11 16:59:28 -07:00
Amjad Masad d5bce33f69 Fix server tests
Summary: @​public
Invoking an extra promise caused failures in the promise-based tests. This fixes them.

Reviewed By: @vjeux

Differential Revision: D2432431
2015-09-11 13:30:33 -07:00
Amjad Masad 9b27116798 Client should throw when server unexpectedly closes the connection
Reviewed By: @natthu

Differential Revision: D2425357
2015-09-09 16:35:25 -07:00