How to use the traceur.compile function in traceur

To help you get started, we’ve selected a few traceur 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 angular / router / scripts / angular-modulate.js View on Github external
contents = contents.replace(IMPORT_RE, function (match, obj, includePath) {
    if (!MODULE_LOCATIONS[includePath]) {
      imports.push(match);
      return '';
    }
    var inlineFilePath = path.join(dir, MODULE_LOCATIONS[includePath]);
    console.log(dir, inlineFilePath);
    if (inlineFilePath.substr(-3) !== '.js') {
      inlineFilePath += '.js';
    }
    return 'var ' + obj + '=' + inlineModule(inlineFilePath) + ';';
  });

  var services = imports.map(getParts).map(serviceify);
  contents = traceur.compile(contents, TRACEUR_OPTS);
  return detraceurify(unwrapify(contents, services));
}
github angular / angular / tools / transpiler / index.js View on Github external
function loadModule(filepath, transpile) {
  var data = fs.readFileSync(filepath, 'utf8');

  if (!data) {
    throw new Error('Failed to import ' + filepath);
  }

  if (transpile) {
    var moduleName = path.normalize(filepath)
      .replace(__dirname, 'transpiler')
      .replace(/\\/g, '/')
      .replace(/\.\w*$/, '');
    data = traceur.compile(data, SELF_COMPILE_OPTIONS, moduleName);
  }

  ('global', eval)(data);
}
github sindresorhus / broccoli-traceur / index.js View on Github external
TraceurFilter.prototype.processString = function (str, relativePath) {
	try {
		return traceur.compile(str, this.options, relativePath);
	} catch (errs) {
		throw errs.join('\n');
	}
};
github babel / babel / benchmark / index.js View on Github external
compile: function (code) {
      return traceur.compile(code, {
        modules: "commonjs",
        experimental: true
      });
    }
  },
github requireio / node6 / transpile.js View on Github external
module.exports = function transpile(src, options) {
  var compiled = compile(src, defaults(options, traceurOptions))
  return compiled
}
github esperantojs / esperanto / comparison / index.js View on Github external
fn: function ( code, filename, type ) {
			return traceur.compile( code, {
				filename: filename,
				modules: type,
				sourceMaps: false
			}).js;
		},
		after: function () {
github assaf / ironium / Gruntfile.js View on Github external
File.readdirSync('src').forEach(function(filename) {

      var source = File.readFileSync('src/' + filename, 'utf8');
      var options = {
        blockBinding: true,
        sourceMaps:   true,
        modules:      'commonjs',
        filename:     filename
      };
      var output = Traceur.compile(source, options);
      if (output.errors.length) {
        throw new Error(output.errors.join('\n'));
      } else {
        var clean = output.js.replace("module.exports = {};", "");
        File.writeFileSync('lib/' + filename, clean, 'utf8');
        grunt.log.ok('src/' + filename + ' => lib/' + filename);
      }

    });
  });
github domenic / count-to-6 / lib / traceur-processor.js View on Github external
var transpile = q.fbind(function (contents, filename) {
    var transpiled = traceur.compile(contents, {
        filename: filename,
        modules: "inline"
    });

    return runtimeContents + transpiled;
});