lukeed / uvu

uvu is an extremely fast and lightweight test runner for Node.js and the browser
MIT License
2.97k stars 100 forks source link

node argument `--conditions browser` doesn't work #151

Closed atk closed 2 years ago

atk commented 2 years ago

While the documentation claims that uvu shares its arguments with node, the --conditions argument that allows to coerce node to load exports for the browser, does not work.

This is especially useful in combination with jsdom. A workaround is to call uvu from node:

node --conditions browser node_modules/.bin/uvu [options]
lukeed commented 2 years ago

uvu only shares/mimics the --require argument. The docs don't/shouldn't say anywhere that it forwards the flags to node – it can't since the uvu/bin.js file is called directly & there's no child.spawn call within the CLI.

Your workaround would be the only solution. Another option could be to define the NODE_OPTIONS environment variable. I havent tried, but I think that might be respected by uvu's underlying node process:

$ NODE_OPTIONS="--conditions=browser" uvu tests

If you saw a docs issue, please follow up and lemme know :) Thanks~!

atk commented 2 years ago

That's maybe a capability that shouldn't be left undocumented ;-)

lukeed commented 2 years ago

It's a Node thing and is documented by Node 😅

atk commented 2 years ago

As you wish. I usually want to make things easy for the users of my packages.