Parcel CLI has an option '--open' which enables to opens bundled file with a browser automatically. However, if you stopped the HMR server with Ctrl + C, that tab does not close automatically, and then you have to close the tab manually.
When the websocket to the HMR server has disconnected, current browser tab closes automatically.
Browser tab remains and you have to close it manually.
See the implementation of suan/instant-markdown-d
$ cd /your/project/root/
$ ./node_modules/.bin/parcel --open firefox --target browser index.html
And press Ctrl + C. You can see the browser tab opened by parcel command does not close automatically.
I would like to work on this but, how it is possible to execute window.close(); from the server side?
I'm not really convinced this is a helpful feature (would be rather unexpected).
Regarding implementation: The HMR server would need to emit a new event type ("close?") and the hmr runtime would then execute window.close: https://github.com/parcel-bundler/parcel/blob/ee0acf2a384c39ff8d04bcb66c8acd60a79edf22/packages/core/parcel-bundler/src/builtins/hmr-runtime.js#L67
AH, I got it Thanks! I will try to submit PR :)
This could only be a helpful feature if provided as an option and not a default, e.g. --autoclose
Most helpful comment
This could only be a helpful feature if provided as an option and not a default, e.g.
--autoclose