How to use the react-tools.transformWithDetails function in react-tools

To help you get started, we’ve selected a few react-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sindresorhus / gulp-react / index.js View on Github external
}

		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();
github floatdrop / plugin-jsx / jsx.js View on Github external
exports.translate = function(load) {
	var output = react.transformWithDetails(load.source, { es6module: true, sourceMap: true });
	load.metadata.sourceMap = output.sourceMap;
	return output.code;
};
github podio / istanbul-react / index.js View on Github external
Instrumenter.prototype._transform = function (content) {
  var transformed = reactTools.transformWithDetails(content, {
    sourceMap: true,
    harmony: true
  });

  var program = esprima.parse(transformed.code, {
    loc: true
  });

  return program;
};