teamhanko / hanko

The complete Authentication and User Management solution for developers.
https://hanko.io
Other
5.74k stars 805 forks source link

Update package.json #1504

Closed Fohlen closed 2 months ago

Fohlen commented 3 months ago

Fixes issue in Node 22 of Hanko not being a valid module

Description

In Node 22 the following error is generated when installing Hanko Elements:

(node:30657) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)

You can try this out by:

This is caused by the fact that HankoElements is not declared as an ESM module correctly. As Node.js is migrating away from CommonJS, this is a rather known bug in many packages. To fix this issue, you have two options:

The later however isn't really supported by browsers.

Tests

Updating the package.json of an installed Hanko Elements with the proposed diff "just works" and unbreaks builds.

Additional context

I attached a vite_build.log log for reference.