jsx-transform
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -20,2 +20,3 @@ /*! | ||
var fs = require('fs'); | ||
var getExtension = require('path').extname; | ||
var jstransform = require('jstransform').transform; | ||
@@ -123,2 +124,4 @@ var visitNode = require('./visitor'); | ||
* @param {Object=} options | ||
* @param {String=} options.extensions Array of file extensions to run | ||
* browserify transform on (default: `['.js', '.jsx', '.es', '.es6']`). | ||
* @returns {Function} browserify transform | ||
@@ -131,6 +134,14 @@ */ | ||
browserifyTransform.configure = function (options) { | ||
if (typeof options.extensions === 'undefined') { | ||
options.extensions = ['.js', '.jsx', '.es', '.es6']; | ||
} | ||
return function (filename) { | ||
return through(function (buf, enc, next) { | ||
try { | ||
this.push(fromString(buf.toString('utf8'), options)); | ||
if (~options.extensions.indexOf(getExtension(filename))) { | ||
this.push(fromString(buf.toString('utf8'), options)); | ||
} else { | ||
this.push(buf.toString()); | ||
} | ||
next(); | ||
@@ -137,0 +148,0 @@ } catch (err) { |
{ | ||
"name": "jsx-transform", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "JSX transpiler. Desugar JSX into JavaScript. A standard and configurable implementation of JSX decoupled from React.", | ||
@@ -36,2 +36,3 @@ "files": [ | ||
"devDependencies": { | ||
"browserify": "^10.0.0", | ||
"expect.js": "^0.3.1", | ||
@@ -38,0 +39,0 @@ "gulp": "^3.8.10", |
@@ -83,6 +83,7 @@ # jsx-transform [![Build Status](http://img.shields.io/travis/alexmingoia/jsx-transform.svg?style=flat)](http://travis-ci.org/alexmingoia/jsx-transform) [![NPM version](http://img.shields.io/npm/v/jsx-transform.svg?style=flat)](https://npmjs.org/package/jsx-transform) [![Dependency Status](http://img.shields.io/david/alexmingoia/jsx-transform.svg?style=flat)](http://david-dm.org/alexmingoia/jsx-transform) | ||
| Param | Type | | ||
| --- | --- | | ||
| [filename] | <code>String</code> | | ||
| [options] | <code>Object</code> | | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| [filename] | <code>String</code> | | | ||
| [options] | <code>Object</code> | | | ||
| [options.extensions] | <code>String</code> | Array of file extensions to run browserify transform on (default: `['.js', '.jsx', '.es', '.es6']`). | | ||
@@ -89,0 +90,0 @@ **Example** |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21686
473
114
10