Skip to content

Commit

Permalink
Add more useful ES6 transforms to jsx-internal.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer committed Dec 5, 2013
1 parent 66f6cba commit 31359e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bin/jsx-internal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// -*- mode: js -*-
"use strict";

var visitors = require('../vendor/fbtransform/visitors').transformVisitors;
var getVisitorsList = require('../vendor/fbtransform/visitors').getVisitorsList;
var transform = require('jstransform').transform;
var propagate = require("../vendor/constants").propagate;

Expand Down Expand Up @@ -31,7 +31,7 @@ require("commoner").version(
var constants = context.config.constants || {};

// This is where JSX, ES6, etc. desugaring happens.
source = transform(visitors.react, source).code;
source = transform(getVisitorsList(), source).code;

// Constant propagation means removing any obviously dead code after
// replacing constant expressions with literal (boolean) values.
Expand Down
16 changes: 14 additions & 2 deletions vendor/fbtransform/visitors.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
/*global exports:true*/
var es6Classes = require('jstransform/visitors/es6-class-visitors').visitorList;
var es6ArrowFunctions = require('jstransform/visitors/es6-arrow-function-visitors');
var es6Classes = require('jstransform/visitors/es6-class-visitors');
var es6ObjectShortNotation = require('jstransform/visitors/es6-object-short-notation-visitors');
var es6RestParameters = require('jstransform/visitors/es6-rest-param-visitors');
var es6Templates = require('jstransform/visitors/es6-template-visitors');
var react = require('./transforms/react');
var reactDisplayName = require('./transforms/reactDisplayName');

/**
* Map from transformName => orderedListOfVisitors.
*/
var transformVisitors = {
'es6-classes': es6Classes,
'es6-arrow-functions': es6ArrowFunctions.visitorList,
'es6-classes': es6Classes.visitorList,
'es6-object-short-notation': es6ObjectShortNotation.visitorList,
'es6-rest-params': es6RestParameters.visitorList,
'es6-templates': es6Templates.visitorList,
'react': [
react.visitReactTag,
reactDisplayName.visitReactDisplayName
Expand All @@ -18,7 +26,11 @@ var transformVisitors = {
* Specifies the order in which each transform should run.
*/
var transformRunOrder = [
'es6-arrow-functions',
'es6-object-short-notation',
'es6-classes',
'es6-rest-params',
'es6-templates',
'react'
];

Expand Down

0 comments on commit 31359e9

Please sign in to comment.