-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (29 loc) · 749 Bytes
/
index.js
File metadata and controls
33 lines (29 loc) · 749 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
var path = require('path');
var simple = require('jstransform/simple');
var JSXProcessor = function (cube) {
this.cube = cube;
};
JSXProcessor.info = {
type: 'script',
ext: '.jsx'
};
JSXProcessor.prototype = {
process: function (file, options, callback) {
var code;
var root = options.root;
try {
code = simple.transformFileSync(path.join(root, file), {react: true}).code;
} catch (e) {
return callback(e);
}
if (!options.moduleWrap) {
return callback(null, {source: code, code: code});
}
if (options.release) {
file = file.replace(/\.jsx/g, '.js');
options.qpath = file;
}
this.cube.processJsCode(file, code, options, callback);
}
};
module.exports = JSXProcessor;