Skip to content

Commit dffeb7d

Browse files
pomledevongovett
authored andcommitted
Display absolute path on failed dependency resolve. (#271)
* Display absolute path on failed dependency resolve. When a file path can not be resolved the error message is cleaned up but the relative path to file is displayed. In cases where a mistake have been made this path can be very confusing, like `Cannot resolve dependency './../../../../../../main.js'` for when a path starts with `/`. This PR resolves attempted path into an absolute path in hope of reducing confusion and minimize cognitive overhead of `..` chasing. * Resolve absolute path relative to asset. * Log both relative name and absolute search path.
1 parent 9376ddd commit dffeb7d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/Bundler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ class Bundler extends EventEmitter {
274274
return await this.resolveAsset(dep.name, asset.name);
275275
} catch (err) {
276276
if (err.message.indexOf(`Cannot find module '${dep.name}'`) === 0) {
277-
err.message = `Cannot resolve dependency '${dep.name}'`;
277+
const absPath = Path.resolve(Path.dirname(asset.name), dep.name);
278+
err.message = `Cannot resolve dependency '${dep.name}' at '${absPath}'`;
278279

279280
// Generate a code frame where the dependency was used
280281
if (dep.loc) {

0 commit comments

Comments
 (0)