-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Improve ESM support detect #2404
Conversation
deb1264
to
c28b2f3
Compare
a3884d3
to
ba66367
Compare
ba66367
to
7242ec8
Compare
// Lazily determine support since this prints an experimental warning. | ||
const supportsESM = async () => { | ||
try { | ||
await import('data:text/javascript,'); |
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.
Ha that's neat. Saves us from having a weird file in the package.
isESMSupported = await supportsESM(); | ||
} | ||
|
||
if (isESMSupported) { | ||
return import(pathToFileURL(ref)); |
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.
Do we need this pathToFileURL
?
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.
Seems need for Node.js 13 on windows https://github.com/avajs/ava/pull/2404/checks?check_run_id=457268243
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.
Yep 😄
This reverts commit 4ec286d.
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 @fisker!
Replace
lib/esm-probe.mjs
file by a dataURL,and we don't care about theimport
result, we don't have to waitCache the detect result, so we don't have to wait for a microtask everytime
@arlac77