Skip to content

Differentiate Save vs. Change? #12

Description

@ericclemmons

I just introduced this to a (personal) project and was trying to figure out how to tell if the module has actually changed:

watching[path] = watch(path, { persistent: false }, function(eventType, filename) {

Traditionally, webpack generates a hash for the file contents so that, even if HMR fires on the client, there's a way to tell (via the websocket payload) what the current hash is.

(By comparing the previous hash vs. the current hash for a module, you can determine if there have been any changes, or if the user simple saved twice)

Now, why is this important?

Sometimes HMR can get into a bad state, in which case I've been using double-save to reload the server/client/browser.

Unfortunately, I can't tell what file prompted to HMR, since this line is called with path instead of filename:

parent.hot._acceptedDependencies[path](path);


What would you recommend I do to differentiate changes vs. saved?

My first thought was to change the call to:

 // Send the accepted path & the file that triggered the change
 parent.hot._acceptedDependencies[path](path, filename);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions