Skip to content

Conversation

@pimterry
Copy link
Contributor

Registry.js doesn't actually have a default import.

Its output is CJS (this is effectively what's being imported) and exports an explicit list of fields with no default set.

Node.js will emulate a fake default export in this case to make this work regardless, but some other environments (most notably ts-node & tsx) won't do that, which makes this fail. To repro:

Clone this repo, npm install tsx, then:

> node --import tsx -e "require('.')"
.../win-detect-browsers/lib/registry.js:5
const HKEY = registry.HKEY
                      ^

TypeError: Cannot read properties of undefined (reading 'HKEY')

Really this should fail - the equivalent ESM code for this module would really be a set of named exports, with no default export. This PR fixes that so this can be used with tsx/ts-node, and makes the import conceptually more correct by pulling the module namespace that's actually being exported.

Copy link
Owner

@vweevers vweevers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks!

@vweevers vweevers merged commit daf13e5 into vweevers:master Nov 14, 2025
3 checks passed
@vweevers
Copy link
Owner

Released in 8.0.1 / 8.0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants