Skip to content

Conversation

@guybedford
Copy link
Contributor

Threw together some very simple draft spec text, which should be enough for a Stage 2 if there is interest.

<p>See <a href="https://github.com/styfle/proposal-import-bytes/blob/main/README.md">the explainer</a> for information.</p>
<emu-note type="editor">
<p>This proposal is buit on top of the <a href="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/tc39/proposal-import-attributes">Import Attributes</a> proposal.</p>
<p>This proposal is buit on top of the <a href="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/tc39/proposal-json-modules">JSON Modules</a> and <a href="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/tc39/proposal-immutable-arraybuffer">Immutable Array Buffer</a> proposals.</p>
Copy link
Member

Choose a reason for hiding this comment

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

Might need to update the readme as well if we want to swap import-attributes for json-modules

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I think import-attributes is correct.

This proposal is built on top of import-attributes, not json-modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way I framed it we are sharing JSON modules text per the next comment.


<emu-note>
<p><ins>The above text implies that hosts *must* support JSON modules imported with `type: "json"` (if it completes normally), but it doesn't prohibit hosts from supporting JSON modules imported with no type specified. Some environments (for example, web browsers) plan to require `with { type: "json" }`, and environments which want to restrict themselves to a compatible subset would do so as well.</ins></p>
<p>The above text implies that hosts *must* support JSON modules <ins>and buffer modules</ins> imported with `type: "json"` <ins>and `type: "buffer"` respectively </ins>(if it completes normally), but it doesn't prohibit hosts from supporting JSON modules imported with no type specified. Some environments (for example, web browsers) plan to require `with { type: "json" }`, and environments which want to restrict themselves to a compatible subset would do so as well.</p>
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to remove the type: "json" part mentioned here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I've based this to JSON modules, it's sharing this note with JSON modules.

@github-actions
Copy link

The rendered spec for this PR is available at https://styfle.github.io/proposal-import-buffer/pr/10.

Copy link
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

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

Great work, thanks!

@styfle styfle merged commit f7c16f8 into tc39:main Jul 30, 2025
1 check passed
@styfle
Copy link
Member

styfle commented Aug 13, 2025

@guybedford Since this was changed from returning ArrayBuffer to Uint8Array, do we need to update this spec?

https://github.com/tc39/proposal-import-bytes/blob/main/README.md#proposed-semantics-and-interoperability

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.

2 participants