Issues with the handling of exports maps in package.json
Describe the bug
Vite seems to have troubles to correctly resolve node modules that have exports
defined in their package.json
. This issue includes a repro for @urql/preact
but I found the same issues with @urql/core
and wonka
. Dropping the exports
from the package.json
s helped in all cases.
EDIT: Only applicable to node 13, works with node 12
Reproduction
Add the following import to a basic vite setup:
import { createClient } from '@urql/preact';
(See https://github.com/sventschui/vite-mjs-repro/tree/urql)
System Info
- required
vite
version: 0.14.2 - required Operating System: OS X
- required Node version: 13.12.0
Logs (Optional if provided reproduction)
vite:resolve (redirect) @urql/preact -> dist/urql-preact.mjs +4ms
[vite] Error while resolving node_modules with id "@urql/preact/dist/urql-preact.mjs":
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/urql-preact.mjs' is not defined by "exports" in xxx/vite-mjs-repro/node_modules/@urql/preact/package.json
at applyExports (internal/modules/cjs/loader.js:524:9)
at resolveExports (internal/modules/cjs/loader.js:541:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:661:22)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:963:27)
at resolveFileName (xxx/vite-mjs-repro/node_modules/vite/node_modules/resolve-from/index.js:29:39)
at resolveFrom (xxx/vite-mjs-repro/node_modules/vite/node_modules/resolve-from/index.js:43:9)
at Object.module.exports [as default] (xxx/vite-mjs-repro/node_modules/vite/node_modules/resolve-from/index.js:46:47)
at xxx/vite-mjs-repro/node_modules/vite/dist/server/serverPluginModuleResolve.js:79:48
at async xxx/vite-mjs-repro/node_modules/vite/dist/server/serverPluginModuleRewrite.js:41:9 {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'