generated from tc39/template-for-proposals
-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Description
For our implementation it would be very beneficial for this proposal to expose an immutable byte buffer, because the user visible ArrayBuffer
could then be backed by the same underlying bytes that the module loader initially loads from disk / network.
If a mutable ArrayBuffer
is returned, we have to take a copy of the underlying buffer, and would have to keep both copies in memory in perpetuity for two reasons:
- to avoid different underlying bytes for
import(specifier, { type: "text" })
andimport(specifier, { type: "bytes" })
, we need to keep the underlying bytes around - for JS modules we have to keep around the original source text for error display + source mapping, and without a significant refactor the same would apply to bytes / text modules in our implementation
The first point likely also applies to browsers, depending on the HTML integration.
As such, I'd advocate that we pipeline type: bytes
after the immutable ArrayBuffer proposal (currently Stage 2.7), and return an immutable buffer for this type of import.
ljharb, erights, rekmarks, ctcpip, bakkot and 1 more
Metadata
Metadata
Assignees
Labels
No labels