esbuild_deno_loader
esbuild_deno_loader copied to clipboard
"external" config option in esbuild broken
When I configure external to be excluded from the bundle in my esbuilder config, they seem to be ignored when enabling the esbuild_deno_loader plugin. What I've done my local fork is add this:
if (build.initialOptions.external) {
for (const external of build.initialOptions.external) {
if (resolved.href.startsWith(external)) {
return { path: resolved.href, external: true };
}
}
}
Above this line: https://github.com/lucacasonato/esbuild_deno_loader/blob/main/mod.ts#L77
This works, but isn't great, because external supports wildcards and what not. According to the esbuild docs this shouldn't be necessary, but I'm not familiar enough of how this all interacts to figure out why externals just seem to break without the lines above.
Had to use this:
if (build.initialOptions.external) {
for (const external of build.initialOptions.external) {
if ((resolved.href.startsWith(external)) || (args.path === external)) {
return { path: resolved.href, external: true };
}
}
}
in order to also ignore modules added to external
by the name defined in the import map json file.
I am running into this issue too. @lucacasonato any ideas on how to use esbuild_deno_loader
with esbuild
's external
feature?
+1 this is also happening to me.
Same here!
@haschu I made a fork here which you can use: https://github.com/lucacasonato/esbuild_deno_loader/pull/95
import { denoPlugins } from 'https://raw.githubusercontent.com/quinn/esbuild_deno_loader/main/mod.ts'
YMMV. it is tailored to my usecase, which is to pass the import through untouched (rather than being resolved by deno's import map, then left as an import)
Would very much appreciate if this could be fixed as PeerJS has one link for both Deno and the web, but when bundling it seems to include node:process
and node:buffer
. Being able to exclude it from being bundled in would simply solve that problem.
This code in the browser works, but when bundled, breaks.
import { Peer } from "https://esm.sh/[email protected]?bundle-deps"
const peer = new Peer()
console.log(peer.id)