The package.json says type: commonjs, but the contents of the package on npm is ESM. This works with metro because it brut force transpiles everything to CJS regardless, but breaks when you want to use this module with tooling that rely on node semantics, which is pretty much any other tool, including jest in esm mode.
The only reason I can think of why you would do this is that you have issues using jest mocks from react native locally in the package itself, but IMHO that's internals that can be solved in a different way and shouldn't be a reason to ship a broken package.
I see a few different options:
- change type to be module like your other packages
- ship CJS instead of ESM
- rename files/imports to .mjs
with no 1 being the easiest
The
package.jsonsaystype: commonjs, but the contents of the package on npm is ESM. This works with metro because it brut force transpiles everything to CJS regardless, but breaks when you want to use this module with tooling that rely on node semantics, which is pretty much any other tool, including jest in esm mode.The only reason I can think of why you would do this is that you have issues using jest mocks from react native locally in the package itself, but IMHO that's internals that can be solved in a different way and shouldn't be a reason to ship a broken package.
I see a few different options:
with no 1 being the easiest