ioB
ioB17mo ago

Running esbuild with esbuild_deno_loader

I've spent probably four or five hours trying to track down this issue, to the point where I actually started tweaking and rebuilding old versions of esbuild to try and reproduce this bug without the help of a plugin. I have no idea. I want to find what version this started happening in to file a bug report (because I think it's an esbuild issue), but I haven't had the time to do that. Here is the reproc code (it only errors with wasm):
import * as esbuild from "https://deno.land/x/esbuild@v0.15.10/wasm.js";
import { denoPlugin } from "https://deno.land/x/esbuild_deno_loader@0.6.0/mod.ts";

const result = await esbuild.build({
plugins: [denoPlugin()],
entryPoints: {
"test": new URL("./link-to-any-deno-file.ts", import.meta.url).href
},
outdir: ".",
bundle: true,
write: false,
format: "esm",
});

esbuild.stop();
import * as esbuild from "https://deno.land/x/esbuild@v0.15.10/wasm.js";
import { denoPlugin } from "https://deno.land/x/esbuild_deno_loader@0.6.0/mod.ts";

const result = await esbuild.build({
plugins: [denoPlugin()],
entryPoints: {
"test": new URL("./link-to-any-deno-file.ts", import.meta.url).href
},
outdir: ".",
bundle: true,
write: false,
format: "esm",
});

esbuild.stop();
Running this results in:
error: Cannot read file "Users/iob/Desktop/test/link-to-any-deno-file.ts": not implemented on js
error: Cannot read file "Users/iob/Desktop/test/link-to-any-deno-file.ts": not implemented on js
This is blocking any upgrade of the esbuild dependency for fresh.
2 Replies
KyleJune
KyleJune17mo ago
When I use esbuild, i just use a single entry point of "app.tsx" where it resolves to the app.tsx file in my current directory. So I have entryPoints:["app.tsx"]. I also specify the working directory with the absWorkingDir set to Deno.cwd(). Maybe it would work if you set the absWorkingDir and set entryPoints to {test:"./link-to-andy-deno-file.ts"} using a relative path string instead of a URL object. Oh also I don't use wasm. I just noticed you said you only have problems with wasm. You could still try using strings instead of URL objects to see if that would work with wasm. Maybe it's an issue related to handling of the URL objects.
ioB
ioB17mo ago
the reason this is set up this way is because this is how it has to be set up for fresh I wouldn't use esbuild this way for personal projects I imagine that's why I'm the first person as far as I can tell to encounter this The error message is super unclear though and I'm not even sure how it could happen Where does the "not implemented on js" error message come from? it's not anywhere in esbuild's source code nor in the esbuild_deno_loader source code I realize now that it could be a dependency of esbuild and that would probably explain why I can't find the source of this error