HarmonyImportDependency should throw during build for missing module

Do you want to request a feature or report a bug?

What is the current behavior?
Inlines a throw statement into a bundle when a module is missing

If the current behavior is a bug, please provide the steps to reproduce.

  1. Clone this repository
  2. Run npm install
  3. Run npm start
  4. Open dist/bundle.js and grep for Cannot find module

What is the expected behavior?
My expectation is that webpack would throw at build time, instead of inlining code to throw at runtime, when a module cannot be found. This would be an easy to miss bug if the throw statement is in a chunk that doesn’t happen to be covered by E2E or manual testing.

If this is a feature request, what is motivation or use case for changing the behavior?
Would make it easier to catch cases where a module can’t be found

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
This happens in the latest webpack stable at the time of writing (3.10.0).

I’m trying to figure out if there was a specific reason that this behavior needed to happen at run-time, or if this was just overlooked.

This is related to #4959, but it’s likely other bugs could cause this same problem (anytime dep.module is falsy), so I think this merits being tracked separately.

Author: Fantashit

1 thought on “HarmonyImportDependency should throw during build for missing module

  1. One thing, how would this work with watch mode if we completely threw?

    I guess maybe I should rephrase “throw at build time” to “report a module error”. IOW, like webpack does today for mistyped paths or missing dependencies.

    ERROR in ./src/index.js
    Module not found: Error: Can't resolve 'someModuleIdentifier'

Comments are closed.