Urgent.News

What's breaking now, across thousands of outlets.

Tech

Safari 27 rewrites the module loader to fix top-level await

I pulled the WebKit post open in one tab and the smallest possible module graph in another, because a rewrite of the loader is not the kind of note you skim. The short version: per WebKit, Safari 27 now runs top-level await on a fresh module loader that translates the ECMAScript specification's pseudocode directly into C++, replacing the old self-hosted JavaScript implementation. The longer…

The WebKit team has rewritten the module loader in Safari 27 to ensure proper handling of top-level await, a feature introduced in ECMAScript 2022. The old loader, a self-hosted JavaScript implementation, was written during the WHATWG Loader proposal days and did not support top-level await. Top-level await allows modules to await at the beginning of their body, which can lead to intermittent failures due to incomplete module evaluation.

The new loader, written in C++ and following the ECMAScript modules pseudocode step by step, resolves this issue by ensuring the correct evaluation order. WebKit verified the new loader by fuzzing complex module graphs, running outputs through the new loader and other engines, and comparing them. A small reproduction of the issue shows that the new loader logs the imports in the correct order (1, 2, 3) when dynamically importing a module that uses top-level await.

This fix will benefit developers who have encountered ordering issues with top-level await in Safari. However, the WebKit post does not address the behavior of other engines or the performance impact of the rewrite.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

The 5-Minute Trick That Landed Me 3 Job Offers

I used to prep for interviews the normal way. Read the job post twice. Practice "tell me about yourself" in the mirror. Show up hoping for the best. Three offers later, I do one thing differently.

More from Friday 11 September →