I'm wondering why is that tsup not shimming the require.resolve correctly?
Adding this shim myself, before using require works correctly:
const require_ = createRequire(
__filename ??
// @ts-expect-error Forward compat. The `import.meta` meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.
import.meta.url,
)
This error is thrown by Vitest, when running tests against a project using a package compiled by
tsup
.The bundled code of
lib/index.mjs
looks like this:Here's the
tsup.config.json
that was used to build the library:I'm wondering why is that
tsup
not shimming therequire.resolve
correctly?Adding this shim myself, before using
require
works correctly:Package versions:
Related Issues
tsup
issue that says it was fixed: https://github.com/egoist/tsup/issues/369esbuild
: https://github.com/evanw/esbuild/issues/1921#issuecomment-1898197331Upvote & Fund