uvu 0.5.6 regression: CLI runner fails on Node.js 10
ludofischer opened this issue · 1 comments
On GitHub actions with Node.js 10, running : uvu packages "test.*\.js$"
fails to run any tests and crashes with this stack trace:
ReferenceError: globalThis is not defined
at Object.exports.run (/home/runner/work/cssnano/cssnano/node_modules/.pnpm/uvu@0.5.6/node_modules/uvu/run/index.js:2:2)
at sade.version.option.option.option.option.option.action (/home/runner/work/cssnano/cssnano/node_modules/.pnpm/uvu@0.5.6/node_modules/uvu/bin.js:28:30)
The tests run as expected with uvu 0.5.5 on the same configuration.
Link to CI failure: https://github.com/cssnano/cssnano/runs/7240283115?check_suite_focus=true
Node.js version: 10.24.1
OS: Ubuntu
Don't ask me why, but I was testing a package for Node.js v10 in 2023, and I stumbled upon this bug :D
The regression seems to come from the re-arrangement of the imports in uvu 0.5.6. Now, uvu/run imports uvu after a reference to globalThis
, which is something that needs polyfilling. uvu itself, as well as esm
(the package) actually take care of this, but running uvu -r esm
will polyfill globalThis
after it gets referenced.
Workaround: Run tests using node -r esm tests
instead of uvu -r esm tests
To resolve this bug, one need to either: a) require esm
before requiring uvu/run
; or b) move the included globalThis
polyfill all the way up to bin.js