question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Top level await

See original GitHub issue

🙋 feature request

Parcel 2 could support Top Level Await. Most bundlers/runtimes are starting to support it so it could be nice to have it in Parcel

Webpack’s experiments.topLevelAwait experimental feature Node stable support ~Node’s(13.3+) --harmony-top-level-await/--harmony_top_level_await experimental feature~ Deno’s native support, https://github.com/denoland/deno/pull/3212 Chromium’s native support, https://bugs.chromium.org/p/v8/issues/detail?id=9344. Will ship in Chrome 89

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:18
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Banou26commented, Aug 3, 2020
0reactions
mischniccommented, Mar 23, 2022

Related: https://twitter.com/bradleymeck/status/1506727720968986633 https://esm-exports-without-eval.glitch.me/

Details

the source code for c.mjs exports names: default, hi

// a.mjs
import './d.mjs';
import * as c from './c.mjs';
export function getNS() {
  return Object.getOwnPropertyNames(c);
}

// b.mjs
import {getNS} from './a.mjs';
console.log(getNS()); 
// Safari gets this right with TLA
// but V8 and SpiderMonkey incorrectly
// evaluate parents if using TLA and throwing errors
// FIXME: once V8 and SpiderMonkey allow TLA to block
//   graphs correctly move to `await new Promise` to
//   not fire off error alarms in devtools
throw getNS();
// await new Promise(()=>{})

// c.mjs
console.error('EVALUATING C, OH NO');
debugger;
export default 0;
export var hi;

// d.mjs
import './b.mjs';
Read more comments on GitHub >

github_iconTop Results From Across the Web

Top-level await is available in Node.js modules - Stefan Judis
When dealing with asynchronous functionality such as making network requests, there was no top-level await support in Node.js (yet).
Read more >
await - JavaScript - MDN Web Docs
The await operator is used to wait for a Promise and get its fulfillment value. It can only be used inside an async...
Read more >
Top-level await - V8 JavaScript engine
Top -level await enables developers to use the await keyword outside of async functions. It acts like a big async function causing other ......
Read more >
"top level await" | Can I use... Support tables for HTML5, CSS3 ...
JavaScript operator: await: Use at module top level. Usage % of ... Support data for this feature provided by: MDN browser-compat-data.
Read more >
Top-level await in TypeScript 3.8
TypeScript 3.8 introduces a new functionality which is called top-level await. It allows developers to use the await keyword without a surrounding async ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found