broccolijs / broccoli

Browser compilation library – an asset pipeline for applications that run in the browser
https://broccoli.build
MIT License
3.33k stars 217 forks source link

checkInputPathsExist errors are unhelpful #438

Open rwjblue opened 4 years ago

rwjblue commented 4 years ago

When you have either a WatchedDir or plain string as an input node for a plugin and that directory does not exist we throw an error here:

https://github.com/broccolijs/broccoli/blob/b684378e3328821fbafe0f72f69582b5961521a5/lib/builder.js#L270-L283

Unfortunately, that error message is pretty useless:

  BuilderError: Directory not found: addon/styles
    at Builder.checkInputPathsExist (/Users/rjackson/sandbox/zenunu/node_modules/broccoli/dist/builder.js:241:23)
    at new Builder (/Users/rjackson/sandbox/zenunu/node_modules/broccoli/dist/builder.js:58:14)
    at Builder.setupBroccoliBuilder (/Users/rjackson/sandbox/zenunu/node_modules/ember-cli/lib/models/builder.js:84:22)
    at new Builder (/Users/rjackson/sandbox/zenunu/node_modules/ember-cli/lib/models/builder.js:32:10)
    at BuildTask.run (/Users/rjackson/sandbox/zenunu/node_modules/ember-cli/lib/tasks/build.js:15:19)
    at Promise.resolve.then (/Users/rjackson/sandbox/zenunu/node_modules/ember-cli/lib/models/command.js:239:24)
    at tryCatcher (/Users/rjackson/sandbox/zenunu/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:326:21)
    at invokeCallback (/Users/rjackson/sandbox/zenunu/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:498:33)
    at /Users/rjackson/sandbox/zenunu/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:562:16
    at flush (/Users/rjackson/sandbox/zenunu/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:2441:7)
    at process._tickCallback (internal/process/next_tick.js:61:11)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

In order to make it useful, we should throw it during the makeNodeWrapper recursion and include the parent node's annotation (or constructor.name).