How to use the jstransform.transform function in jstransform

To help you get started, we’ve selected a few jstransform 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 facebook / react / vendor / fbtransform / syntax.js View on Github external
function transformAll(source, options, excludes) {
  excludes = excludes || [];

  // Stripping types needs to happen before the other transforms
  // unfortunately, due to bad interactions. For example,
  // es6-rest-param-visitors conflict with stripping rest param type
  // annotation
  source = transform(typesSyntax.visitorList, source, options).code;

  // The typechecker transform must run in a second pass in order to operate on
  // the entire source code -- so exclude it from the first pass
  var visitorsList = visitors.getAllVisitors(excludes.concat('typechecker'));
  source = transform(visitorsList, source, options);
  if (excludes.indexOf('typechecks') == -1 && /@typechecks/.test(source.code)) {
    source = transform(
      visitors.transformVisitors.typechecker,
      source.code,
      options
    );
  }
  return source;
}
github insin / msx / vendor / fbtransform / syntax.js View on Github external
function transformAll(source, options, excludes) {
  excludes = excludes || [];

  // Stripping types needs to happen before the other transforms
  // unfortunately, due to bad interactions. For example,
  // es6-rest-param-visitors conflict with stripping rest param type
  // annotation
  source = transform(typesSyntax.visitorList, source, options).code;

  // The typechecker transform must run in a second pass in order to operate on
  // the entire source code -- so exclude it from the first pass
  var visitorsList = visitors.getAllVisitors(excludes.concat('typechecker'));
  source = transform(visitorsList, source, options);
  if (excludes.indexOf('typechecks') == -1 && /@typechecks/.test(source.code)) {
    source = transform(
      visitors.transformVisitors.typechecker,
      source.code,
      options
    );
  }
  return source;
}
github facebook / react / vendor / fbtransform / syntax.js View on Github external
function transformAll(source, options, excludes) {
  excludes = excludes || [];

  // Stripping types needs to happen before the other transforms
  // unfortunately, due to bad interactions. For example,
  // es6-rest-param-visitors conflict with stripping rest param type
  // annotation
  source = transform(typesSyntax.visitorList, source, options).code;

  // The typechecker transform must run in a second pass in order to operate on
  // the entire source code -- so exclude it from the first pass
  var visitorsList = visitors.getAllVisitors(excludes.concat('typechecker'));
  source = transform(visitorsList, source, options);
  if (excludes.indexOf('typechecks') == -1 && /@typechecks/.test(source.code)) {
    source = transform(
      visitors.transformVisitors.typechecker,
      source.code,
      options
    );
  }
  return source;
}
github facebook / react / vendor / browser-transforms.js View on Github external
function transformReact(source, options) {
  // TODO: just use react-tools
  var visitorList;
  if (options && options.harmony) {
    visitorList = visitors.getAllVisitors();
  } else {
    visitorList = visitors.transformVisitors.react;
  }

  return transform(visitorList, source, {
    sourceMap: supportsAccessors
  });
}
github Caltech-IPAC / firefly / node_modules / jsx-loader / node_modules / react-tools / main.js View on Github external
}

  if (options.es3) {
    visitorSets.push('es3');
  }

  if (options.stripTypes) {
    // Stripping types needs to happen before the other transforms
    // unfortunately, due to bad interactions. For example,
    // es6-rest-param-visitors conflict with stripping rest param type
    // annotation
    input = transform(typesSyntax.visitorList, input, options).code;
  }

  var visitorList = visitors.getVisitorsBySet(visitorSets);
  return transform(visitorList, input, options);
}
github insin / msx / main.js View on Github external
// annotation
    input = transform(typesSyntax.visitorList, input, options).code;
  }

  var visitorList = visitors.getVisitorsBySet(visitorSets);

  // Patch the react tag visitor to preconfigure the MSX precompile argument
  for (var i = 0; i < visitorList.length ; i++) {
    var visitor = visitorList[i];
    if (visitor === visitReactTag) {
      visitorList[i] = partial(visitor, options.precompile);
      visitorList[i].test = visitor.test;
    }
  }

  return transform(visitorList, input, options);
}
github groupon / quinn / build / compile.js View on Github external
process.stdin.pipe(concat(function(data) {
  var transformed = transform([].concat(
    modules,
    // destruct, // buggy :(
    arrow,
    classes,
    templates,
    restParam
  ), data.toString('utf8'), {
    sourceMap: false,
    minify: true
  });
  process.stdout.write(transformed.code);
}));
github cesarenaldi / iniettore / tasks / utils / runtime-transpiler.js View on Github external
require.extensions['.js'] = function(module, filename) {

	var src

	if (! (/iniettore\/(?:src|test)/.test(filename)) ) {
		return loader.apply(this, [].slice.call(arguments))
	}

	src = fs.readFileSync(filename, {encoding: 'utf8'})

	try {
		src = jstransform.transform(visitorList, src, { minify: true })
	} catch (e) {
		throw new Error('Error transforming ' + filename + ' to ES6: ' + e.toString())
	}
	module._compile(stripBOM(src.code), filename)
}
github cesarenaldi / iniettore / tasks / utils / runtime-transpiler.js View on Github external
require.extensions['.js'] = function(module, filename) {

	var src

	if (! (/iniettore\/(?:src|test)/.test(filename)) ) {
		return loader.apply(this, [].slice.call(arguments))
	}

	src = fs.readFileSync(filename, {encoding: 'utf8'})

	try {
		src = jstransform.transform(visitorList, src, { minify: false })
	} catch (e) {
		throw new Error('Error transforming ' + filename + ' to ES6: ' + e.toString())
	}
	module._compile(stripBOM(src.code), filename)
}
github joshuaslate / saas-tutorial / node_modules / envify / custom.js View on Github external
function flush() {
      var source = buffer.join('')

      if (processEnvPattern.test(source)) {
        try {
          var visitors = createVisitors([argv, rootEnv])
          source = jstransform.transform(visitors, source).code
        } catch(err) {
          return this.emit('error', err)
        }
      }

      this.queue(source)
      this.queue(null)
    }
  }

jstransform

A simple AST visitor-based JS transformer

BSD-3-Clause
Latest version published 9 years ago

Package Health Score

50 / 100
Full package analysis

Popular jstransform functions