esm.sh icon indicating copy to clipboard operation
esm.sh copied to clipboard

Deno + esbuild: ReferenceError: require is not defined

Open yw662 opened this issue 4 years ago • 3 comments

error: Uncaught ReferenceError: require is not defined at https://cdn.esm.sh/v15/[email protected]/esnext/esbuild.js:8:1378 at https://cdn.esm.sh/v15/[email protected]/esnext/esbuild.js:1:754 at https://cdn.esm.sh/v15/[email protected]/esnext/esbuild.js:8:4069

I can find a require("child_process") in esbuild.js, which I think is what causes the issue.

yw662 avatar Mar 04 '21 22:03 yw662

esbuild seems like one of those projects that are too big/complex to be able to just use through a CDN for Deno support

shadowtime2000 avatar Mar 04 '21 23:03 shadowtime2000

I can find a require("child_process") in esbuild.js, which I think is what causes the issue.

Well kind of. esm.sh at the start of each file adds imports to all depenendcies and then creates a require function which takes the name of a package and just returns the result of that import. It seems require is being used but a require function at the top isn't being generated.

shadowtime2000 avatar Mar 04 '21 23:03 shadowtime2000

esbuild on Node.js uses worker_threads which is not yet supported by Deno std/node but you can use deno esbuild port instead

v1rtl avatar Oct 11 '21 13:10 v1rtl