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

Clear the console in browser on each HMR #1073

Merged
merged 5 commits into from
Apr 28, 2018

Conversation

ameerthehacker
Copy link
Contributor

What was missing ?

Whenever there was an HRM the console in the browser had old logging data #1064

What I have added ?

I have modified the hmr-runtime.js file to include a console.clear() statement to clear the console whenever there is an HRM

Little workaround I used

If I used console.clear() some of the test were breaking complaining that Error: TypeError console.clear function is undefined I think that the testing environment does not support console.clear() function so I replaced the statement in such a way that it will be called only if it is supported.

console.clear && console.clear()

@codecov-io
Copy link

codecov-io commented Mar 26, 2018

Codecov Report

Merging #1073 into master will increase coverage by 1.3%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #1073     +/-   ##
=========================================
+ Coverage   88.64%   89.94%   +1.3%     
=========================================
  Files          71       71             
  Lines        3504     3660    +156     
=========================================
+ Hits         3106     3292    +186     
+ Misses        398      368     -30
Impacted Files Coverage Δ
src/assets/GlobAsset.js 58.66% <0%> (-40%) ⬇️
src/assets/WebManifestAsset.js 59.18% <0%> (-19.39%) ⬇️
src/assets/JSONAsset.js 84.61% <0%> (-8.72%) ⬇️
src/assets/CSSAsset.js 73.04% <0%> (-8.7%) ⬇️
src/assets/SASSAsset.js 91.66% <0%> (-8.34%) ⬇️
src/assets/LESSAsset.js 93.18% <0%> (-6.82%) ⬇️
src/assets/StylusAsset.js 81.01% <0%> (-5.04%) ⬇️
src/assets/TypeScriptAsset.js 97.14% <0%> (-2.86%) ⬇️
src/utils/serializeObject.js 88.23% <0%> (-1.77%) ⬇️
src/utils/syncPromise.js 100% <0%> (ø) ⬆️
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ddaec9...57c0304. Read the comment docs.

@@ -32,6 +32,9 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
hmrAccept(global.require, asset.id);
}
});
// Clear the console after HMR
// Check if console.clear function is supported, absence of this caused tests to fail
console.clear && console.clear();
Copy link
Member

@DeMoorJasper DeMoorJasper Mar 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to use a mock function for the tests like I explained in #1074
This way you could also make the tests test if it actually happens

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure @DeMoorJasper I will use a mock function to fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @DeMoorJasper I have mocked the function console.clear() in test

@ameerthehacker
Copy link
Contributor Author

@DeMoorJasper I have done the changes you requested please do review

@ameerthehacker
Copy link
Contributor Author

@DeMoorJasper Is there anything else I need to do to get my pull request merged

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Mar 30, 2018

@ameerthehacker No it should be fine, but as in the discussion it might not get merged as some developers might not want parcel clearing their console.
Will see how the RFC progresses

@ameerthehacker
Copy link
Contributor Author

@DeMoorJasper that is great

@devongovett devongovett merged commit 1a688cd into parcel-bundler:master Apr 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants