Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

traceur

Package Overview
Dependencies
Maintainers
1
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

traceur - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

bin/traceur-runtime.js

9

package.json
{
"name": "traceur",
"version": "0.0.9",
"version": "0.0.10",
"description": "Experimental ES6 to ES5 compiler",

@@ -26,2 +26,3 @@ "keywords": [

"scripts": {
"prepublish": "node build/prepublish.js",
"test": "make test"

@@ -44,5 +45,7 @@ },

"node-uuid": ">=1.4",
"rsvp": ">=2.0",
"requirejs": "~2.1.9"
"rsvp": "3.0.3",
"requirejs": "~2.1.9",
"semver": "2.2.1",
"traceur": "0.0.9"
}
}

@@ -24,3 +24,3 @@ [![Build Status](https://travis-ci.org/google/traceur-compiler.png)](https://travis-ci.org/google/traceur-compiler)

page to get up and running. You can use some language features right now and
even try it out in your browser [here](http://traceur-compiler.googlecode.com/git/demo/repl.html).
even try it out in your browser [here](http://google.github.io/traceur-compiler/demo/repl.html).
Just type in some code and see what Traceur produces. For an idea of what is

@@ -27,0 +27,0 @@ available and what we have in the pipeline, see the

@@ -22,2 +22,3 @@ // Copyright 2013 Traceur Authors.

var path = require('path');
var traceur = require('./traceur.js');

@@ -28,2 +29,3 @@ var ErrorReporter = traceur.util.TestErrorReporter;

var SourceFile = traceur.syntax.SourceFile;
var SourceMapGenerator = traceur.outputgeneration.SourceMapGenerator;
var TreeWriter = traceur.outputgeneration.TreeWriter;

@@ -44,2 +46,6 @@ var traceurOptions = traceur.options;

// The absolute path to traceur-runtime.js -- the file that should be executed
// if you want to run Traceur-compiled scripts when the compiler isn't present.
var RUNTIME_PATH = path.join(__dirname, '../../bin/traceur-runtime.js');
/**

@@ -57,3 +63,4 @@ * Compile ES6 source code with Traceur.

modules: 'commonjs',
filename: '<unknown file>'
filename: '<unknown file>',
sourceMap: false
}, options || {});

@@ -70,7 +77,24 @@

var transformedTree = transformer.transform(tree);
var code = errorReporter.hadError() ? null : TreeWriter.write(transformedTree, null);
if (errorReporter.hadError()) {
return {
js: null,
errors: errorReporter.errors,
sourceMap: null
};
}
var treeWriterOptions = {};
if (options.sourceMap) {
treeWriterOptions.sourceMapGenerator = new SourceMapGenerator({
file: options.filename,
sourceRoot: null
});
}
return {
js: code,
errors: errorReporter.errors
js: TreeWriter.write(transformedTree, treeWriterOptions),
errors: errorReporter.errors,
sourceMap: treeWriterOptions.sourceMap || null
};

@@ -82,1 +106,2 @@ };

module.exports.compile = compile;
module.exports.RUNTIME_PATH = RUNTIME_PATH;

@@ -32,2 +32,4 @@ // Copyright 2013 Traceur Authors.

flags.option('--out <FILE>', 'Compile all input files into a single file');
flags.option('--referrer <name>',
'Prefix compiled code with System.referrName');

@@ -164,3 +166,3 @@ flags.option('--sourcemap', 'Generate source maps');

} else {
interpret(includes[0], includes.slice(1), argv.flags);
interpret(path.resolve(includes[0]), includes.slice(1), argv.flags);
}

@@ -37,3 +37,3 @@ // Copyright 2013 Traceur Authors.

function writeTreeToFile(tree, filename, useSourceMaps, opt_sourceRoot) {
var options = null;
var options;
if (useSourceMaps) {

@@ -77,3 +77,3 @@ var sourceMapFilePath = getSourceMapFileName(filename);

inlineAndCompile(resolvedIncludes, {}, reporter, function(tree) {
inlineAndCompile(resolvedIncludes, traceur.options, reporter, function(tree) {
writeTreeToFile(tree, resolvedOutputFile, useSourceMaps);

@@ -96,3 +96,4 @@ process.exit(0);

inlineAndCompile(includes.slice(current, current + 1), {}, reporter,
inlineAndCompile(includes.slice(current, current + 1), traceur.options,
reporter,
function(tree) {

@@ -99,0 +100,0 @@ var outputFile = path.join(outputDir, includes[current]);

@@ -23,3 +23,3 @@ // Copyright 2012 Traceur Authors.

var ErrorReporter = traceur.util.ErrorReporter;
var InternalLoader = traceur.modules.internals.InternalLoader;
var Loader = traceur.modules.internals.Loader;
var LoaderHooks = traceur.modules.internals.LoaderHooks;

@@ -37,8 +37,6 @@ var Script = traceur.syntax.trees.Script;

*/
function InlineCodeLoader(reporter, url, elements, depTarget) {
var loaderHooks = new LoaderHooks(reporter, url);
loaderHooks.fileLoader = nodeLoader;
InternalLoader.call(this, loaderHooks);
function InlineLoaderHooks(reporter, url, elements, depTarget) {
LoaderHooks.call(this, reporter, url, undefined, nodeLoader);
this.dirname = url;
this.elements = elements;
this.dirname = url;
this.depTarget = depTarget && normalizePath(path.relative('.', depTarget));

@@ -48,12 +46,6 @@ this.codeUnitList = [];

InlineCodeLoader.prototype = {
__proto__: InternalLoader.prototype,
InlineLoaderHooks.prototype = {
__proto__: LoaderHooks.prototype,
evalCodeUnit: function(codeUnit) {
// Don't eval. Instead append the trees to the output.
var tree = codeUnit.transformedTree;
this.elements.push.apply(this.elements, tree.scriptItemList);
},
transformCodeUnit: function(codeUnit) {
evaluateCodeUnit: function(codeUnit) {
if (this.depTarget) {

@@ -64,5 +56,7 @@ console.log('%s: %s', this.depTarget,

}
// Don't eval. Instead append the trees to the output.
var tree = codeUnit.metadata.transformedTree;
this.elements.push.apply(this.elements, tree.scriptItemList);
},
return InternalLoader.prototype.transformCodeUnit.call(this, codeUnit);
}
};

@@ -93,24 +87,38 @@

var depTarget = options && options.depTarget;
var referrerName = options && options.referrer;
if (referrerName) {
// The compile occurs two directories down from current directory,
// in src/node. Thus the names will appear as eg ../src/x.
// We want something like referrerName/src/x. So we need to give
// the normalize() the 'package' or root name with src/node append
// to represent the referrer from here.
referrerName = referrerName && referrerName + 'src/node';
// The basePath will replace options.referrer in our final filename.
// Since we are in src/node, we need to back up two directories.
basePath = path.join(__dirname, '../../');
}
basePath = basePath.replace(/\\/g, '/');
var loadCount = 0;
var elements = [];
var loader = new InlineCodeLoader(reporter, basePath, elements, depTarget);
var hooks = new InlineLoaderHooks(reporter, basePath, elements, depTarget);
var loader = new Loader(hooks);
function loadNext() {
var codeUnit = loader.load(filenames[loadCount]);
codeUnit.addListener(function() {
loadCount++;
if (loadCount < filenames.length) {
loadNext();
} else if (depTarget) {
callback(null);
} else {
var tree = allLoaded(basePath, reporter, elements);
callback(tree);
}
}, function() {
console.error(codeUnit.error);
errback(codeUnit.error);
});
var codeUnit = loader.loadAsScript(filenames[loadCount],
{referrerName: referrerName},
function() {
loadCount++;
if (loadCount < filenames.length) {
loadNext();
} else if (depTarget) {
callback(null);
} else {
var tree = allLoaded(basePath, reporter, elements);
callback(tree);
}
}, function(err) {
errback(err);
});
}

@@ -120,20 +128,2 @@

}
function inlineAndCompileSync(filenames, options, reporter) {
// The caller needs to do a chdir.
var basePath = './';
var depTarget = options && options.depTarget;
var loadCount = 0;
var elements = [];
var loader = new InlineCodeLoader(reporter, basePath, elements, depTarget);
filenames.forEach(function(filename) {
filename = System.normalResolve(filename, basePath);
loader.loadSync(filename);
});
return allLoaded(basePath, reporter, elements);
}
exports.inlineAndCompile = inlineAndCompile;
exports.inlineAndCompileSync = inlineAndCompileSync;

@@ -19,16 +19,22 @@ // Copyright 2013 Traceur Authors.

var traceur = require('./traceur.js');
var nodeLoader = require('./nodeLoader.js');
function interpret(filename, argv, flags) {
var execArgv = [require.main.filename].concat(flags || []);
// Interpret the filename argument as a platform-independent,
// normalized module name.
var moduleName = filename.replace(/\\/g, '/').replace(/\.js$/,'');
filename = fs.realpathSync(filename);
process.argv = ['traceur', filename].concat(argv || []);
process.execArgv = process.execArgv.concat(execArgv);
if (traceur.options.deferredFunctions)
require('./deferred.js').wrap();
return traceur.require(filename);
// TODO(jjb): Should be system loader.
function getLoader() {
var LoaderHooks = traceur.modules.LoaderHooks;
var reporter = new traceur.util.ErrorReporter();
// Load dependencies as relative to the argument.
var loaderHooks = new LoaderHooks(reporter, moduleName, undefined,
nodeLoader);
return new traceur.modules.Loader(loaderHooks);
}
global.SystemLoader = getLoader();
global.SystemLoader.import(moduleName);
}
module.exports = interpret;

@@ -24,6 +24,2 @@ // Copyright 2013 Traceur Authors.

var nodeLoader = {
loadSync: function(url) {
return stripShebang(fs.readFileSync(url, 'utf8'));
},
load: function(url, callback, errback) {

@@ -30,0 +26,0 @@ fs.readFile(url, 'utf8', function(err, data) {

@@ -29,6 +29,2 @@ // Copyright 2012 Traceur Authors.

__proto__: traceur,
// Wrap in a getter to break cyclic dependencies.
get require() {
return require('./require.js');
}
};

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc