From f1b7db9aef57d5b2a9264b51e4303540772f847f Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Fri, 31 Jan 2014 21:53:08 +0200 Subject: [PATCH] More optimizations and fix for JSXTransformer build * Dropped dependency on emulation of Node.js native modules. * Added deamdify step for JSXTransformer build. --- grunt/config/browserify.js | 2 ++ package.json | 3 ++- vendor/browser-transforms.js | 7 +++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/grunt/config/browserify.js b/grunt/config/browserify.js index f0ad28dfa13c9..6c63ac5796b71 100644 --- a/grunt/config/browserify.js +++ b/grunt/config/browserify.js @@ -3,6 +3,7 @@ 'use strict'; +var deamdify = require('deamdify'); var envify = require('envify/custom'); var grunt = require('grunt'); var UglifyJS = require('uglify-js'); @@ -80,6 +81,7 @@ var transformer = { outfile: './build/JSXTransformer.js', debug: false, standalone: 'JSXTransformer', + transforms: [deamdify], after: [simpleBannerify] }; diff --git a/package.json b/package.json index 21d9b71b8cc40..69cd50e477d1c 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "devDependencies": { "benchmark": "~1.0.0", "coverify": "~1.0.4", + "deamdify": "~0.1.1", "envify": "~1.0.1", "es5-shim": "~2.3.0", "grunt": "~0.4.2", @@ -59,7 +60,7 @@ "phantomjs": "~1.9", "platform": "~1.0.0", "populist": "~0.1.6", - "pure-cjs": "~1.8.0", + "pure-cjs": "~1.8.3", "recast": "~0.5.6", "sauce-tunnel": "~1.1.0", "semver": "~2.2.1", diff --git a/vendor/browser-transforms.js b/vendor/browser-transforms.js index 701693c34a7cf..b0e61c6bb7691 100644 --- a/vendor/browser-transforms.js +++ b/vendor/browser-transforms.js @@ -20,7 +20,6 @@ var runScripts; var headEl; -var buffer = require('buffer'); var transform = require('jstransform').transform; var visitors = require('./fbtransform/visitors').transformVisitors; var docblock = require('jstransform/src/docblock'); @@ -97,6 +96,10 @@ var transformCode = function(code, source) { throw e; } + if (typeof btoa === 'undefined') { + return transformed.code; + } + var map = transformed.sourceMap.toJSON(); if (source == null) { source = "Inline JSX script"; @@ -111,7 +114,7 @@ var transformCode = function(code, source) { return ( transformed.code + '//# sourceMappingURL=data:application/json;base64,' + - buffer.Buffer(JSON.stringify(map)).toString('base64') + btoa(unescape(encodeURIComponent(JSON.stringify(map)))) ); } else { return code;