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

Does this plugin will benefit from proposal top-level-await? #18

Open
shrinktofit opened this issue Nov 4, 2019 · 1 comment
Open

Comments

@shrinktofit
Copy link

https://github.com/tc39/proposal-top-level-await

Once if babel implements this proposal. This plugin can replace require to await import to support require non-string-literal module ids?

@tbranyen
Copy link
Owner

tbranyen commented Jan 14, 2020

Hi @shrinktofit I believe it does. We should remove the synchronousImport option and instead opt to directly transpiling to a top-level await. This also has the potential to solve "top-level" conditional imports such as:

if (process.env.NODE_ENV === 'production') {
  module.exports = require('react/prod');
}
else {
  module.exports = require('react/test');
}

...converting to...

let _a;

if (process.env.NODE_ENV === 'production') {
  _a = await import('react/prod');
}
else {
  _a = await import('react/test');
}

export default _a;

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

No branches or pull requests

2 participants