*feature* Throw Error with missing module name instead of “Cannot read property ‘call’ of undefined”

webpack 2.2.0.rc.0 and earlier

We’ve all gotten missing module errors due to various mis-configurations, commons chunks juggling etc. ( See #959 for many of them )

The problem is that we don’t know which module is missing, just moduleId=47

This line is a common failure point:

      // Execute the module function
        /******/
        modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));

In development mode I think it would be worthwhile to include a map of module ids to names so that an error can be thrown here with the name of the missing module.

I can open http://localhost:3000/__webpack_hmr and look it up "47":"./~/jquery/dist/jquery.js" but it took me a long time to figure that out.

Author: Fantashit

1 thought on “*feature* Throw Error with missing module name instead of “Cannot read property ‘call’ of undefined”

  1. Something like:

    var m = modules[moduleId];
    if (typeof m === 'undefined') {
     throw new Error(`Module ${moduleId} not found`);
    }
    m.call(module.exports, ... )

Comments are closed.