the lib use require and module.paths API to resolve the package.json file. these API call cannot be transformed into equivalent API call in es module, which make it incompatible with some build systems(vite). it throw the following exception
Uncaught Exception:
TypeError: module2.paths is not iterable at detectPackageJson
it's because loadPackageJson fail.
Could not dynamically require ".../package.json". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.
Unfortunately, somehow configure dynamicRequireTargets as the error hint doesn't solve the problem, maybe it's because the pre-bundle mechanism in vite.
I think allow the user to pass in package.json directly is the quickest way to solve the problem.
the lib use
require
andmodule.paths
API to resolve thepackage.json
file. these API call cannot be transformed into equivalent API call in es module, which make it incompatible with some build systems(vite). it throw the following exceptionit's because loadPackageJson fail.
Unfortunately, somehow configure
dynamicRequireTargets
as the error hint doesn't solve the problem, maybe it's because thepre-bundle
mechanism in vite. I think allow the user to pass in package.json directly is the quickest way to solve the problem.