Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
contents = contents.replace(IMPORT_RE, function (match, obj, includePath) {
if (!MODULE_LOCATIONS[includePath]) {
imports.push(match);
return '';
}
var inlineFilePath = path.join(dir, MODULE_LOCATIONS[includePath]);
console.log(dir, inlineFilePath);
if (inlineFilePath.substr(-3) !== '.js') {
inlineFilePath += '.js';
}
return 'var ' + obj + '=' + inlineModule(inlineFilePath) + ';';
});
var services = imports.map(getParts).map(serviceify);
contents = traceur.compile(contents, TRACEUR_OPTS);
return detraceurify(unwrapify(contents, services));
}
function loadModule(filepath, transpile) {
var data = fs.readFileSync(filepath, 'utf8');
if (!data) {
throw new Error('Failed to import ' + filepath);
}
if (transpile) {
var moduleName = path.normalize(filepath)
.replace(__dirname, 'transpiler')
.replace(/\\/g, '/')
.replace(/\.\w*$/, '');
data = traceur.compile(data, SELF_COMPILE_OPTIONS, moduleName);
}
('global', eval)(data);
}
TraceurFilter.prototype.processString = function (str, relativePath) {
try {
return traceur.compile(str, this.options, relativePath);
} catch (errs) {
throw errs.join('\n');
}
};
compile: function (code) {
return traceur.compile(code, {
modules: "commonjs",
experimental: true
});
}
},
module.exports = function transpile(src, options) {
var compiled = compile(src, defaults(options, traceurOptions))
return compiled
}
fn: function ( code, filename, type ) {
return traceur.compile( code, {
filename: filename,
modules: type,
sourceMaps: false
}).js;
},
after: function () {
File.readdirSync('src').forEach(function(filename) {
var source = File.readFileSync('src/' + filename, 'utf8');
var options = {
blockBinding: true,
sourceMaps: true,
modules: 'commonjs',
filename: filename
};
var output = Traceur.compile(source, options);
if (output.errors.length) {
throw new Error(output.errors.join('\n'));
} else {
var clean = output.js.replace("module.exports = {};", "");
File.writeFileSync('lib/' + filename, clean, 'utf8');
grunt.log.ok('src/' + filename + ' => lib/' + filename);
}
});
});
var transpile = q.fbind(function (contents, filename) {
var transpiled = traceur.compile(contents, {
filename: filename,
modules: "inline"
});
return runtimeContents + transpiled;
});