open-cli-tools / concurrently

Run commands concurrently. Like `npm run watch-js & npm run watch-less` but better.
https://www.npmjs.com/package/concurrently
MIT License
7.11k stars 231 forks source link

Import footgun: Default export versus named export (No output when used via API) #399

Closed rezonant closed 9 months ago

rezonant commented 1 year ago

I got bit by accidentally importing as import { concurrently } from 'concurrently'; instead of import concurrently from 'concurrently';. The default export applies all the default controllers and logger, whereas the named export does not (the default export uses the "unconfigured" named export to do it's thing).

It might be worth adding a note to the README about this or possibly renaming the named export to make it harder to fall into this trap.

The symptoms are that no program output appears, even though it does when you use the concurrently CLI- this is of course because there is no Logger or LogOutput/LogError controllers added in the configuration. I ended up having to dig into the source code to figure this out.

At the very least, this issue should provide some help for anyone else who hits this footgun.

gustavohenke commented 1 year ago

You've raised an excellent point! I suppose that renaming the unconfigured function to createConcurrently would be better, but that'd be a breaking change 😕

paescuj commented 1 year ago

I suppose that renaming the unconfigured function to createConcurrently would be better, but that'd be a breaking change 😕

Might be something for ~v8~ v9?

gustavohenke commented 2 months ago

Hey! This is now fixed in v9.0.0. https://github.com/open-cli-tools/concurrently/releases/tag/v9.0.0