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
7k stars 228 forks source link

Fix default export returning undefined in ESM #440

Closed Codex- closed 7 months ago

Codex- commented 1 year ago

I noticed this previously but it's consistently reproducible with Bun.

The esm based index.mjs export for concurrently, export default concurrently.default, in some cases depending on the way you're executing concurrently can have the default function on concurrently itself which makes this export not work as expect, as default is undefined.

This PR adds a simple fallback export default concurrently.default || concurrently that allows some defense against this behaviour.

I have added tests for both Node and Bun that test the commonjs and esm import behaviour, as well as a direct ts import case testing both for Bun's case.

Also, I've noticed Node 19 is targetted here but Node 20 enters LTS next month, should this target 20 instead of 19?

coveralls commented 1 year ago

Coverage Status

coverage: 99.31%. remained the same when pulling ee853011adf4d5c2cc6f6c8861042c0407f73ac9 on Codex-:fix_bun_compatibility into 16182089336827900ef2fc943b353c14b850cc9b on open-cli-tools:main.

paescuj commented 12 months ago

Not sure if this is the preferred solution. I think this could be properly tackled by https://github.com/open-cli-tools/concurrently/issues/399 instead. Also I think it's about time to go full ESM, things are getting messy. I'll look into this more detailed later on this day.