question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HarmonyImportDependency should throw during build for missing module

See original GitHub issue

Do you want to request a feature or report a bug? 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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
DrewMLcommented, Jan 26, 2018

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'
0reactions
sokracommented, Sep 27, 2019

Has been fixed

Read more comments on GitHub >

github_iconTop Results From Across the Web

webpack try to require a module that might be missing
You can do it by using webpack's special require: __ webpack_require__ which won't be parsed at build time, and will become a regular...
Read more >
Error handling in Node.js - LogRocket Blog
While building production-ready software, we need to manage errors effectively to: ... and when you throw an error, it becomes an exception.
Read more >
webpack: Versions | Openbase
fix RemoteModules when using HMR (Module Federation + HMR); throw error when using module ... Values no longer need to be defined as...
Read more >
8. Errors and Exceptions — Python 3.11.1 documentation
Errors detected during execution are called exceptions and are not unconditionally fatal: you will soon learn how to handle them in Python programs....
Read more >
rollup.js
This allows you to build on top of existing tools and modules without adding extra dependencies ... Rollup should typically be used from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found