Call instead of inlining a body that names a module the caller can't load
Why
A body stored in a .cmj can name modules of packages its own package depends on. A package depending on that one usually does not have them on its load path, so inlining the body failed the build. This is PR 4 of the plan in #8733 (problem 2.9).
modifiedJS with -bs-cross-module-opt; app depends on p, p on q
// node_modules/p/src/PMod.res@inline let f = x => QMod.g(x) + 1@inline let k = x => x * 2 // app/src/App.reslet viaQ = PMod.f(2)let local = PMod.k(2)
diagnostic
QMod not found, it means either the module does not exist or it is a namespacejs
import * as PMod from "p/src/PMod.mjs"; let viaQ = PMod.f(2); let local = 4;
Review
- Does looking a module up change the imports? No. The check reads this compile's module cache and the load path, and does not register the module, since registered modules with side effects get imported.