Worker JavaScript webpack recommendations to polyfill V8 for gaps between browser and node? Context of Loggly, Sentry, Bunyan

tl;dr; Many logging SaaS providers’ SDKs running in Worker lead to missing console, net, tls (etc) - looking for a recommendation solution or a well supported tool to integrate with a popular logging service.

Giant caveat: I’m a bit out of my depth with some of the discussions around V8 vs node vs browser as it relates to JavaScript, webpack, TypeScript, etc. I’m generally more “backend” focused (though am a bit of a “jack of all, master of none”). My point is please assume I don’t really know what I’m talking about :).

Also, though I don’t think it really matters with runtime as everything is transpired, my goal is to be 100% TypeScript (because types!).

Here is my basic situation: I went into creating a PoC for Workers INCORRECTLY assuming Workers == node - I realized in reality Workers == V8, but again I sort of ignored that “minor” detail for my PoC work.

I was able to get away with ignoring the V8 vs Node runtime until I started trying to get Loggly working, and after failing that, Sentry. I should add that I am sure I could skip using the SDKs from these vendors, but I’d prefer to!

Starting with Sentry as it’s actually directly recommended in the “debugging Workers” documentation section,

npm install @sentry/node @sentry/tracing

import * as Sentry from “@sentry/node”;
import { Integrations } from “@sentry/tracing”;

Sentry.init({
  dsn: SENTRY_DSN,
  tracesSampleRate: 1.0,
});

This results in

Module not found: Error: Can't resolve 'console' in .../node_modules/@sentry/node/esm/integrations'
...
Module not found: Error: Can't resolve 'net' in '.../node_modules/https-proxy-agent/dist'
...
Module not found: Error: Can't resolve 'tls' in '.../node_modules/https-proxy-agent/dist'
...

Using Loggly via their recommended tooling yields a similar experience:

var winston  = require('winston');
var {Loggly} = require('winston-loggly-bulk');
winston.add(new Loggly({
    token: LOGGLY_TOKEN,
    subdomain: LOGGLY_SUBDOMAIN,
    tags: ["Winston-NodeJS"],
    json: true
}));
winston.log('info', "Hello World from Node.js!");

results in

...
Module not found: Error: Can't resolve 'tls' in '.../node_modules/tunnel-agent'
...

Now in all of these situations I can get around the webpack issues by adding

 node: {
    fs: "empty",
    net: "empty",
    tls: "empty"
 },

To my webpack config, but in my testing I can’t simply ignore these as they may actually be used by these libraries.

Other times, e.g. if I use the browser version of some of these plugins (e.g. @sentry/browser, or winston if I ignore the TLS issue) I end up with runtime issues like ReferenceError: window is not defined

So this is a lot of words, but I’m wondering if there are any recommendations on how I might solve this? I’m guessing there are some simple / stupid things I might be able to do?

Or perhaps somebody happens to know of an integration tool / library / package with Loggly / Sentry that only depends on things available within the Worker / V8 runtime?

Thanks for any tips / advice!