Skip to content

Conversation

@guybedford
Copy link
Collaborator

@guybedford guybedford commented Oct 4, 2025

The import attributes specification is now part of ECMA-262. This rebases the spec to handle the new module request record and import attribute record functionality in module resolution.

In addition, I've also integrated a simple proposal for import attributes integration along the lines discussed in #42.

The design is to allow a ?... querystring on the export name to indicate the attributes, using standard URL query param semantics and referencing the URL spec for this exactly. This then fully encodes the import attributes grammar.

Effectively then, "./foo.bin" "default?type=bytes" can be used to import an immutable array buffer for arbitrary external data.

Supporting bytes, CSS and JSON imports natively for Wasm can be simply implemented this way.

This does change the meaning of ? in export names - but these are not currently commonly used in JS (I don't think I've ever seen a import { "?" as foo } from 'bar'). So it seems like this doesn't conflict with other uses since we have the source phase opt-out for other interpretations anyway not the instance phase. But we could add additional disambiguation by prefixing the export name with wasm-js: or wasm: if we wanted to have a stricter scheme here. Perhaps wasm-js://default/with?type=bytes, although it seems like it might be overkill too.

Copy link
Collaborator

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct from the point of view of properly integrating with ECMA-262.

I don't love the proposed "syntax", but I don't have better suggestions.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants