Skip to content
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

Merged
merged 9 commits into from
Feb 23, 2020
Merged

Conversation

fisker
Copy link
Contributor

@fisker fisker commented Feb 18, 2020

Replace lib/esm-probe.mjs file by a dataURL,

and we don't care about the import result, we don't have to wait

Cache the detect result, so we don't have to wait for a microtask everytime

@arlac77

@fisker fisker force-pushed the improve-esm-support branch 2 times, most recently from a3884d3 to ba66367 Compare February 18, 2020 08:50
@fisker fisker marked this pull request as ready for review February 18, 2020 09:24
lib/worker/subprocess.js Outdated Show resolved Hide resolved
// Lazily determine support since this prints an experimental warning.
const supportsESM = async () => {
try {
await import('data:text/javascript,');
Copy link
Member

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));
Copy link
Contributor Author

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep 😄

Copy link
Member

@novemberborn novemberborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fisker!

@novemberborn novemberborn merged commit 8831f54 into avajs:master Feb 23, 2020
@fisker fisker deleted the improve-esm-support branch February 23, 2020 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants