dnt icon indicating copy to clipboard operation
dnt copied to clipboard

Option to disable dntGlobalThis and picocolors

Open grimfrostmage opened this issue 10 months ago • 2 comments

Even when I set shims: { deno: false} or shims: {} a proxy object is created and anywhere that globalThis is used its being replaced with dntGlobalThis and a proxy object with no shims, which results in an extra file and code in multiple libraries.

And even though I'm using a custom library to shim the different different frameworks for Deno, bun, and nodejs, test_runner.js and picocolors is added to the package.json. So I'm able to run tests with the generated npm package using node --test and bun test.

It would be nice to disable that in certain scenarios to reduce the extra dependency on picocolors without having to read and re-write the package.json and remove the test_runner.js. And unless you write your own wrapper for global in a central location, it makes it harder to remove the dnsGlobalThis and proxy object.

Is there currently a way to turn this off? If not, would you consider an option to turn this off? I can imagine that when something like vitest and other things work in deno, that shimming the tests over time will become needed less.

Also thanks for developing dnt.

grimfrostmage avatar Feb 19 '25 14:02 grimfrostmage

Even better would be replacing picocolors with

  • https://nodejs.org/api/util.html#utilstyletextformat-text-options
  • or console.log("%cWow this works in any JS console! 😎", "color:green") once https://github.com/nodejs/node/pull/49205 is merged into node

stefnotch avatar May 05 '25 10:05 stefnotch

This. Running typeof window === "object" through dnt, it's converted to typeof s.dntGlobalThis == "object", which when run in deno evaluates to true, which is not at all what is supposed to happen. Edit: okay, typeof document === "object" seems to be left untouched.

mb21 avatar Jun 19 '25 11:06 mb21