Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

refactor(HMR): print caught error's message #760

Merged
merged 7 commits into from
Jan 9, 2019
Merged

Conversation

vchimev
Copy link
Contributor

@vchimev vchimev commented Jan 6, 2019

Print caught error's message on a module.hot.check() or a module.hot.apply() failure.

Also:

  • expose a latestHash variable in the hmr-update.js,
  • format properly the HMR_HANDLER snippet in bundles
  • add module context parameter default value
  • update module hot accept callback

PR Checklist

What is the current behavior?

Currently, if module.hot.check() or module.hot.apply() throws an error, the error's trace is printed.

What is the new behavior?

Print error's message if truthy, if not - print error's trace.

log.warn(err.stack || err.message);
// Do not modify message - CLI depends on this exact content to determine hmr operation status.
log.error(`Cannot apply update with hmr hash ${currentHash}.`);
log.error(err.message || err.stack);
Copy link
Contributor

Choose a reason for hiding this comment

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

Even better - print both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's needed - messages look descriptive enough, i.e.:

CONSOLE INFO file:///app/vendor.js:72111:36: HMR: Checking for updates to the bundle with hmr hash 1a369033d922096d2138.
CONSOLE WARN file:///app/vendor.js:72112:36: HMR: Ignored an update to unaccepted module:
CONSOLE WARN file:///app/vendor.js:72112:36: HMR:          ➭ ./main.ts
CONSOLE ERROR file:///app/vendor.js:72113:38: HMR: Cannot apply update with hmr hash 1a369033d922096d2138.
CONSOLE ERROR file:///app/vendor.js:72113:38: HMR: Aborted because ./main.ts is not accepted
Update propagation: ./main.ts

Copy link
Contributor

Choose a reason for hiding this comment

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

If you say so.

@vchimev vchimev requested a review from vakrilov January 9, 2019 11:59
@vchimev vchimev merged commit b582c65 into master Jan 9, 2019
@vchimev vchimev deleted the vchimev/err-hmr branch January 9, 2019 16:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants