Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more useful ES6 transforms to jsx-internal. #636

Merged
merged 1 commit into from
Dec 6, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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