tc39 / proposal-import-attributes

Proposal for syntax to import ES modules with assertions
https://tc39.es/proposal-import-attributes/
Apache License 2.0
569 stars 32 forks source link

Importing arbitrary files as raw bytes #155

Closed AljoschaMeyer closed 5 months ago

AljoschaMeyer commented 5 months ago

I found myself here looking for a way to import arbitrary data files in Deno and have distribution via package managers just work. Hypothetical example:

import rawBytes from "./stuff.someCustomExtensionNobodyElseCaresAbout" with { type: "UInt8Array" };

export const usefulStuff = parseMyCustomFormat(rawBytes);

As someone who is not really a web developer, seeing support for a select few blessed data formats but excluding the most simple and general choice (arbitrary sequences of bytes) feels odd to me.

Is there support for this (in this proposal, not in Deno) and I just didn't find it? Is there any chance a feature like this could be supported eventually? Or am I missing some web-specific context that would make this impossible?


This is not a duplicate of #116 as far as I understand it. #116 wants to obtain information on how to interpret the module contents from a server, I want to not interpret the module contents.

AljoschaMeyer commented 5 months ago

Should have looked in the closed issues first, this is (essentially) a duplicate of #120. Sorry about that.