Commit Graph

24 Commits

Author SHA1 Message Date
David Aurelio bc22a4da7e Make preset a function to account for different dev settings
Summary: Makes `babel-preset-react-native` a factory function that allows to include/exclude dev tool transforms per transform.

Reviewed By: jeanlauliac

Differential Revision: D5237158

fbshipit-source-id: aa7be0fc0f471575b4ee1c5a0e266e2ed2477fc6
2017-06-14 09:32:37 -07:00
David Aurelio 5c57601769 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:32:37 -07:00
Dan Abramov 7210a060e6 Enable JSX source plugin in DEV and integrate it with React DevTools
Summary:
The `env` option has been broken in Babel for a while (https://github.com/babel/babel/issues/4539), and will be deprecated (https://github.com/babel/babel/issues/5276).

I am changing this code to the way Babel < 6.10 interpreted the `env` option. This should fix the `__source` JSX transform which was applied in DEV in the past, but stopped getting applied because of the Babel bug.

I also changed the `filename` passed by Babel to be relative (currently, to `fbsource` but open to other options). This way DEV builds are still reproducible.

This still needs some help from davidaurelio to make the root location more foolproof. I'd also appreciate zertosh taking a look in case there's a better way to "anchor" the relative path. All I need is to for `react-third-party/react-devtools/react-devtools` and `babelTransformer.js` to agree on what the relative path base is.

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

Reviewed By: gaearon

Differential Revision: D5035892

Pulled By: davidaurelio

fbshipit-source-id: 19ffeb867d7ed5928e9de05dcec9ba85bf961dd5
2017-05-12 08:50:11 -07:00
Nicholas Young 2121527cb8 Update babel-preset, filter path by identifiers.
Summary:
This PR contains [the fix](https://github.com/facebook/react-native/issues/6063#issuecomment-189416771) from #6063, which resolves the issue with rxjs 5. Is there a reason to not include these proposed changes in the repo?
Closes https://github.com/facebook/react-native/pull/10815

Differential Revision: D4226835

fbshipit-source-id: bfaeaebbe308c45bce814469ef0f75283f050d18
2016-11-23 09:28:27 -08:00
Robert Rose 98dd91825f Fixing Issue #7526
Summary:
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:

Fixing a bug detailed in Issue #7526 where Android app was crashing when using a binary number.

**Test plan:**
- Build & Run UIExplorer
- Build & Run UIExplorer with `const binaryNumber = 0b101010` inserted into UIExplorerApp.android.js
- Use `react-native init` to create a new blank project, then replace files in node_modules and insert `const binaryNumber = 0b101010` into index.android.js.
Closes https://github.com/facebook/react-native/pull/7730

Reviewed By: avaly

Differential Revision: D3353119

Pulled By: bestander

fbshipit-source-id: 098442da32a29c369f5932b7a4004e8d7f4cb91f
2016-05-26 13:43:29 -07:00
Alex Kotliarskyi 858643dbdf Add transform-react-jsx-source to react-native preset
Summary:
Putting this up as request for comments.

The PR adds [transform-react-jsx-source](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-jsx-source) to the list of plugins that come by default with the `react-native` preset. It will enable the use of a bunch of really cool tooling around JSX, however those are generally useful only in development mode. Is changing `react-native` preset the right thing to do in this case? Is there a way to enable this transform only in DEV? Should I add this somewhere else?
Closes https://github.com/facebook/react-native/pull/6351

Differential Revision: D3302906

Pulled By: frantic

fbshipit-source-id: 012d3a4142168f9f90d30d1686115d4dc3996eb9
2016-05-18 12:43:24 -07:00
Kelvin Sherlock 46ba1532fd babel-preset - transform-es2015-constants was replaced by check-es2015-constants.
Summary:
The babel plugin transform-es2015-constants was replaced by check-es2015-constants.

References:

T2970
rBW0a3b3b03dbcfc8d1e809a0eaf6270eec8de80763
T3053

This patch updates the babel preset to use check-es2015-constants which should be more future-proof and will receive bug fixes.
Closes https://github.com/facebook/react-native/pull/6943

Reviewed By: davidaurelio

Differential Revision: D3189222

Pulled By: bestander

fb-gh-sync-id: a5ec23e297e1d3591d51641dd567049f4310b107
fbshipit-source-id: a5ec23e297e1d3591d51641dd567049f4310b107
2016-05-03 06:43:27 -07:00
Konstantin Raev a2ee5bd307 Fixed HMR for React Native Android
Summary:Needs to be published to npm and version be updated in RN
Closes https://github.com/facebook/react-native/pull/7208

Differential Revision: D3218870

Pulled By: davidaurelio

fb-gh-sync-id: 1caac6eb79be16f2e3ed230f413835341c7291dc
fbshipit-source-id: 1caac6eb79be16f2e3ed230f413835341c7291dc
2016-04-25 06:31:25 -07:00
Janic Duplessis 51310b0669 Bump babel-preset-react-native version
Summary:To include a missing part of the fix to HMR on Windows that was done in 0.25rc. See c61100d0ce. Will need to also publish to npm.

cc ide grabbou
Closes https://github.com/facebook/react-native/pull/7076

Differential Revision: D3199977

fb-gh-sync-id: b97da3c91d3723eaa40f63550e053d224689d517
fbshipit-source-id: b97da3c91d3723eaa40f63550e053d224689d517
2016-04-20 18:14:21 -07:00
Daniel Friesen 855c0cc25e Add transform-es2015-function-name to the react-native babel preset. Fixes #6716
Summary:Stateless function components (at least those using arrow functions) are not assigned names when this transform is omitted.

Rebased against master and kept the original author from #6717

cc martinbigio bestander
Closes https://github.com/facebook/react-native/pull/6794

Differential Revision: D3133791

Pulled By: mkonicek

fb-gh-sync-id: bb7790ad17d1520da5ab95580548d29d0c0f397d
fbshipit-source-id: bb7790ad17d1520da5ab95580548d29d0c0f397d
2016-04-13 07:41:26 -07:00
Janic Duplessis c61100d0ce Fix HMR on Windows
Summary:Tested HMR on Windows and found 2 small issues related to paths that made it not work. Now it works nicely :)

**Test plan (required)**
Tested HMR in UIExplorer on Windows.
Closes https://github.com/facebook/react-native/pull/6678

Differential Revision: D3138379

fb-gh-sync-id: f27cd2fa21f95954685c8c6916d820f41bc187be
fbshipit-source-id: f27cd2fa21f95954685c8c6916d820f41bc187be
2016-04-05 01:13:18 -07:00
Martin Bigio 4133de04d7 Use full path for react-native on HMR config
Summary:Fixes https://github.com/facebook/react-native/issues/6731
Closes https://github.com/facebook/react-native/pull/6748

Differential Revision: D3126410

Pulled By: martinbigio

fb-gh-sync-id: fc462ec82e72914d13341a4543212c017bd3838c
fbshipit-source-id: fc462ec82e72914d13341a4543212c017bd3838c
2016-04-01 08:08:27 -07:00
Mart?n Bigio 3bf19070c0 Bump preset
Reviewed By: bestander

Differential Revision: D3113371

fb-gh-sync-id: 96c8cbad2439a53259b47e6be11654148384aabc
fbshipit-source-id: 96c8cbad2439a53259b47e6be11654148384aabc
2016-03-30 07:36:23 -07:00
Janic Duplessis bc54a45542 Revert strict mode in transform-es2015-modules-commonjs
Summary:See discussion here https://github.com/facebook/react-native/pull/5796#issuecomment-202002658

**Test plan (required)**
Change the babel-preset-react-native dependency to `"babel-preset-react-native": "file:./babel-preset",` so it uses the local babel-preset instead of the one from npm.
```
./packager/packager.sh --reset-cache
```
open `http://localhost:8081/Examples/UIExplorer/UIExplorerApp.android.bundle?platform=android&dev=true&hot=false&minify=false` and there should not be any added 'strict mode'.
Closes https://github.com/facebook/react-native/pull/6686

Reviewed By: mkonicek

Differential Revision: D3103122

Pulled By: bestander

fb-gh-sync-id: 85658ee01bb73f13dacb2b6a48ab121324c13118
fbshipit-source-id: 85658ee01bb73f13dacb2b6a48ab121324c13118
2016-03-29 07:26:22 -07:00
Martin Bigio 51b5423fd5 Use `react-native` instead of `React` on hmr config
Summary:Check https://github.com/facebook/react-native/issues/6640 for details
Closes https://github.com/facebook/react-native/pull/6696

Differential Revision: D3109128

fb-gh-sync-id: b80ff44f0dbc063870dc1dc7de9bf3c814ac9a12
fbshipit-source-id: b80ff44f0dbc063870dc1dc7de9bf3c814ac9a12
2016-03-29 06:35:21 -07:00
Martín Bigio e53a6a2931 Bump preset version
Reviewed By: davidaurelio

Differential Revision: D3081487

fb-gh-sync-id: aa3f16f3ac16185fe8c3590ecd34e9d6738e7e0f
shipit-source-id: aa3f16f3ac16185fe8c3590ecd34e9d6738e7e0f
2016-03-22 07:46:23 -07:00
Martín Bigio 3a1634ec7b Fix HMR preset config path
Reviewed By: davidaurelio

Differential Revision: D3077935

fb-gh-sync-id: b1e89f9e34a505f0611cf8991afe4224d5a6f05d
shipit-source-id: b1e89f9e34a505f0611cf8991afe4224d5a6f05d
2016-03-21 15:45:27 -07:00
Janic Duplessis 36893ecfa0 Enable strict mode for transform-es2015-modules-commonjs
Summary:Since #5422 react-native works with strict mode modules but the transform was not updated since Facebook has some non strict mode compatible internal modules. Now that #5214 has landed and it is easy to change the babel config I think we should enable it by default to make es2015 modules spec compliant.

Someone at Facebook will have to make the internal changes necessary to disable strict mode modules for their projects that use non strict mode compatible modules by including a .babelrc file with
``` json
{
  "presets": [
    "react-native"
  ],
  "plugins": [
    ["transform-es2015-modules-commonjs", { "strict": false, "allowTopLevelThis": true }]
  ]
}
```
before merging this.

We might also want to mention this in the breaking change section for the next release.
Closes https://github.com/facebook/react-native/pull/5796

Differential Revision: D3075802

fb-gh-sync-id: e807b67401107e1e944db38453e254025ce0a6c7
shipit-source-id: e807b67401107e1e944db38453e254025ce0a6c7
2016-03-21 06:24:31 -07:00
Dan Abramov 2e9c888dcd Update hot reloading dependencies
Summary:These updates include important changes to correctness in the linked and underlying packages:

* https://github.com/gaearon/babel-plugin-react-transform/releases/tag/v2.0.1
* https://github.com/gaearon/babel-plugin-react-transform/releases/tag/v2.0.2
* https://github.com/gaearon/react-proxy/releases/tag/v1.1.3
* https://github.com/gaearon/react-proxy/releases/tag/v1.1.4
* etc

We need to include these if we want to ship hot reloading.

Create a new project with those versions of packages.

<img width="761" alt="screen shot 2016-03-06 at 18 49 20" src="https://cloud.githubusercontent.com/assets/810438/13556222/2d45ca62-e3cc-11e5-8a3f-a2346efe19dd.png">

Verify hot reloading still works.

![](http://cl.ly/2J150y0Y3E1z/download/Screen%20Recording%202016-03-06%20at%2018.48.gif)

martinbigio skevy

I wasn’t sure whether to touch the shrinkwrap.
Closes https://github.com/facebook/react-native/pull/6325

Reviewed By: yungsters

Differential Revision: D3019470

Pulled By: martinbigio

fb-gh-sync-id: 99bad390cd898f58aa7f74494066561a81eb40e6
shipit-source-id: 99bad390cd898f58aa7f74494066561a81eb40e6
2016-03-11 16:28:21 -08:00
Adam Miskiewicz f5edabf3db Update Babel/React Dependencies
Summary:PR does as it says -- updates Babel dependencies to latest versions.

In general, this changes nothing for 99.9% of users (everyone that isn't FB). If they were to `npm install react-native` right now, they would get all of these dependencies anyway.

However, this does revert a previous change where we were using "~" instead of "^" in front of the Babel deps in order to attempt to lock them to minor dependencies. However, due to the fact that each Babel package uses "^", and there are so many interdependencies, this actually would cause an issue where multiple versions of babel-core, et. al. to be installed.

*Edit* - In addition, we add React to `devDependencies` so that it behaves properly in testing, now that it's a peer dependency.
Closes https://github.com/facebook/react-native/pull/5811

Reviewed By: davidaurelio

Differential Revision: D2931184

Pulled By: martinbigio

fb-gh-sync-id: 7b9fc640d37fb2d98fc1808860f9f64074aff475
shipit-source-id: 7b9fc640d37fb2d98fc1808860f9f64074aff475
2016-03-03 21:19:23 -08:00
David Aurelio a72c2950d6 babel-preset-react-native: Make sure that `react-transform-hmr/lib/index.js` is included correctly for every module in the bundle
Summary:This imports `react-transform-hmr/lib/index.js` with a relative path from every module, to make sure we don’t rely on the current (broken) behaviour.

It works now, because:
- the dependency is added by a transform
- we extract dependencies before transforming
- we include `react-transform-hmr/lib/index.js` manually
- packager incorrectly names modules by the name of their package (i.e. packages with multiple versions overwrite each other)

This blocks transforming before extracting dependencies, switching to numeric module IDs, and unbundling/random access bundles.

Reviewed By: bestander

Differential Revision: D2994024

fb-gh-sync-id: 23c56397b768775ff56e3d6924f50a9e39e8ce8c
shipit-source-id: 23c56397b768775ff56e3d6924f50a9e39e8ce8c
2016-03-01 03:22:32 -08:00
Adam Miskiewicz 194092e729 Adding 'transform-symbol-member' transform to preset.
Summary:
Turns out, even after discussion that was had in https://github.com/facebook/react-native/pull/5294#issuecomment-174397103, we really do need this transform.

I've just included it in the preset...let me know if you all would rather publish to npm.

The actual reason why this is necessary is because in the latest sync from FB, fbjs was updated to use the `Symbol.iterator` express in it's isEmpty function: 064a484e18

We use this in RN in the ListView...and this change (once #5084 is merged) will cause ListView to break on older JSC context's.

This resolves that, and is probably something we should have had all along.
Closes https://github.com/facebook/react-native/pull/5824

Reviewed By: svcscm

Differential Revision: D2913315

Pulled By: vjeux

fb-gh-sync-id: abaf484a9431b3111e8118d01db8d2c0d2dd73ca
shipit-source-id: abaf484a9431b3111e8118d01db8d2c0d2dd73ca
2016-02-08 15:01:36 -08:00
Martín Bigio 0fa54d5a22 Bump preset to 1.2.4
Reviewed By: javache

Differential Revision: D2896094

fb-gh-sync-id: 6423ccb7f258bd166a0b04e0a3f41963dc0f8c8c
2016-02-03 11:09:36 -08:00
Adam Miskiewicz e6cb02d61a Use "babel-preset-react-native"
Summary:
Rather than specifying Babel plugins in the `.babelrc` packaged with react-native, leverage a Babel preset to define the plugins (https://github.com/exponentjs/babel-preset-react-native).

This allows for a much better user experience for those who want (or need) to override options in their project's `.babelrc`.

Prior to this PR, if a user wanted to use a custom babel-plugin (or a custom set of babel plugins), they'd have either 1) manually override the `.babelrc` in the react-packager directory (or fork RN), or 2) specify a custom transformer to use when running the packager that loaded their own `.babelrc`. Note - the custom transformer was necessary because without it, RN's `.babelrc` options would supersede the options defined in the project's `.babelrc`...potentially causing issues with plugin ordering.

This PR makes the transformer check for the existence of a project-level `.babelrc`, and if it it's there, it _doesn't_ use the react-native `.babelrc`. This prevents any oddities with Babel plug
Closes https://github.com/facebook/react-native/pull/5214

Reviewed By: davidaurelio

Differential Revision: D2881814

Pulled By: martinbigio

fb-gh-sync-id: 4168144b7a365fae62bbeed094d8a03a48b4798c
2016-02-03 08:15:32 -08:00