Skip to content

Instantly share code, notes, and snippets.

View nicolo-ribaudo's full-sized avatar

Nicolò Ribaudo nicolo-ribaudo

View GitHub Profile

Execute modules on idle

Today the ESM loading/execution pipeline is very linearly split into separate phases. When the browser sees a <script type="module" src="..."> tag it will:

  1. Load the root of that module graph
    1. Once it's loaded, look at its dependencies and fetch all of them
    2. Once each one of those dependencies is loaded, look at their dependencies and recurse.
  2. After that the whole module graph is loaded, if there have been no errors, "link" it (i.e. validate that imports/exports match)
  3. After that a graph is linked, synchronously execute all of it (modulo top-level await, which causes some modules to be blocked on their dependencies to complete)

The import defer proposal allows partially pulling some module out of this linear process, so that their execution is deprioritized compared

Productions with optional elements whose SDOs omit the optional

These are cases where a grammar production has an optional (?) element on the right-hand side, and a syntax-directed operation defines a rule for that production without the optional part.

For example, the production Foo : Bar Baz? has two alternatives: Foo : Bar Baz and Foo : Bar. When an SDO is defined on Foo : Bar, it handles the "optional element absent" case.

{
"did": "did:plc:diblntoainoud2g6qk5bawks"
}
From bc1e34f1a3be4cd8ab92f35c67c9ac7306da934d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= <nribaudo@igalia.com>
Date: Sun, 16 Feb 2025 01:17:14 +0100
Subject: [PATCH 1/2] Define `importMap` option in webidl
---
.../renderer/bindings/generated_in_core.gni | 4 +++
.../blink/renderer/core/workers/worker.idl | 2 +-
.../renderer/core/workers/worker_options.idl | 5 ++++
.../constructors/Worker/importMap-option.html | 29 +++++++++++++++++++

"numeric value with precision" V3

NOTE: The other file in the gist shows the same but using "significant digits" rather than "fractional digits". After trying to use it, I noticed that almost always we want to start counting fro mthe units and not from the most significant digit.

A "numeric with precision" is a pair consisting of a numeric value and an indication of how many of its digits are significant. The number of digits is counted starting from the units: 1 means the first digit after the dot, 0 means that we have an integer, -1 means that we have a multiple of 10.

It can be obtained from a numeric value (wether it's decimal, float, or bigint) by "decorating it":

new Decimal("123.45").withFractionalDigits(1);
123.45.withFractionalDigits(1);

MessageFormat 2 modules integration

This is a proposal for better integration of MessageFormat 2 (Unicode proposal, TC39 proposal) with the rest of the web platform.

TLDR

import message from "./message.mf2" with { type: "messageformat" };

export function Notifications({ count }) {
  return html`<p>${message.format({ count })}</p>`;

Optional chaining assignment proposal

Basically, allow this:

foo?.bar = value;

which is equivalent to

foo == null ? undefined : (foo.bar = value);
const CH_BRACE_L = 0x7b as const;
const CH_BRACE_R = 0x7d as const;
const CH_SQUARE_L = 0x5b as const;
const CH_SQUARE_R = 0x5d as const;
const CH_QUOTE_D = 0x22 as const;
const CH_ESCAPE = 0x5c as const;
const CH_COMMA = 0x2c as const;
const CH_COLON = 0x3a as const;
const CH_DOT = 0x2e as const;
const CH_MINUS = 0x2d as const;

Meta

Key ID: C6CB6CC54E363735

Subkeys: AAFDA9101C58F338, A96EDD9C10BC77A5, 5BB1D2E5A4C8404B

Setup GPG

git config --global user.signingkey AAFDA9101C58F338

This for loop:

for (let i = 0, getI = () => i; i < 3; i++)
  console.log(getI());

unrolls to: