Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function babelifyPackage(destPkg) {
// Make a copy of the package's Babel configuration
const babelConfig = clone(project.transform.getBabelConfig(destPkg));
// Tune babel config
babelConfig.babelrc = false;
babelConfig.compact = false;
babelConfig.only = '**/*';
if (babelConfig.sourceMaps === undefined) {
babelConfig.sourceMaps = true;
}
// Report a copy of the package's Babel configuration before loading plugins
report.packageProcessBabelConfig(destPkg, clone(babelConfig));
// Intercept presets and plugins to load them from here
babelConfig.plugins = project.transform.getBabelPlugins(destPkg);
babelConfig.presets = [];
// Make a copy of the package's Babel configuration
const babelConfig = clone(project.transform.getBabelConfig(destPkg));
// Tune babel config
babelConfig.babelrc = false;
babelConfig.compact = false;
babelConfig.only = '**/*';
if (babelConfig.sourceMaps === undefined) {
babelConfig.sourceMaps = true;
}
// Report a copy of the package's Babel configuration before loading plugins
report.packageProcessBabelConfig(destPkg, clone(babelConfig));
// Intercept presets and plugins to load them from here
babelConfig.plugins = project.transform.getBabelPlugins(destPkg);
babelConfig.presets = [];
// Determine file globs
const globs = ['**/*.js', '!node_modules/**/*'];
if (destPkg.isRoot) {
globs.push(...gl.negate(project.transform.babelIgnores));
}
// Run babel through files
const prjRelPaths = findFiles(
project.dir.asNative,
gl.prefix(`${project.dir.asPosix}/${destPkg.dir.asPosix}/`, globs)
);
log.debug(
return new Promise((resolve, reject) => {
try {
const state = runPlugins(
phase === 'pre'
? project.transform.getPrePluginDescriptors(destPkg)
: project.transform.getPostPluginDescriptors(destPkg),
srcPkg,
destPkg,
{
pkgJson: readJsonSync(
destPkg.dir.join('package.json').asNative
),
},
(plugin, log) => {
report.packageProcessBundlerPlugin(
phase,
destPkg,
plugin,
log
);
if (log.errorsPresent) {
return new Promise((resolve, reject) => {
try {
const state = runPlugins(
phase === 'pre'
? project.transform.getPrePluginDescriptors(destPkg)
: project.transform.getPostPluginDescriptors(destPkg),
srcPkg,
destPkg,
{
pkgJson: readJsonSync(
destPkg.dir.join('package.json').asNative
),
},
(plugin, log) => {
report.packageProcessBundlerPlugin(
phase,
destPkg,
plugin,
log
);