How to use the traceur.require 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 frankwallis / plugin-typescript / test / compiler-load-spec.js View on Github external
var fs = require('fs');
var os = require('os');
var path = require('path');
var should  = require('should');
var Promise = require('bluebird');

var Traceur = require('traceur');

// Traceur will compile all JS aside from node modules
Traceur.require.makeDefault(function(filename) {
   return !(/node_modules/.test(filename));
});

var Compiler = require('../lib/incremental-compiler').IncrementalCompiler;
var formatErrors = require('../lib/format-errors').formatErrors;

var missingFile = '/somefolder/fixtures/program1/missing-file.ts';
var circularFile = require.resolve('./fixtures/circular/circular.ts');
var missingImport = require.resolve('./fixtures/program1/missing-import.ts');
var syntaxError = require.resolve('./fixtures/program1/syntax-error.ts');
var typeError = require.resolve('./fixtures/program1/type-error.ts');
var nestedTypeError = require.resolve('./fixtures/program1/nested-type-error.ts');
var noImports = require.resolve('./fixtures/program1/no-imports.ts');
var oneImport = require.resolve('./fixtures/program1/one-import.ts');
var ambientImportJs = require.resolve('./fixtures/ambients/ambient-import-js.ts');
var ambientImportTs = require.resolve('./fixtures/ambients/ambient-import-ts.ts');
github frankwallis / plugin-typescript / test / compiler-compile-spec.js View on Github external
var fs = require('fs');
var path = require('path');
var should  = require('should');
var Promise = require('bluebird');

var Traceur = require('traceur');

// Traceur will compile all JS aside from node modules
Traceur.require.makeDefault(function(filename) {
   return !(/node_modules/.test(filename));
});

var Compiler = require('../lib/incremental-compiler').IncrementalCompiler;
var formatErrors = require('../lib/format-errors').formatErrors;

var missingFile = '/somefolder/fixtures/program1/missing-file.ts';
var missingImport = require.resolve('./fixtures/program1/missing-import.ts');
var syntaxError = require.resolve('./fixtures/program1/syntax-error.ts');
var referenceSyntaxError = require.resolve('./fixtures/program1/ref-syntax-error.ts');
var typeError = require.resolve('./fixtures/program1/type-error.ts');
var nestedTypeError = require.resolve('./fixtures/program1/nested-type-error.ts');
var noImports = require.resolve('./fixtures/program1/no-imports.ts');
var oneImport = require.resolve('./fixtures/program1/one-import.ts');
var ambientReference = require.resolve('./fixtures/ambients/ambient-reference.ts');
var ambientImportJs = require.resolve('./fixtures/ambients/ambient-import-js.ts');
github marian2js / rode / index.js View on Github external
// NOTE: This is the only file that does not support ES6 //

var traceur = require('traceur');
var path = require('path');
require('es6-shim');
require('es6-module-loader');
require('prfun');

// base path
global.__rodeBase = __dirname;

// ES6 files
traceur.require.makeDefault(function(filename) {
  // all the files outside the node_modules directory will use ES6
  return filename.startsWith(__dirname) && !filename.startsWith(path.join(__dirname, 'node_modules'));
});

// export rode.js
module.exports = require('./loader').rode;
github getguesstimate / guesstimate-app / server.js View on Github external
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config');

var express    = require('express');        // call express
var bodyParser = require('body-parser');
var app        = express();                 // define our app using express
var mongoose = require('mongoose');
var router = express.Router();              // get an instance of the express Router
var path = require('path');
mongoose.connect('mongodb://oagr:password@proximus.modulusmongo.net:27017/tas3uZuj');
var jsx = require('express-react-views').createEngine({jsx: {harmony: true}});
var traceur = require('traceur');
traceur.require.makeDefault(function(file) {
  return file.indexOf('node_modules') == -1;
});

app.use(express.static(path.join(__dirname, 'public')));
app.set('views', __dirname + '/scripts/views');
app.set('view engine', 'jsx');
app.engine('jsx', jsx)

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

var comments = [{author: 'Pete Hunt', text: 'Hey there!'}];

app.all('/', function(req, res, next) {
  res.header('Access-Control-Allow-Origin', 'http://localhost:3000');
  res.header('Access-Control-Allow-Headers', 'X-Requested-With');
github OpenSprites / OpenSprites-next / server / entry.js View on Github external
require('source-map-support').install()
require('traceur/bin/traceur-runtime')
require('traceur').require.makeDefault(f => f.indexOf('node_modules') === -1, {
  experimental: true,
  properTailCalls: false,
  symbols: true,
  arrayComprehension: true,
  asyncFunctions: true,
  asyncGenerators: true,
  forOn: true,
  generatorComprehension: true,
  sourceMaps: 'inline'
})

process.on('unhandledRejection', function(err) {
  console.error(err)
})

require('../main.js')
github domenic / traceur-runner / lib / traceur-runner.js View on Github external
"use strict";
var traceur = require("traceur");
var path = require("path");
var fs = require("fs");

require("traceur-source-maps").install(traceur);

traceur.require.makeDefault(function (filename) {
    var segments = filename.split(/(?:\/|\\)/);
    var nodeModulesIndex = segments.lastIndexOf("node_modules");
    if (nodeModulesIndex === -1) {
        return true;
    }

    var packagePath = segments.slice(0, nodeModulesIndex + 2).join(path.sep) + path.sep + "package.json";
    var packageContents = fs.readFileSync(packagePath, { encoding: "utf-8" });
    var packageJSON = JSON.parse(packageContents);

    return !!packageJSON["traceur-runner"];
});
github petkaantonov / bluebird / benchmark / async-compare / examples / dst-promises-q-generator-traceur.js View on Github external
require('traceur').require.makeDefault();
require('source-map-support').install();
module.exports = require('./promises-q-generator.js');
github petkaantonov / bluebird / benchmark / async-compare / examples / dst-thunks-generator-co-traceur.js View on Github external
require('traceur').require.makeDefault();
require('source-map-support').install();
module.exports = require('./thunks-generator-co.js');
github dr4fters / dr4ft / src / make / index.js View on Github external
var target = process.argv[2];
require("traceur").require.makeDefault(function(path) {
  return path.indexOf("node_modules") === -1;
});
require("./" + target);
github petkaantonov / bluebird / benchmark / async-compare / examples / dst-callbacks-generator-suspend-traceur.js View on Github external
require('traceur').require.makeDefault();
require('source-map-support').install();
module.exports = require('./callbacks-generator-suspend.js');