Browse files

[react-native] Replace jstransform with Babel in the OSS repo

Replaces jstransform with Babel. Additionally, stops (using the deprecated) passing an error property
back from the transformer, and instead passes an error in the first argument. This is because we were
able to update node-worker-farm to handle custom properties on errors.

Test Plan:
1. Export the oss project
2. npm install
3. Start the movies app
4. Make sure it works
5. Add a syntax error
6. Make sure the message is correct
  • Loading branch information...
amasad committed May 22, 2015
1 parent 5bad316 commit 56d6ee3f0fadeb66aeb6cf9156c723759f48f617
Showing with 30 additions and 40 deletions.
  1. +30 −40 packager/transformer.js
@@ -10,40 +10,37 @@
'use strict';
var jstransform = require('jstransform').transform;
var babel = require('babel');
var reactVisitors =
var staticTypeSyntax =
var trailingCommaVisitors =
// Note that reactVisitors now handles ES6 classes, rest parameters, arrow
// functions, template strings, and object short notation.
var visitorList = reactVisitors.concat(trailingCommaVisitors);
function transform(srcTxt, filename) {
var options = {
es3: true,
sourceType: 'nonStrictModule',
function transform(srcTxt, filename, options) {
var result = babel.transform(srcTxt, {
retainLines: true,
compact: true,
comments: false,
filename: filename,
whitelist: [
sourceFileName: filename,
sourceMaps: false,
extra: options || {},
return {
code: result.code,
// These tranforms mostly just erase type annotations and static typing
// related statements, but they were conflicting with other tranforms.
// Running them first solves that problem
var staticTypeSyntaxResult = jstransform(
return jstransform(
module.exports = function(data, callback) {
@@ -54,15 +51,8 @@ module.exports = function(data, callback) {
} catch (e) {
return callback(null, {
error: {
lineNumber: e.lineNumber,
column: e.column,
message: e.message,
stack: e.stack,
description: e.description
callback(null, result);

1 comment on commit 56d6ee3


This comment has been minimized.

Show comment
Hide comment

nmn May 30, 2015

flow remains useless with most of ES6 and ES7, so don't use any new features if you want to typecheck.

nmn commented on 56d6ee3 May 30, 2015

flow remains useless with most of ES6 and ES7, so don't use any new features if you want to typecheck.

Please sign in to comment.