Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (file.isStream()) {
cb(new gutil.PluginError('gulp-react', 'Streaming not supported'));
return;
}
try {
if (file.sourceMap) {
opts = objectAssign(opts, {
sourceMap: true,
sourceFilename: file.relative
});
}
var res = react.transformWithDetails(file.contents.toString(), opts);
file.contents = new Buffer(res.code);
file.path = gutil.replaceExtension(file.path, '.js');
if (res.sourceMap && file.sourceMap) {
applySourceMap(file, res.sourceMap);
}
this.push(file);
} catch (err) {
this.emit('error', new gutil.PluginError('gulp-react', err, {
fileName: file.path
}));
}
cb();
exports.translate = function(load) {
var output = react.transformWithDetails(load.source, { es6module: true, sourceMap: true });
load.metadata.sourceMap = output.sourceMap;
return output.code;
};
Instrumenter.prototype._transform = function (content) {
var transformed = reactTools.transformWithDetails(content, {
sourceMap: true,
harmony: true
});
var program = esprima.parse(transformed.code, {
loc: true
});
return program;
};