Turbopack: support `import ... with {type: "bytes"}` (#83896)
- [x] The big question is: do we
- put this behind a flag (`nextConfig.experimental.importTypeBytes`?)
- ~~put this behind a non-standard `type: "turbopack-bytes"` (currently implemented)~~
- ~~just ship it?~~
- the only "problem" is that type: "bytes" is now silently ignored if the flag is not enabled
- [x] [Furthermore, `Uint8Array.fromBase64` isn't that widely supported](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/fromBase64#browser_compatibility). So emitting that always is questionable from a browser support standpoint.
This is the output in the test:
```js
module.exports = [
"[project]/turbopack/crates/turbopack-tests/tests/execution/turbopack/basic/type-bytes/input/data.bin (static bytes in ecmascript)",
(ctx) => {
ctx.v(Uint8Array.fromBase64("dGhpcyBpcyBzb21lIGRhdGEK"));
},
"[project]/turbopack/crates/turbopack-tests/tests/execution/turbopack/basic/type-bytes/input/index.js [test] (ecmascript)",
(ctx) => {
"use strict";
var bytes = ctx.i(
"[project]/turbopack/crates/turbopack-tests/tests/execution/turbopack/basic/type-bytes/input/data.bin (static bytes in ecmascript)"
);
it("import type:bytes should work", () => {
expect(bytes["default"]).toBeInstanceOf(Uint8Array);
expect(new TextDecoder().decode(bytes["default"])).toBe(
"this is some data\n"
);
});
},
];
```