I think the issue is with how pnpm resolves dependencies in a monorepo with isolated installs.
My use case:
Root node_modules/.pnpm:
- contains
rescript - contains
@rescript/runtime
some/app package.json:
"devDependencies": {
"rescript": "^12.0.0"
},
some/app node_modules:
- contains
rescript -
does not contain @rescript/runtime - Vite import fails because the compiled source file contains
import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js"
With pnpm’s isolated installs, a package can only import modules that appear in its own dependencies (or devDependencies), so from pnpm’s point of view some/app directly depends on @rescript/runtime and must declare it.
fix
some/app package.json:
"dependencies": {
"@rescript/runtime": "^12.0.0"
},
"devDependencies": {
"rescript": "^12.0.0"
},
not a fix
Adding rescript to dependencies does not solve the issue; you get the same error. Even if rescript itself depends on @rescript/runtime, pnpm will not expose @rescript/runtime as a direct dependency of some/app, so Node/Vite still cannot resolve it from some/app’s node_modules.
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@rescript/runtime'