Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
transform: function (content, filename) {
// Make sure to only transform your code or the dependencies you want
if (filename.indexOf('lib') >= 0) {
var result = Babel.transform(content, {
sourceMap: 'inline',
filename: filename,
sourceFileName: filename
});
return result.code;
}
return content;
}
}
filename: event.path,
sourceMap: true,
moduleIds: true
}
if (opts.modules === 'amd') {
var modulePath = event.projectPath.replace(/\.js$/, '')
if (opts.getModulePath)
modulePath = opts.getModulePath(modulePath)
babelOpts.moduleId = modulePath
}
// if (event.basePath)
// babelOpts.filenameRelative = event.basePath
var result = babel.transform(event.data, babelOpts)
return _.pick(result, 'code', 'map')
}
}
Autod.prototype.parseFile = function (filePath) {
var file;
try {
file = fs.readFileSync(filePath, 'utf-8');
file = babel.transform(file, { ast: false }).code || '';
} catch (err) {
this.emit('warn', util.format('Read(or transfrom) file %s error', filePath));
return [];
}
var modules = [];
var self = this;
crequire(file).forEach(function (r) {
var parsed = MODULE_REG.exec(r.path);
if (!parsed) {
return;
}
var scope = parsed[1];
var name = parsed[2];
if (scope) {
name = scope + name;
transform: function (content, filename) {
if (filename.indexOf('node_modules') === -1) {
var options = {
sourceMap: 'inline',
filename: filename,
sourceFileName: filename
};
var result = Babel.transform(content, options);
return result.code;
}
return content;
}
}];
transform: function (context) {
var options = _.defaults({}, context.compileOptions, defaultCompileOptions);
var babelrc = context.preview.files['.babelrc'];
if (typeof babelrc !== 'undefined') {
try {
babelrc = JSON.parse(babelrc);
_.extend(options, babelrc);
} catch (__) {}
}
try {
var result = Compiler.transform(context.sourceContent, options);
return result.code;
} catch (err) {
context.preview.log({
source: 'babel',
data: err,
});
throw new Boom.badRequest('Compilation failed: ' + err.message, err);
}
}
};
function convertToES5(code) {
return babel.transform(
code, {
loose: true,
stage: 0,
blacklist: ['es6.modules', 'useStrict']
});
}
es6: function(js) {
return require('babel').transform(js, { blacklist: ['useStrict'] }).code
},
coffee: function(js) {
module.exports = function processor(content, attrs, scope) {
if (!content) {
return content;
}
return babel.transform(content, {
filename: scope.getDirname()
}).code;
};
var out = function (svg) {
var source = render(filename, svg.data),
output = babel.transform(source, settings.babel);
var replaceAttribute = function (a, str) {
switch (str) {
case 'class':
return 'className';
default:
return str.replace(/-(.)/g, function (_, letter) {
return letter.toUpperCase();
});
}
};
output.code = output.code.replace(/\"(class|clip-path|fill-opacity|font-family|font-size|marker-end|marker-mid|marker-start|stop-color|stop-opacity|stroke-width|stroke-linecap|stroke-dasharray|stroke-opacity|text-anchor)\"/g, replaceAttribute);
stream.queue(output.code);
this.watch(["src/*.js"].concat(excluded), function*(filePath, ev, match) {
var outputPath = filePath.replace(/^src\//, "lib/");
var outputDir = path.dirname(outputPath);
if (!(yield* fsutils.exists(outputDir))) {
yield* fsutils.mkdirp(outputDir);
}
var contents = yield* fsutils.readFile(filePath);
var result = babel.transform(contents, { blacklist: ["regenerator", "es6.constants", "es6.blockScoping"] });
yield* fsutils.writeFile(outputPath, result.code);
}, "babel");