Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.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
compileErrors += e.stack + '\n' + relFile + ': Unable to transpile ES Module\n';
}
})
(function () {
try {
load.kind = 'declarative';
var options = load.metadata.traceurOptions || {};
options.modules = 'instantiate';
var compiler = new traceur.Compiler(options);
var tree = compiler.parse(load.source, load.address);
depsList = getImports(tree);
tree = compiler.transform(tree);
source = compiler.write(tree);
var sourceMap = compiler.getSourceMap();
if (global.btoa && sourceMap)
source += '\n//# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(sourceMap))) + '\n';
__eval(source, global, load);
}
catch(e) {
if (e.name == 'SyntaxError' || e.name == 'TypeError')
e.message = 'Evaluating ' + (load.name || load.address) + '\n\t' + e.message;
throw e;
}
function remap(source, map, fileName) {
var compiler = new traceur.Compiler();
var tree = compiler.parse(source, fileName);
tree = new TraceurImportNormalizeTransformer(map).transformAny(tree);
return Promise.resolve({
source: compiler.write(tree)
});
}
exports.remap = remap;
function remap(source, map, fileName) {
var compiler = new traceur.Compiler();
var tree = compiler.parse(source, fileName);
tree = new TraceurImportNormalizeTransformer(map).transformAny(tree);
return Promise.resolve({
source: compiler.write(tree)
});
}
exports.remap = remap;
return Promise.all(Object.keys(trace).map(function(name) {
var load = trace[name];
if (load.deferredImports) {
deferredImports = deferredImports.concat(load.deferredImports);
return;
}
var curDeferredImports = [];
if (!load || load.conditional)
return;
var compiler = new traceur.Compiler({ script: load.metadata.format !== 'esm' });
var tree = compiler.parse(load.source, load.path);
var transformer = new DeferredImportsTransformer();
tree = transformer.transformAny(tree);
return Promise.all(transformer.imports.map(function(impt) {
return builder.loader.normalize(impt)
.then(function(moduleName) {
var canonical = getCanonicalName(builder.loader, moduleName);
curDeferredImports.push({
name: canonical,
parent: name
});
function precompile(inFile, outFile, basePath, callback) {
if (!traceurConfig) {
loadConfig();
}
traceurConfig.moduleName = null;
var compiler = new traceur.Compiler(traceurConfig);
var sourceMapFile = outFile.replace(/\.js$/, '.map');
fs.readFile(path.resolve(basePath, inFile), function(err, inSource) {
if (err)
return callback(err);
var source, sourceMap;
try {
source = compiler.compile(inSource.toString(), '/' + inFile, path.basename(outFile));
sourceMap = compiler.getSourceMap();
}
catch(e) {
return callback(e);
}
function remap(source, map, fileName) {
var compiler = new traceur.Compiler();
var tree = compiler.parse(source, fileName);
tree = new TraceurImportNormalizeTransformer(map).transformAny(tree);
return Promise.resolve({
source: compiler.write(tree)
});
}
exports.remap = remap;