From d982d5e153186b45a523e740d3ae7be699adda48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Tue, 2 Jun 2015 14:13:11 -0700 Subject: [PATCH 1/2] Move react-tools from root. ReactTools is deprecated, it doesn't belong at the root of the project. We'll remove it after 0.14 but for now this moves it so that it's contained and not intermixed with the rest of the project. The currect behavior of copying src/ into the package is maintained. --- grunt/tasks/npm-react-tools.js | 18 +++++------------ {bin => npm-react-tools/bin}/jsx | 0 main.js => npm-react-tools/main.js | 0 npm-react-tools/package.json | 32 ++++++++++++++++++++++++++++++ package.json | 32 +++--------------------------- packages/react/package.json | 5 +---- 6 files changed, 41 insertions(+), 46 deletions(-) rename {bin => npm-react-tools/bin}/jsx (100%) rename main.js => npm-react-tools/main.js (100%) create mode 100644 npm-react-tools/package.json diff --git a/grunt/tasks/npm-react-tools.js b/grunt/tasks/npm-react-tools.js index e68ecf8cfe2..f125f754cf9 100644 --- a/grunt/tasks/npm-react-tools.js +++ b/grunt/tasks/npm-react-tools.js @@ -4,6 +4,7 @@ var fs = require('fs'); var grunt = require('grunt'); var src = 'npm-react-tools'; +var srcSrc = 'src/**/*.js'; var dest = 'build/npm-react-tools/'; function buildRelease() { @@ -11,22 +12,13 @@ function buildRelease() { grunt.file.delete(dest); } - // read our required files from package.json - var pkgFiles = grunt.config.data.pkg.files; - // copy all files from src first, includes custom README var mappings = grunt.file.expandMapping('**/*', dest, {cwd: src}); - // make sure we also get package.json - pkgFiles.push('package.json'); - - pkgFiles.map(function(file) { - if (grunt.file.isDir(file)) { - mappings = mappings.concat(grunt.file.expandMapping(file + '**/*', dest)); - } else { - mappings.push({src: [file], dest: dest + file}); - } - }); + // Also copy all files from src/ (for react-native) + mappings = mappings.concat( + grunt.file.expandMapping(srcSrc, dest) + ); mappings.forEach(function(mapping) { var mappingSrc = mapping.src[0]; diff --git a/bin/jsx b/npm-react-tools/bin/jsx similarity index 100% rename from bin/jsx rename to npm-react-tools/bin/jsx diff --git a/main.js b/npm-react-tools/main.js similarity index 100% rename from main.js rename to npm-react-tools/main.js diff --git a/npm-react-tools/package.json b/npm-react-tools/package.json new file mode 100644 index 00000000000..35fc90a06f9 --- /dev/null +++ b/npm-react-tools/package.json @@ -0,0 +1,32 @@ +{ + "name": "react-tools", + "description": "A set of complementary tools to React, including the JSX transformer.", + "version": "0.14.0-alpha3", + "keywords": [ + "react", + "jsx", + "transformer", + "view" + ], + "homepage": "https://facebook.github.io/react", + "bugs": "https://github.com/facebook/react/issues", + "license": "BSD-3-Clause", + "files": [ + "main.js", + "bin/jsx", + "src/" + ], + "main": "main.js", + "bin": { + "jsx": "./bin/jsx" + }, + "repository": "facebook/react", + "dependencies": { + "commoner": "^0.10.0", + "jstransform": "^11.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "preferGlobal": true +} diff --git a/package.json b/package.json index ca08a3d6802..32001f6e61f 100644 --- a/package.json +++ b/package.json @@ -1,33 +1,7 @@ { - "name": "react-tools", - "description": "A set of complementary tools to React, including the JSX transformer.", + "name": "react-build", + "private": true, "version": "0.14.0-beta1", - "keywords": [ - "jsx", - "react", - "transformer", - "view" - ], - "homepage": "https://facebook.github.io/react", - "bugs": "https://github.com/facebook/react/issues", - "license": "BSD-3-Clause", - "files": [ - "bin/jsx", - "main.js", - "src/" - ], - "main": "main.js", - "bin": { - "jsx": "./bin/jsx" - }, - "repository": { - "type": "git", - "url": "https://github.com/facebook/react" - }, - "dependencies": { - "commoner": "^0.10.0", - "jstransform": "^11.0.0" - }, "devDependencies": { "babel": "^5.8.3", "babel-eslint": "^3.1.25", @@ -54,6 +28,7 @@ "gulp-util": "^3.0.5", "gzip-js": "~0.3.2", "jest-cli": "^0.4.13", + "jstransform": "^11.0.0", "object-assign": "^3.0.0", "optimist": "^0.6.1", "platform": "^1.1.0", @@ -67,7 +42,6 @@ "engines": { "node": ">=0.10.0" }, - "preferGlobal": true, "commonerConfig": { "version": 7 }, diff --git a/packages/react/package.json b/packages/react/package.json index 15afb92cbde..52531a3aa0a 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -16,10 +16,7 @@ "lib/" ], "main": "react.js", - "repository": { - "type": "git", - "url": "https://github.com/facebook/react" - }, + "repository": "facebook/react", "engines": { "node": ">=0.10.0" }, From 94bc29b400f487aa84c4ff6686e9f41e78b2ccc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Mon, 15 Jun 2015 00:27:02 -0700 Subject: [PATCH 2/2] Remove react-tools completely --- Gruntfile.js | 6 ---- grunt/tasks/npm-react-tools.js | 53 --------------------------- npm-react-tools/README.md | 65 ---------------------------------- npm-react-tools/bin/jsx | 51 -------------------------- npm-react-tools/main.js | 38 -------------------- npm-react-tools/package.json | 32 ----------------- 6 files changed, 245 deletions(-) delete mode 100644 grunt/tasks/npm-react-tools.js delete mode 100644 npm-react-tools/README.md delete mode 100755 npm-react-tools/bin/jsx delete mode 100644 npm-react-tools/main.js delete mode 100644 npm-react-tools/package.json diff --git a/Gruntfile.js b/Gruntfile.js index f2cf451f726..52f55e91b08 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -71,10 +71,6 @@ module.exports = function(grunt) { grunt.registerTask('npm-react:release', npmReactTasks.buildRelease); grunt.registerTask('npm-react:pack', npmReactTasks.packRelease); - var npmReactToolsTasks = require('./grunt/tasks/npm-react-tools'); - grunt.registerTask('npm-react-tools:release', npmReactToolsTasks.buildRelease); - grunt.registerTask('npm-react-tools:pack', npmReactToolsTasks.packRelease); - var npmReactDOMTasks = require('./grunt/tasks/npm-react-dom'); grunt.registerTask('npm-react-dom:pack', npmReactDOMTasks.packRelease); @@ -133,8 +129,6 @@ module.exports = function(grunt) { 'browserify:addonsMin', 'npm-react:release', 'npm-react:pack', - 'npm-react-tools:release', - 'npm-react-tools:pack', 'npm-react-dom:pack', 'npm-react-addons:release', 'npm-react-addons:pack', diff --git a/grunt/tasks/npm-react-tools.js b/grunt/tasks/npm-react-tools.js deleted file mode 100644 index f125f754cf9..00000000000 --- a/grunt/tasks/npm-react-tools.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -var fs = require('fs'); -var grunt = require('grunt'); - -var src = 'npm-react-tools'; -var srcSrc = 'src/**/*.js'; -var dest = 'build/npm-react-tools/'; - -function buildRelease() { - if (grunt.file.exists(dest)) { - grunt.file.delete(dest); - } - - // copy all files from src first, includes custom README - var mappings = grunt.file.expandMapping('**/*', dest, {cwd: src}); - - // Also copy all files from src/ (for react-native) - mappings = mappings.concat( - grunt.file.expandMapping(srcSrc, dest) - ); - - mappings.forEach(function(mapping) { - var mappingSrc = mapping.src[0]; - var mappingDest = mapping.dest; - if (grunt.file.isDir(mappingSrc)) { - grunt.file.mkdir(mappingDest); - } else { - grunt.file.copy(mappingSrc, mappingDest); - } - }); -} - -function packRelease() { - var done = this.async(); - var spawnCmd = { - cmd: 'npm', - args: ['pack', 'npm-react-tools'], - opts: { - cwd: 'build/', - }, - }; - grunt.util.spawn(spawnCmd, function() { - var buildSrc = 'build/react-tools-' + grunt.config.data.pkg.version + '.tgz'; - var buildDest = 'build/react-tools.tgz'; - fs.rename(buildSrc, buildDest, done); - }); -} - -module.exports = { - buildRelease: buildRelease, - packRelease: packRelease, -}; diff --git a/npm-react-tools/README.md b/npm-react-tools/README.md deleted file mode 100644 index 895c3e70342..00000000000 --- a/npm-react-tools/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# react-tools - -This package compliments the usage of [React](https://facebook.github.io/react/). It ships with tools that are often used in conjunction. - -## JSX - -This package installs a `jsx` executable that can be used to transform JSX into vanilla JS. This is often used as part of a build step. This transform is also exposed as an API. - -By default JSX files with a `.js` extension are transformed. Use the `-x` option to transform files with a `.jsx` extension. - -## Usage - -### Command Line - - Usage: jsx [options] [ [ ...]] - - Options: - - -h, --help output usage information - -V, --version output the version number - -c, --config [file] JSON configuration file (no file or - means STDIN) - -w, --watch Continually rebuild - -x, --extension File extension to assume when resolving module identifiers (default: js) - --relativize Rewrite all module identifiers to be relative - --follow-requires Scan modules for required dependencies - --cache-dir Alternate directory to use for disk cache - --no-cache-dir Disable the disk cache - --source-charset Charset of source (default: utf8) - --output-charset Charset of output (default: utf8) - --harmony Turns on JS transformations such as ES6 Classes etc. - --source-map-inline Embed inline sourcemap in transformed source - --strip-types Strips out type annotations - --es6module Parses the file as a valid ES6 module - --non-strict-es6module Parses the file as an ES6 module, except disables implicit strict-mode (i.e. CommonJS modules et al are allowed) - --target Target version of ECMAScript. Valid values are "es3" and "es5". Use "es3" for legacy browsers like IE8. - -## API - -### `transform(inputString, options)` - -option | values | default --------|--------|--------- -`sourceMap` | `true`: append inline source map at the end of the transformed source | `false` -`harmony` | `true`: enable ES6 features | `false` -`sourceFilename` | the output filename for the source map | `"source.js"` -`stripTypes` | `true`: strips out type annotations | `false` -`es6module` | `true`: parses the file as an ES6 module | `false` -`nonStrictEs6module` | `true`: parses the file as an ES6 module, except disables implicit strict-mode (i.e. CommonJS modules et al are allowed) | `false` -`target` | `"es3"`: ECMAScript 3
`"es5"`: ECMAScript 5| `"es5"` - -```js -var reactTools = require('react-tools'); - -reactTools.transform(string, options); -``` - -### `transformWithDetails(inputString, options)` - -Just like `transform`, but outputs an object: -```js -{ - code: outputString, - sourceMap: theSourceMap // Only if the `sourceMap` option is `true`. -} -``` diff --git a/npm-react-tools/bin/jsx b/npm-react-tools/bin/jsx deleted file mode 100755 index 616d7afe401..00000000000 --- a/npm-react-tools/bin/jsx +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env node -// -*- mode: js -*- -'use strict'; - -var transform = require('../main').transform; - -require('commoner').version( - require('../package.json').version -).resolve(function(id) { - return this.readModuleP(id); -}).option( - '--harmony', - 'Turns on JS transformations such as ES6 Classes etc.' -).option( - '--target [version]', - 'Specify your target version of ECMAScript. Valid values are "es3" and ' + - '"es5". The default is "es5". "es3" will avoid uses of defineProperty and ' + - 'will quote reserved words. WARNING: "es5" is not properly supported, even ' + - 'with the use of es5shim, es5sham. If you need to support IE8, use "es3".', - 'es5' -).option( - '--strip-types', - 'Strips out type annotations.' -).option( - '--es6module', - 'Parses the file as a valid ES6 module. ' + - '(Note that this means implicit strict mode)' -).option( - '--non-strict-es6module', - 'Parses the file as an ES6 module, except disables implicit strict-mode. ' + - '(This is useful if you\'re porting non-ES6 modules to ES6, but haven\'t ' + - 'yet verified that they are strict-mode safe yet)' -).option( - '--source-map-inline', - 'Embed inline sourcemap in transformed source' -).process(function(id, source) { - // This is where JSX, ES6, etc. desugaring happens. - // We don't do any pre-processing of options so that the command line and the - // JS API both expose the same set of options. We do extract the options that - // we care about from commoner though so we aren't passing too many things - // along. - var options = { - harmony: this.options.harmony, - sourceMap: this.options.sourceMapInline, - stripTypes: this.options.stripTypes, - es6module: this.options.es6module, - nonStrictEs6module: this.options.nonStrictEs6module, - target: this.options.target - }; - return transform(source, options); -}); diff --git a/npm-react-tools/main.js b/npm-react-tools/main.js deleted file mode 100644 index 0dc6d5e6882..00000000000 --- a/npm-react-tools/main.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -'use strict'; - -var jstransform = require('jstransform/simple'); - -function transformWithDetails(code, opts) { - opts = opts || {}; - - // Copy out the values we need and make sure they are compatible with - // jstransform options. Always set react:true. - var options = { - react: true, - harmony: opts.harmony, - stripTypes: opts.stripTypes, - sourceMapInline: opts.sourceMap, - sourceFilename: opts.sourceFilename, - es6module: opts.es6module, - nonStrictEs6module: opts.nonStrictEs6module, - target: opts.target, - }; - - return jstransform.transform(code, options); -} - -module.exports = { - transform: function(input, options) { - return transformWithDetails(input, options).code; - }, - transformWithDetails: transformWithDetails, -}; diff --git a/npm-react-tools/package.json b/npm-react-tools/package.json deleted file mode 100644 index 35fc90a06f9..00000000000 --- a/npm-react-tools/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "react-tools", - "description": "A set of complementary tools to React, including the JSX transformer.", - "version": "0.14.0-alpha3", - "keywords": [ - "react", - "jsx", - "transformer", - "view" - ], - "homepage": "https://facebook.github.io/react", - "bugs": "https://github.com/facebook/react/issues", - "license": "BSD-3-Clause", - "files": [ - "main.js", - "bin/jsx", - "src/" - ], - "main": "main.js", - "bin": { - "jsx": "./bin/jsx" - }, - "repository": "facebook/react", - "dependencies": { - "commoner": "^0.10.0", - "jstransform": "^11.0.0" - }, - "engines": { - "node": ">=0.10.0" - }, - "preferGlobal": true -}