-
-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix default export returning undefined in ESM #440
Conversation
b26f6ac
to
e4f1cc0
Compare
fcaa531
to
01d6175
Compare
01d6175
to
111274d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this! I have mostly nitpicks, no questions on the intended change
smoke-tests/smoke-test-cjs.cjs
Outdated
// Prevent an unhandled rejection, exit gracefully. | ||
process.exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non-zero exit codes will fail the CICD, there were cases in my own testing where simply using process.exit()
would cause a false success on the workflow run
smoke-tests/smoke-test-cjs.cjs
Outdated
console.info('Imported cjs successfully'); | ||
} catch (error) { | ||
console.error(error); | ||
console.debug(error.stack); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node logs the stacktrace by default, doesn't bun do the same? E.g. if you make the assertion fail, won't it print the stack trace twice?
smoke-tests/smoke-test-cjs.cjs
Outdated
); | ||
|
||
console.info('Imported cjs successfully'); | ||
} catch (error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is catching the error necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unhandled rejections can fail silently, but these don't actually need to be async so I'll update them (ported from a larger suite I use for one of my own packages)
0de1d19
to
ee85301
Compare
Not sure if this is the preferred solution. I think this could be properly tackled by #399 instead. |
I noticed this previously but it's consistently reproducible with Bun.
The esm based
index.mjs
export forconcurrently
,export default concurrently.default
, in some cases depending on the way you're executingconcurrently
can have the default function onconcurrently
itself which makes this export not work as expect, asdefault
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
andesm
import behaviour, as well as a directts
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?