ember-cli / broccoli-builder

MIT License
1 stars 10 forks source link

Don't break SilentError #20

Closed ef4 closed 6 years ago

ef4 commented 6 years ago

If a broccoli plugin throws SilentError, we wrap it in a BroccoliBuildError and lose its actual message, resulting in unhelpful output like:

Build failed.
The Broccoli Plugin: [BroccoliMergeTrees] failed with:
undefined

The broccoli plugin was instantiated at:
    at BroccoliMergeTrees.Plugin (/Users/edward/hacking/ember-cli-fastboot/node_modules/broccoli-plugin/index.js:7:31)
    at new BroccoliMergeTrees (/Users/edward/hacking/ember-cli-fastboot/node_modules/broccoli-merge-trees/index.js:16:10)
    at Class.postprocessTree (/Users/edward/hacking/ember-cli-fastboot/index.js:200:14)
    at projectOrAddon.addons.reduce (/Users/edward/hacking/cardstack-web/node_modules/ember-cli/lib/utilities/addon-process-tree.js:6:25)
    at Array.reduce (<anonymous>)
    at addonProcessTree (/Users/edward/hacking/cardstack-web/node_modules/ember-cli/lib/utilities/addon-process-tree.js:4:32)
    at EmberApp.addonPostprocessTree (/Users/edward/hacking/cardstack-web/node_modules/ember-cli/lib/broccoli/ember-app.js:600:12)
    at EmberApp.toTree (/Users/edward/hacking/cardstack-web/node_modules/ember-cli/lib/broccoli/ember-app.js:1716:17)
    at module.exports (/Users/edward/hacking/cardstack-web/ember-cli-build.js:50:14)
    at Builder.setupBroccoliBuilder (/Users/edward/hacking/cardstack-web/node_modules/ember-cli/lib/models/builder.js:56:19)

This change gives SilentError priority to be rethrown without being mangled.

ef4 commented 6 years ago

@courajs: I think this is the underlying cause of your difficulty in getting pleasant-looking build errors.

rwjblue commented 6 years ago

Seems like either this test is wrong or the change is wrong: https://github.com/ember-cli/broccoli-builder/blob/ed62da3cd5920c1b9c0f312d93a8cc06809f6e74/test/builder_test.js#L123-L145

ef4 commented 6 years ago

Looks to me like the test was wrong. It was (accidentally, I think) asserting that SilentErrors get decorated with broccoli instantiation stack, which is kinda the opposite of what SilentErrors are for.

rwjblue commented 6 years ago

Thanks @ef4 !

rwjblue commented 6 years ago
❯ np --any-branch

Publish a new version of broccoli-builder (0.18.9)

? Select semver increment or specify new version patch  0.18.10
? Will bump from 0.18.9 to 0.18.10. Continue? Yes
 ✔ Prerequisite check
 ✔ Git
 ✔ Cleanup
 ✔ Installing dependencies using Yarn
 ✔ Running tests
 ✔ Bumping version using Yarn
 ✔ Publishing package
 ✔ Pushing tags

 broccoli-builder 0.18.10 published 🎉