Integrate with latest ECMA-262 import attributes #116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 aimport { "?" 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 withwasm-js:orwasm:if we wanted to have a stricter scheme here. Perhapswasm-js://default/with?type=bytes, although it seems like it might be overkill too.