How to use the traceur.options 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 jspm / jspm-cli / traceur-compiler.js View on Github external
process.stdin.on('end', function(data) {
  inData.push(data || '');
  try {
    var o = JSON.parse(inData.join(''));

    /*
      o.source
      o.options
      o.file
      o.originalFile
    */

    traceur.options = o.options;
    traceur.options.sourceMaps = true;
    traceur.options.modules = 'parse';

    var reporter = new traceur.util.ErrorReporter();
    reporter.reportMessageInternal = function(location, kind, format, args) {
      process.stdout.write(JSON.stringify({ err: kind + '\n' + o.file + location }));
      process.exit(0);
    }

    var parser = new traceur.syntax.Parser(reporter, new traceur.syntax.SourceFile(o.file, o.source));
    var tree = parser.parseModule();

    var project = new traceur.semantics.symbols.Project(o.file);
    var transformer = new traceur.codegeneration.ProgramTransformer(reporter, project);
    tree = transformer.transform(tree);

    // generate source
github jspm / jspm-cli / traceur-compiler.js View on Github external
process.stdin.on('end', function(data) {
  inData.push(data || '');
  try {
    var o = JSON.parse(inData.join(''));

    /*
      o.source
      o.options
      o.file
      o.originalFile
    */

    traceur.options = o.options;
    traceur.options.sourceMaps = true;
    traceur.options.modules = 'parse';

    var reporter = new traceur.util.ErrorReporter();
    reporter.reportMessageInternal = function(location, kind, format, args) {
      process.stdout.write(JSON.stringify({ err: kind + '\n' + o.file + location }));
      process.exit(0);
    }

    var parser = new traceur.syntax.Parser(reporter, new traceur.syntax.SourceFile(o.file, o.source));
    var tree = parser.parseModule();

    var project = new traceur.semantics.symbols.Project(o.file);
    var transformer = new traceur.codegeneration.ProgramTransformer(reporter, project);
    tree = transformer.transform(tree);

    // generate source
    var sourceMapGenerator = new traceur.outputgeneration.SourceMapGenerator({ file: o.originalFile });
github jspm / jspm-cli / lib / build.js View on Github external
.then(function() {
            if (!options.transpile)
              return;

            var traceur = require('traceur');

            traceur.options.sourceMaps = true;
            traceur.options.modules = 'instantiate';

            try {
              var compiler = new traceur.Compiler({
                moduleName: '',
                modules: 'instantiate'
              });

              source = compiler.compile(source, relFile, path.basename(relFile.replace(/\.js$/, '.src.js')));
              sourceMap = compiler.getSourceMap();
            }
            catch(e) {
              // an error in one compiled file doesn't stop all compilation

              if (!e.stack)
                compileErrors +=  + '\n';
              else
github jspm / jspm-cli / lib / build.js View on Github external
.then(function() {
            if (!options.transpile)
              return;

            var traceur = require('traceur');

            traceur.options.sourceMaps = true;
            traceur.options.modules = 'instantiate';

            try {
              var compiler = new traceur.Compiler({
                moduleName: '',
                modules: 'instantiate'
              });

              source = compiler.compile(source, relFile, path.basename(relFile.replace(/\.js$/, '.src.js')));
              sourceMap = compiler.getSourceMap();
            }
            catch(e) {
              // an error in one compiled file doesn't stop all compilation

              if (!e.stack)
                compileErrors +=  + '\n';
github jspm / jspm-cli / traceur-compiler.js View on Github external
process.stdin.on('end', function(data) {
  inData.push(data || '');
  try {
    var o = JSON.parse(inData.join(''));

    /*
      o.source
      o.options
      o.file
      o.originalFile
    */

    traceur.options = o.options;
    traceur.options.sourceMaps = true;
    traceur.options.modules = 'parse';

    var reporter = new traceur.util.ErrorReporter();
    reporter.reportMessageInternal = function(location, kind, format, args) {
      process.stdout.write(JSON.stringify({ err: kind + '\n' + o.file + location }));
      process.exit(0);
    }

    var parser = new traceur.syntax.Parser(reporter, new traceur.syntax.SourceFile(o.file, o.source));
    var tree = parser.parseModule();

    var project = new traceur.semantics.symbols.Project(o.file);
    var transformer = new traceur.codegeneration.ProgramTransformer(reporter, project);
    tree = transformer.transform(tree);
github tarruda / grunt-traceur-build / tasks / traceur_build.js View on Github external
generators: true,
      modules: true,
      blockBinding: false,
      privateNameSyntax: false,
      privateNames: false,
      cascadeExpression: false,
      trapMemberLookup: false,
      deferredFunctions: false,
      propertyOptionalComma: false,
      types: false
    });

    traceur.options.reset();

    for (var k in options) {
      if (k in traceur.options) traceur.options[k] = options[k];
    }

    this.files.forEach(function(f) {
      if (/\.js$/.test(f.orig.dest)) {
        buildToFile(grunt, options, f);
      } else {
        buildToDirectory(grunt, options, f);
      }
    });
  });
};
github tarruda / grunt-traceur-build / tasks / traceur_build.js View on Github external
restParameters: true,
      spread: true,
      generatorComprehension: true,
      generators: true,
      modules: true,
      blockBinding: false,
      privateNameSyntax: false,
      privateNames: false,
      cascadeExpression: false,
      trapMemberLookup: false,
      deferredFunctions: false,
      propertyOptionalComma: false,
      types: false
    });

    traceur.options.reset();

    for (var k in options) {
      if (k in traceur.options) traceur.options[k] = options[k];
    }

    this.files.forEach(function(f) {
      if (/\.js$/.test(f.orig.dest)) {
        buildToFile(grunt, options, f);
      } else {
        buildToDirectory(grunt, options, f);
      }
    });
  });
};
github bjoerge / react-es6-class / boilerplate / transpile-es6.js View on Github external
  ].forEach(function (k) { traceur.options[k] = true; });
}();