Parcel: Proposal: console.clear() on HMR

Created on 24 Mar 2018  路  16Comments  路  Source: parcel-bundler/parcel

IT would be nice if console.clear() command would be executed on each HMR

What you think?

Good First Issue Feature RFC

Most helpful comment

Hi @davidnagli shall I take up the issue

All 16 comments

馃憤

馃憤

Hi @davidnagli shall I take up the issue

@DeMoorJasper What does HMR means and which file or module should I start looking for improvement?

@ameerthehacker HMR is Hot Module reload, it's the thing that refreshes the page content in the browser when saving a file.
Related file: https://github.com/parcel-bundler/parcel/blob/master/src/builtins/hmr-runtime.js

@DeMoorJasper thanks for the guidance I have made a pull request for this issue, do check it out and let me know if any improvement is needed from my side.

This will clear console output that the user's app posted, not things parcel posted. I don't necessarily think we should be clearing messages we don't own. People will definitely complain about this.

@devongovett then how can we differntiate between parcels messages and others messages. I think of a way like whenever something is logged in from console I will add it to an array with flag whether it was added by parcel and will clear the messages based on the flag.

Fixed by #1073

Thank you

Is there a way to disable this?

(it clears any console.log I might make in an express server using parcel as a middleware).

(it clears any console.log I might make in an express server using parcel as a middleware).

This is about the client (browser) side (after reading https://github.com/parcel-bundler/parcel/issues/355#issuecomment-480297826)

can you disable clearing the console? I load a file inside the webpage and then on each HMR I have to either re-add the file or create a special button for development to press every HMR cycle :/

a simple solution is to just:

delete console.clear

but that in turn gives you:

Uncaught TypeError: console.clear is not a function
    at WebSocket.ws.onmessage

on each HMR.

I'm not agree. This your special case. I suggest you to not use hmr

I get what you're saying! I totally agree that the whole behavior shouldn't be changed for this special case, I was only thinking about an option to disable the clearing as a command line argument or something, like parcel index.html --no-console-clear.

Or something like --verbose

Was this page helpful?
0 / 5 - 0 ratings