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" }) and import(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.
For our implementation it would be very beneficial for this proposal to expose an immutable byte buffer, because the user visible
ArrayBuffercould then be backed by the same underlying bytes that the module loader initially loads from disk / network.If a mutable
ArrayBufferis 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:import(specifier, { type: "text" })andimport(specifier, { type: "bytes" }), we need to keep the underlying bytes aroundThe first point likely also applies to browsers, depending on the HTML integration.
As such, I'd advocate that we pipeline
type: bytesafter the immutable ArrayBuffer proposal (currently Stage 2.7), and return an immutable buffer for this type of import.