Skip to content

Consider immutable array buffers for type: bytesΒ #5

@lucacasonato

Description

@lucacasonato

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions