denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.4k stars 5.37k forks source link

bundled/compiled code throws exception #13170

Closed emrul closed 2 years ago

emrul commented 2 years ago

I have tried the latest Deno release (1.17.0) and also tried canary and I am facing an error error: Uncaught (in promise) ReferenceError: Cannot access 'NodeTypeError' before initialization when running my script - via deno bundle and deno compile. The script works fine when executed via deno run. I am not sure if the fact that I need --unstable is causing this?

Trying to run the output of deno bundle gives me this:

error: Uncaught (in promise) ReferenceError: Cannot access 'NodeTypeError' before initialization
class ERR_INVALID_ARG_TYPE extends NodeTypeError {
                                   ^
    at file:///Users/...js/tg.bundle.js:12236:36

and indeed, I can see the class NodeTypeError is extended before it has been declared.

% deno --version
deno 1.17.0+ac06797 (canary, x86_64-apple-darwin)
v8 9.7.106.15
typescript 4.5.2

Any pointers would be greatly appreciated.

Reproduction steps:

Originally posted by @emrul in https://github.com/denoland/deno/issues/12086#issuecomment-999151689

Pjort commented 2 years ago

I can confirm I have the same issue, and I am not using --unstable.

deno --version deno 1.17.1 (release, x86_64-pc-windows-msvc) v8 9.7.106.15 typescript 4.5.2

I used to get: Uncaught ReferenceError: Cannot access 'Response' see: https://github.com/denoland/deno/issues/12086 but that seems solved now.

Instead the error has now changed to: ReferenceError: Cannot access 'NodeTypeError' before initialization

The only lib I am using is: https://deno.land/x/denodb/mod.ts

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.