Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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(
`Babelifying ${prjRelPaths.length} files in package '${destPkg.id}'...`
);
return runInChunks(
prjRelPaths,
project.misc.maxParallelFiles,
0,
prjRelPath => babelifyFile(destPkg, prjRelPath, babelConfig)
);
}
function processPackage(srcPkg) {
log.debug(`Applying rules to package '${srcPkg.id}'...`);
const sourceGlobs = srcPkg.isRoot
? project.sources.map(source =>
fs.statSync(project.dir.join(source).asNative).isDirectory()
? `${source.asPosix}/**/*`
: source.asPosix
)
: ['**/*'];
const globs = [...sourceGlobs, '!node_modules/**/*'];
const sourcePrjRelPaths = findFiles(
project.dir.asNative,
gl.prefix(`${project.dir.asPosix}/${srcPkg.dir.asPosix}/`, globs)
);
const destPkg = srcPkg.clone({
dir: getDestDir(srcPkg),
});
return runInChunks(
sourcePrjRelPaths,
project.misc.maxParallelFiles,
0,
prjRelPath => processFile(srcPkg, destPkg, prjRelPath)
);
}
dir: getDestDir(srcPkg),
});
if (!manifest.isOutdated(destPkg)) {
return Promise.resolve();
}
log.debug(`Copying package '${srcPkg.id}'...`);
srcPkg.clean = false;
const srcPkgRelPaths = srcPkg.isRoot
? ['package.json']
: findFiles(
project.dir.join(srcPkg.dir).asNative,
gl.prefix(`${project.dir.asPosix}/${srcPkg.dir.asPosix}/`, [
`**/*`,
`!node_modules/**/*`,
])
);
const srcPkgRelPathsToCopy = srcPkg.isRoot
? srcPkgRelPaths
: runCopyPlugins(
srcPkg,
destPkg,
findFiles(
project.dir.join(srcPkg.dir).asNative,
gl.prefix(`${project.dir.asPosix}/${srcPkg.dir.asPosix}/`, [
`**/*`,
`!node_modules/**/*`,
...gl.negate(project.copy.getExclusions(srcPkg)),
: findFiles(
project.dir.join(srcPkg.dir).asNative,
gl.prefix(`${project.dir.asPosix}/${srcPkg.dir.asPosix}/`, [
`**/*`,
`!node_modules/**/*`,
])
);
const srcPkgRelPathsToCopy = srcPkg.isRoot
? srcPkgRelPaths
: runCopyPlugins(
srcPkg,
destPkg,
findFiles(
project.dir.join(srcPkg.dir).asNative,
gl.prefix(`${project.dir.asPosix}/${srcPkg.dir.asPosix}/`, [
`**/*`,
`!node_modules/**/*`,
...gl.negate(project.copy.getExclusions(srcPkg)),
])
)
);
report.packageCopy(srcPkg, srcPkgRelPaths, srcPkgRelPathsToCopy);
if (srcPkgRelPathsToCopy.length === 0) {
srcPkg.clean = true;
}
return Promise.all(
srcPkgRelPathsToCopy.map(srcPkgRelPath =>
copyFile(srcPkg, destPkg, srcPkgRelPath)