forked from edd/broccoli-react
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (27 loc) · 905 Bytes
/
index.js
File metadata and controls
35 lines (27 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
var Filter = require('broccoli-filter');
var babel = require('babel-core');
var reactPreset = require('babel-preset-react');
module.exports = ReactFilter;
ReactFilter.prototype = Object.create(Filter.prototype);
ReactFilter.prototype.constructor = ReactFilter;
function ReactFilter (inputTree, options) {
if (!(this instanceof ReactFilter)){
return new ReactFilter(inputTree, options);
}
this.inputTree = inputTree;
this.options = options || {};
if (this.options.extensions) {
this.extensions = options.extensions;
}
}
ReactFilter.prototype.extensions = ['jsx'];
ReactFilter.prototype.targetExtension = 'js';
ReactFilter.prototype.processString = function (string) {
var result = babel.transform(string, {
babelrc: false,
presets: [reactPreset],
plugins: ["transform-class-properties", "transform-object-rest-spread"]
}).code;
return result;
};