Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix watch config #12372

Merged
merged 1 commit into from Nov 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 15 additions & 4 deletions Gulpfile.js
Expand Up @@ -22,8 +22,19 @@ const { terser: rollupTerser } = require("rollup-plugin-terser");

const defaultSourcesGlob = "./@(codemods|packages|eslint)/*/src/**/*.{js,ts}";

function swapSrcWithLib(srcPath) {
const parts = srcPath.split(path.sep);
/**
* map source code path to the generated artifacts path
* @example
* mapSrcToLib("packages/babel-core/src/index.js")
* // returns "packages/babel-core/lib/index.js"
* @example
* mapSrcToLib("packages/babel-template/src/index.ts")
* // returns "packages/babel-template/lib/index.js"
* @param {string} srcPath
* @returns {string}
*/
function mapSrcToLib(srcPath) {
const parts = srcPath.replace(/\.ts$/, ".js").split(path.sep);
parts[2] = "lib";
return parts.join(path.sep);
}
Expand Down Expand Up @@ -72,7 +83,7 @@ function buildBabel(exclude, sourcesGlob = defaultSourcesGlob) {

return stream
.pipe(errorsLogger())
.pipe(newer({ dest: base, map: swapSrcWithLib }))
.pipe(newer({ dest: base, map: mapSrcToLib }))
.pipe(compilationLogger())
.pipe(
babel({
Expand All @@ -85,7 +96,7 @@ function buildBabel(exclude, sourcesGlob = defaultSourcesGlob) {
.pipe(
// Passing 'file.relative' because newer() above uses a relative
// path and this keeps it consistent.
rename(file => path.resolve(file.base, swapSrcWithLib(file.relative)))
rename(file => path.resolve(file.base, mapSrcToLib(file.relative)))
)
.pipe(gulp.dest(base));
}
Expand Down