-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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-cli: add --skip-initial-build option to only compile on changes when watching #3489
Conversation
Do you happen to know if there's precedent for a flag like this with any other tools? Babel can't be the only tool where this is an issue. I don't have a problem with this flag, but I feel like it'd be clearer with a name like "--skip-initial-build` |
@loganfsmyth this is similar (in spirit) to the As far as the name is concerned, |
If we're going to think about nodemon, we might want to handle removal of files too. Babel's Currently I use three package.json scripts to handle it: {
"build": "rimraf dest && babel src -d dest",
"start": "npm run build && node dest",
"watch": "nodemon -w src -x npm start"
} But it recompiles the entire app every time something changes, which is not ideal. |
Current coverage is 87.83%@@ master #3489 diff @@
==========================================
Files 194 194
Lines 10128 10128
Methods 1537 1537
Messages 0 0
Branches 2247 2247
==========================================
Hits 8895 8895
Misses 1233 1233
Partials 0 0
|
I'm not sure why this had such major coverage impact |
1f762c1
to
cec8e43
Compare
@@ -61,7 +61,9 @@ module.exports = function (commander, filenames) { | |||
} | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Babel is generally pretty strict about arguments. It would be good to show an error if commander.skipInitialBuild
is true but commander.watch
is false.
We should also squash these commits before landing this. |
cec8e43
to
b3585b5
Compare
b3585b5
to
4bf6f8a
Compare
Thanks! |
Currently, the
-w
option would build the files, and then keep the process running, recompiling the files on changes.Consider this 'watch' workflow:
This causes 2 problems:
nodemon dest/server
can start before babel finishes compilation ofdist/
and restart the server on initialization multiple times.Let's compile the files before starting the watch commands:
This solves the first problem, however now we are recompiling things twice, which causes nodemon to flap.
We can solve all that with
sleep
, but that's far from ideal.Instead, lets introduce
--just-watch
:This way nodemon always starts cleanly.