jiti
jiti copied to clipboard
cannot resolve esm-only modules with `import` condition and yarn pnp
Environment
Node 21.5.0, yarn 4.0.2, macOS 14.2.1 (23C71)
Reproduction
See the steps detailed here https://github.com/nksaraf/vinxi/issues/43, vinxi fixed yarn berry compat by disabling jiti when not using a typescript vite.config.ts
file, but it's still broken due jiti calling require.resolve with the wrong import conditions in the default setup (having a .ts config file)
Describe the bug
See also the linked issue above and run the reproduction steps
daniel@mmmmmmmmmm my-app % yarn dev
Error: Package subpath './lib/chunks' is not defined by "exports" in /Users/daniel/.yarn/berry/cache/vinxi-npm-0.0.54-94f4086925-10c0.zip/node_modules/vinxi/package.json imported from /private/tmp/solid-start-x/my-app/.yarn/__virtual__/@vinxi-server-functions-virtual-824b5314c0/5/Users/daniel/.yarn/berry/cache/@vinxi-server-functions-npm-0.0.51-9542aa8426-10c0.zip/node_modules/@vinxi/server-functions/
Require stack:
- /private/tmp/solid-start-x/my-app/.yarn/__virtual__/@vinxi-server-functions-virtual-824b5314c0/5/Users/daniel/.yarn/berry/cache/@vinxi-server-functions-npm-0.0.51-9542aa8426-10c0.zip/node_modules/@vinxi/server-functions/client.js
at require$$0.Module._resolveFilename (/private/tmp/solid-start-x/my-app/.pnp.cjs:12657:13)
at Function.resolve (node:internal/modules/helpers:187:19)
at _resolve (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:251148)
at jiti (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:253746)
at /private/tmp/solid-start-x/my-app/.yarn/__virtual__/@vinxi-server-functions-virtual-824b5314c0/5/Users/daniel/.yarn/berry/cache/@vinxi-server-functions-npm-0.0.51-9542aa8426-10c0.zip/node_modules/@vinxi/server-functions/client.js:3:15
at evalModule (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:256443)
at jiti (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:254371)
at /private/tmp/solid-start-x/my-app/.yarn/__virtual__/@vinxi-server-functions-virtual-824b5314c0/5/Users/daniel/.yarn/berry/cache/@vinxi-server-functions-npm-0.0.51-9542aa8426-10c0.zip/node_modules/@vinxi/server-functions/plugin.js:3:15
at evalModule (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:256443)
at jiti (/Users/daniel/.yarn/berry/cache/jiti-npm-1.21.0-baebd5985a-10c0.zip/node_modules/jiti/dist/jiti.js:1:254371)
Additional context
No response
Logs
No response