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

babel --watch should have equivalent file selection logic with babel #10283

Merged
merged 2 commits into from Dec 5, 2019

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jul 30, 2019

Q                       A
Fixed Issues? Fixes #10270
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Nope
Documentation PR Link
Any Dependency Changes?
License MIT

In this PR, we align file selection logic of --watch to one time building. In

filenames.forEach(function(filename) {
if (!fs.existsSync(filename)) return;
const stat = fs.statSync(filename);
if (stat.isDirectory()) {
const dirname = filename;
util
.readdirForCompilable(
filename,
cliOptions.includeDotfiles,
cliOptions.extensions,
)
.forEach(function(filename) {
_filenames.push(path.join(dirname, filename));
});
} else {
_filenames.push(filename);
}
});

The cli options --extensions is used to filter compilable files if the filename argument is a directory. However the watch logic excludes all non-compilable files even if it is specified in filename argument.

We also introduce minor performance tweak by passing disableGlobbing: true into chokidar as @babel/cli does not support globbing.

Fixture-based unit test does not work here since we need separate process to trigger a file change.

@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11266/

@JLHwung JLHwung added pkg: cli PR: Bug Fix 🐛 A type of pull request used for our changelog categories labels Aug 6, 2019
@nicolo-ribaudo
Copy link
Member

@JLHwung Could you rebase and merge?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: cli PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

babel --watch does initial compile but ignores changes when --extensions is missing
4 participants