denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.45k stars 5.37k forks source link

Support `import foo from "./bar.txt" with { as: "bytes" }` #25354

Open lucacasonato opened 2 months ago

lucacasonato commented 2 months ago

Would import the relevant file as a byte buffer (Uint8Array). Maybe also import foo from "./bar.txt" with { as: "text" }?

marvinhagemeister commented 2 months ago

The import as text could also be very useful for bundler plugins.

lucacasonato commented 2 months ago

Also see https://github.com/whatwg/html/issues/9444

littledivy commented 2 months ago

Would be super useful for deno compile apps (https://github.com/denoland/deno/issues/17994)

kriskowal commented 3 weeks ago

Consider immutable ArrayBuffer and spelling import uint8array from 'octets.bin' with { type: 'bytes' } to line up with type: 'json': https://github.com/tc39/proposal-immutable-arraybuffer