Comparing version 0.0.79 to 0.0.80
{ | ||
"name": "traceur", | ||
"version": "0.0.79", | ||
"version": "0.0.80", | ||
"description": "ES6 to ES5 compiler", | ||
@@ -49,3 +49,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"source-map": "0.1.34", | ||
"source-map": "0.1.43", | ||
"express": "4.x", | ||
@@ -58,4 +58,3 @@ "serve-index": "1.x", | ||
"requirejs": "2.x", | ||
"semver": "2.x", | ||
"traceur": "0.0.78", | ||
"traceur": "0.0.79", | ||
"promises-aplus-tests": "2.x" | ||
@@ -62,0 +61,0 @@ }, |
@@ -57,3 +57,4 @@ // Copyright 2013 Traceur Authors. | ||
amdOptions: Compiler.amdOptions, | ||
closureOptions: Compiler.closureOptions, | ||
RUNTIME_PATH: RUNTIME_PATH | ||
}; |
@@ -60,4 +60,5 @@ // Copyright 2014 Traceur Authors. | ||
this.writeTreeToFile(this.transform( | ||
this.parse(contents.toString(), inputFilePath)), outputFilePath); | ||
var parsed = this.parse(contents.toString(), inputFilePath); | ||
this.writeTreeToFile(this.transform(parsed, undefined, inputFilePath), | ||
outputFilePath); | ||
}.bind(this)); | ||
@@ -64,0 +65,0 @@ }, |
@@ -32,34 +32,30 @@ // Copyright 2012 Traceur Authors. | ||
function recursiveModuleCompileToSingleFile(outputFile, includes, options) { | ||
return new Promise(function(resolve, reject) { | ||
var resolvedOutputFile = path.resolve(outputFile); | ||
var outputDir = path.dirname(resolvedOutputFile); | ||
var resolvedOutputFile = path.resolve(outputFile); | ||
var outputDir = path.dirname(resolvedOutputFile); | ||
// Resolve includes before changing directory. | ||
var resolvedIncludes = includes.map(function(include) { | ||
include.name = path.resolve(include.name); | ||
return include; | ||
}); | ||
// Resolve includes before changing directory. | ||
var resolvedIncludes = includes.map(function(include) { | ||
include.name = path.resolve(include.name); | ||
return include; | ||
}); | ||
var compiler = new NodeCompiler(options); | ||
var compiler = new NodeCompiler(options); | ||
mkdirRecursive(outputDir); | ||
process.chdir(outputDir); | ||
mkdirRecursive(outputDir); | ||
process.chdir(outputDir); | ||
// Make includes relative to output dir so that sourcemap paths are correct. | ||
resolvedIncludes = resolvedIncludes.map(function(include) { | ||
include.name = normalizePath(path.relative(outputDir, include.name)); | ||
return include; | ||
}); | ||
// Make includes relative to output dir so that sourcemap paths are correct. | ||
resolvedIncludes = resolvedIncludes.map(function(include) { | ||
include.name = normalizePath(path.relative(outputDir, include.name)); | ||
return include; | ||
}); | ||
recursiveModuleCompile(resolvedIncludes, options, function(tree) { | ||
compiler.writeTreeToFile(tree, resolvedOutputFile); | ||
revertCwd(); | ||
resolve(); | ||
}, function() { | ||
revertCwd(); | ||
reject.apply(null, arguments); | ||
}); | ||
}); | ||
return recursiveModuleCompile(resolvedIncludes, options) | ||
.then(function(tree) { | ||
compiler.writeTreeToFile(tree, resolvedOutputFile); | ||
}).then(revertCwd, function(err) { | ||
revertCwd(); | ||
throw err; | ||
}); | ||
} | ||
@@ -71,21 +67,12 @@ | ||
var current = 0; | ||
function next() { | ||
if (current === includes.length) | ||
process.exit(0); | ||
recursiveModuleCompile(includes.slice(current, current + 1), options, | ||
function(tree) { | ||
var outputFileName = path.join(outputDir, includes[current].name); | ||
compiler.writeTreeToFile(tree, outputFileName); | ||
current++; | ||
next(); | ||
}, | ||
function(err) { | ||
process.exit(1); | ||
}); | ||
} | ||
next(); | ||
Promise.all(includes.map(function(input) { | ||
return recursiveModuleCompile([input], options).then(function(tree) { | ||
var outputFileName = path.join(outputDir, input.name); | ||
compiler.writeTreeToFile(tree, outputFileName); | ||
}); | ||
})).then(function() { | ||
process.exit(0); | ||
}, function() { | ||
process.exit(1); | ||
}); | ||
} | ||
@@ -97,2 +84,20 @@ | ||
/** | ||
* Chains .then() calls along a list after applying a function. The function | ||
* is not called on a value in the list until the promise generated by calling | ||
* the function on the previous value in the list completes. | ||
* | ||
* @param {Array.<T>} list | ||
* @param {function(T): Promise<?>} f A function applied to each item on the | ||
* list. | ||
* @return {Promise<?>} A promise where each promise f(v), for each v in the | ||
* list has completed. | ||
*/ | ||
function sequencePromises(list, f) { | ||
var result = Promise.resolve(); | ||
list.forEach(function (item) { | ||
result = result.then(function() { return f(item); }); | ||
}); | ||
return result; | ||
} | ||
@@ -102,3 +107,2 @@ /** | ||
* into a single js file, in module dependency order. | ||
* TODO: Make this function also use a promise | ||
* | ||
@@ -115,4 +119,3 @@ * @param {Array.<Object>} fileNamesAndTypes The list of {name, type} | ||
*/ | ||
function recursiveModuleCompile(fileNamesAndTypes, options, callback, errback) { | ||
function recursiveModuleCompile(fileNamesAndTypes, options) { | ||
var depTarget = options && options.depTarget; | ||
@@ -124,3 +127,2 @@ var referrerName = options && options.referrer; | ||
var loadCount = 0; | ||
var elements = []; | ||
@@ -131,3 +133,3 @@ var loaderCompiler = new InlineLoaderCompiler(elements); | ||
function appendEvaluateModule(name, referrerName) { | ||
function appendEvaluateModule(name) { | ||
var normalizedName = | ||
@@ -141,6 +143,5 @@ traceur.ModuleStore.normalize(name, referrerName); | ||
function loadNext() { | ||
function loadInput(input) { | ||
var doEvaluateModule = false; | ||
var loadFunction = loader.import; | ||
var input = fileNamesAndTypes[loadCount]; | ||
var name = input.name; | ||
@@ -152,8 +153,6 @@ | ||
loadFunction = loader.loadAsScript; | ||
} else { | ||
if (input.format === 'inline') | ||
optionsCopy.modules = 'inline'; | ||
else if (optionsCopy.modules === 'register') | ||
doEvaluateModule = true; | ||
} else if (optionsCopy.modules === 'register') { | ||
doEvaluateModule = true; | ||
} | ||
var loadOptions = { | ||
@@ -163,27 +162,20 @@ referrerName: referrerName, | ||
}; | ||
var codeUnit = loadFunction.call(loader, name, loadOptions).then( | ||
function() { | ||
if (doEvaluateModule) | ||
appendEvaluateModule(name, referrerName); | ||
loadCount++; | ||
if (loadCount < fileNamesAndTypes.length) { | ||
loadNext(); | ||
} else if (depTarget) { | ||
callback(null); | ||
} else { | ||
var tree = loaderCompiler.toTree(basePath, elements); | ||
callback(tree); | ||
} | ||
}, function(err) { | ||
errback(err); | ||
}).catch(function(ex) { | ||
console.error('Internal error ' + (ex.stack || ex)); | ||
}); | ||
return loadFunction.call(loader, name, loadOptions).then(function() { | ||
if (doEvaluateModule) { | ||
appendEvaluateModule(name); | ||
} | ||
}); | ||
} | ||
loadNext(); | ||
return sequencePromises(fileNamesAndTypes, loadInput).then(function() { | ||
if (depTarget) { | ||
return null; | ||
} else { | ||
return loaderCompiler.toTree(); | ||
} | ||
}); | ||
} | ||
exports.recursiveModuleCompile = recursiveModuleCompile; | ||
exports.recursiveModuleCompileToSingleFile = recursiveModuleCompileToSingleFile; | ||
exports.forEachRecursiveModuleCompile = forEachRecursiveModuleCompile; |
@@ -33,4 +33,4 @@ // Copyright 2014 Traceur Authors. | ||
evaluateCodeUnit: function(codeUnit) { | ||
var result = | ||
module._compile(codeUnit.metadata.transcoded, codeUnit.address); | ||
var result = module._compile(codeUnit.metadata.transcoded, | ||
codeUnit.address || codeUnit.normalizedName); | ||
codeUnit.metadata.transformedTree = null; | ||
@@ -37,0 +37,0 @@ return result; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
10
10
41103
19
1047
1