Skip to content

[RFC] Split react-tools out into standalone repo #1966

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions bin/jsx-internal
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// -*- mode: js -*-
"use strict";

var getAllVisitors = require('../vendor/fbtransform/visitors').getAllVisitors;
var transform = require('jstransform').transform;
// var getAllVisitors = require('react-tools/lib/visitors').getAllVisitors;
// var transform = require('jstransform').transform;

var transform = require('react-tools').transform;
var propagate = require("../vendor/constants").propagate;

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

// This is where JSX, ES6, etc. desugaring happens.
source = transform(getAllVisitors(), source).code;
source = transform(source, {harmony: true})

// Constant propagation means removing any obviously dead code after
// replacing constant expressions with literal (boolean) values.
Expand Down
2 changes: 1 addition & 1 deletion jest/preprocessor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

var ReactTools = require('../main.js');
var ReactTools = require('react-tools');

module.exports = {
process: function(src) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion main.js → npm-react-tools/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var visitors = require('./vendor/fbtransform/visitors');
var visitors = require('./lib/visitors');
var transform = require('jstransform').transform;
var Buffer = require('buffer').Buffer;

Expand Down
55 changes: 55 additions & 0 deletions npm-react-tools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "react-tools",
"description": "A set of complementary tools to React, including the JSX transformer.",
"version": "0.12.0-alpha",
"keywords": [
"react",
"jsx",
"transformer",
"view"
],
"homepage": "http://facebook.github.io/react",
"bugs": "https://github.com/facebook/react/issues",
"licenses": [
{
"type": "Apache-2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
}
],
"files": [
"main.js",
"bin/jsx",
"lib/"
],
"main": "main.js",
"bin": {
"jsx": "./bin/jsx"
},
"repository": {
"type": "git",
"url": "https://github.com/facebook/react"
},
"dependencies": {
"commoner": "^0.9.6",
"esprima-fb": "^4001.3001.0-dev-harmony-fb",
"jstransform": "^6.0.1"
},
"engines": {
"node": ">=0.10.0"
},
"preferGlobal": true,
"commonerConfig": {
"version": 4
},
"scripts": {
"test": "./node_modules/.bin/grunt test"
},
"jest": {
"rootDir": "src",
"scriptPreprocessor": "../jest/preprocessor.js",
"setupEnvScriptFile": "../jest/environment.js",
"unmockedModulePathPatterns": [
""
]
}
}
39 changes: 7 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,13 @@
{
"name": "react-tools",
"description": "A set of complementary tools to React, including the JSX transformer.",
"name": "react-build",
"description": "Build React here now.",
"private": true,
"version": "0.12.0-alpha",
"keywords": [
"react",
"jsx",
"transformer",
"view"
],
"homepage": "http://facebook.github.io/react",
"bugs": "https://github.com/facebook/react/issues",
"licenses": [
{
"type": "Apache-2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
}
],
"files": [
"main.js",
"bin/jsx",
"src/",
"vendor/fbtransform/"
],
"main": "main.js",
"bin": {
"jsx": "./bin/jsx"
},
"repository": {
"type": "git",
"url": "https://github.com/facebook/react"
},
"dependencies": {
"commoner": "^0.9.6",
"esprima-fb": "^4001.3001.0-dev-harmony-fb",
"jstransform": "^6.0.1"
"jstransform": "^6.0.1",
"react-tools": "*"
},
"devDependencies": {
"benchmark": "~1.0.0",
Expand Down Expand Up @@ -75,7 +49,8 @@
"version": 4
},
"scripts": {
"test": "./node_modules/.bin/grunt test"
"test": "./node_modules/.bin/grunt test",
"jest": "./node_modules/.bin/jest"
},
"jest": {
"rootDir": "src",
Expand Down
21 changes: 9 additions & 12 deletions vendor/browser-transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

var buffer = require('buffer');
var docblock = require('jstransform/src/docblock');
var transform = require('jstransform').transform;
var visitors = require('./fbtransform/visitors');
// var transform = require('jstransform').transform;
// var visitors = require('./fbtransform/visitors');
var ReactTools = require('react-tools');

var headEl;
var dummyAnchor;
Expand All @@ -41,17 +42,13 @@ var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
* @return {object} object as returned from jstransform
*/
function transformReact(source, options) {
// TODO: just use react-tools
var visitorList;
if (options && options.harmony) {
visitorList = visitors.getAllVisitors();
} else {
visitorList = visitors.transformVisitors.react;
}

return transform(visitorList, source, {
var opts = {
harmony: options && options.harmony,
sourceMap: supportsAccessors
});
};

// Current API of this is { code: result }, so use transformWithDetails
return ReactTools.transformWithDetails(source, opts);
}

/**
Expand Down