Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deal with the node globals gotcha #3

Open
tmcw opened this issue Jun 13, 2024 · 1 comment
Open

Deal with the node globals gotcha #3

tmcw opened this issue Jun 13, 2024 · 1 comment

Comments

@tmcw
Copy link
Member

tmcw commented Jun 13, 2024

The node globals gotcha looks like this:

  1. Unlike Node.js, Deno does not have process or Buffer globals in files by default.
  2. The Node.js @types/node TypeScript type definitions defines global process and Buffer objects
  3. Many NPM modules rely on the @types/node type definitions
  4. When you import a module that relies on @types/node, then it loads those types, and then makes process and Buffer objects appear to be global, from the perspective of the typechecker. But they do not actually become globals: this is just a type system problem.

We have considered some solutions to this:

  • Replace all references to @types/node with a custom patched version
  • Patch @types/node when we detect that it is being loaded into the type environment
  • Try to "un-set" process and Buffer in the environment

There is no robust solution that I've found to this yet.

@zephraph
Copy link

Thankfully it looks like this problem is taking care of itself. Deno 2 adopts Node globals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants