dnt
dnt copied to clipboard
`FileReader` and `File` seems to be missing when compiling to NPM
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:
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
import { build, emptyDir } from "https://deno.land/x/[email protected]/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",
},
// ...
});