cli: handle multiple input sources in watch mode#14281
cli: handle multiple input sources in watch mode#14281nicolo-ribaudo merged 4 commits intobabel:mainfrom
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/51335/ |
|
|
||
| setTimeout(() => { | ||
| console.error("EXECUTOR TIMEOUT"); | ||
| process.exit(1); |
There was a problem hiding this comment.
We could replace exit(1) with exit(0) in all the watch tests and use .log instead of .error, to see at which point they get stuck.
There was a problem hiding this comment.
Good idea! I can't reproduce the timeout error on my local machine, now I have to abuse GitHub CI to see what happens.
| logFile("lib/main.js"); | ||
|
|
||
| // wait 200ms for watcher setup | ||
| await new Promise(resolve => setTimeout(resolve, 200)); |
| // A map from absolute compiled file path to its base, from which | ||
| // the output destination will be determined | ||
| const filenameToBaseMap: Map<string, string> = new Map( | ||
| filenames.map(filename => { |
There was a problem hiding this comment.
I was wondering whether these could be globs or not, but they are already resolved at
babel/packages/babel-cli/src/babel/options.ts
Lines 192 to 197 in 1937284
There was a problem hiding this comment.
Yes they are resolved prior to watch setup, which means if you run babel */src --watch and then create a new folder module3/src, it will not be added to the watcher.
|
Interesting, tests are still failing even if I invoke initial build after the watcher claims ready: https://github.com/babel/babel/actions/runs/1866868095 I have revert this commit and will explore it in another PR. What a flaky test. Test is passing on my fork: https://github.com/JLHwung/babel/runs/5254435895 |
In this PR we fix a regression introduced in #14065. Currently we registered multiple listeners for each
--srcparameter, however, each listeners will be invoked unconditionally even only one of file specified by some--srcparameter are changed. Thereforebabel-clicreates multiple compilation and, which is worse, outputs compiled files on unwanted paths.In this PR we determine the input base from the filename when multiple
--srcparameters are specified. A cache is introduced to avoid repeatedly searching--srcparameters.