Skip to content

Text decoding should be specified for JS, JSON & text imports #117

Open

Description

@eemeli

ECMA-262 does not define how to parse a file into a module, when it's imported into JS. For browsers, this is defined by the HTML standard, which includes this:

Let sourceText be the result of UTF-8 decoding bodyBytes.

That applies for all imports, be it for JS modules, JSON modules, or the upcoming text modules.

For text modules, the intent in its HTML standard changes is to match the behaviour of Fetch's .text(), which already now mandates using the UTF-8 decode algorithm for all files.

I'd be surprised if some runtime wasn't currently at least detecting a BOM and potentially parsing UTF-16 content as UTF-16 rather than UTF-8.

Activity

  1. ctcpip commented on Sep 25, 2026

    @ctcpip
    Member

    this is a valid interop concern, but not in scope for the minimum common API (MCA) spec

    the MCA specifies APIs required for confirming runtimes; it doesn't (currently) specify how hosts resolve/decode ES modules, etc. that would be appropriate in a different spec which defines module loading semantics (or potentially in a separate TC55 host integration effort), rather than in the MCA spec

    edit: maybe it could be in scope for the MCA, but would fall outside the bounds of its current mandate of "defines a subset of Web Platform APIs for server runtimes to implement for interoperability with the web"

  2. ctcpip commented on Sep 25, 2026

    @ctcpip
    Member

    related: #49

    I guess we have to decide on whether/how to include #49, and then this issue becomes significantly more relevant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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