denoland / denoland/dnt

`FileReader` and `File` seems to be missing when compiling to NPM

Open
#283 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.3k
Forks
49
PR merge metrics
No merged PRs in 30d

Description

Hello I'm unsure if this would be the right place for such issue of if it should be part of a shim project, feel free to redirect me.

while compiling the following Deno/TS code:

```ts
export function fromFile(file: File) {
return new Promise((resolve) => {
const reader = new FileReader();
reader.onload = (e: any) => {
const arrayBuffer = e.target?.result;
if (!arrayBuffer || typeof arrayBuffer === "string") {
throw new Error("Could not read file");
}
const mimeType = getMimeTypes(arrayBuffer, file.type);
resolve(mimeType);
};
reader.readAsArrayBuffer(file);
});
}
```

FileReader and File seems to be missing, it works in Deno, but not in nodejs (which kinda make sense as node uses a different system for reading files) but I could find how to configure for a shim, seems like shim `domException` should contain File at least.

example of compile with DNT

```ts
import { build, emptyDir } from "https://deno.land/x/dnt@0.35.0/mod.ts";

// [...]

await build({
entryPoints: ["./mod.ts"],
outDir: "./npm",
shims: {
deno: "dev",
blob: "dev",
domException: "dev",
},
compilerOptions: {
lib: ["esnext", "dom", "dom.iterable"],
sourceMap: true,
target: "ES2015",
},
// ...
});
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.