NODE_DEBUG is undefined in bundled env that doesn't support node shimming (eg. Vite)
See original GitHub issueSystem:
OS: macOS 11.2.3
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 2.00 GB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.15.5 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.11 - /usr/local/bin/npm
Browsers:
Brave Browser: 89.1.22.67
Chrome: 89.0.4389.90
Edge: 89.0.774.57
Firefox: 86.0
Safari: 14.0.3
Packages:
typescript: 4.2.3
@azure/event-hubs: 5.4.0
Describe the bug
The NODE_DEBUG
global is undefined when using a bundler such as Vite which doesn’t support node shimming. A repo with a reproduction of the error is available here.
This issue was originally raised in the Vite repository but I have been advised that the issue is related to how @azure/event-hubs
is bundled. See the original issue here.
To Reproduce Steps to reproduce the behavior:
- Clone the above repo
- Run
yarn install
- Run
yarn start
- Open the browser console and note the error.
Expected behavior There should be no error.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Troubleshooting - Vite
Vite cannot handle and does not support code that only runs on non-strict mode (sloppy mode). This is because Vite uses ESM and...
Read more >Why do some variables show up as "undefined" when using ...
@Bergi node starts in the same directory as the selected file. The index.js and .env are in the same directory, so they should...
Read more >Shimming - webpack
This means writing isolated modules that are well contained and do not rely on hidden dependencies (e.g. globals). Please use these features only...
Read more >API - esbuild
Supported by: Build ... By default esbuild will not bundle the input files. ... For example, a package may contain code that only...
Read more >Dependency resolution - Parcel
When building for a node environment, builtin modules are excluded from the bundle, otherwise a shim is included. See the Node docs for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@andrewcourtice It looks like our dependency
rhea
requires some shims to work in the browser, so we’ll need to push updates to that before we can fully resolve the issue you’re seeing.That said, I was able to come up with a workaround for your sample by creating a shims file and importing it in your
index.ts
.Here’s what it looks like:
npm install --save buffer process
src/shims.tssrc/index.ts
Is this workaround something you’d be able to use until we can update our dependencies/verify we’re not relying on shims in our clients?
@chradek Can we log an issue for rhea regarding this?