rescript-lang / rescript-lang/rescript-react
Bindings to React modules are incompatible with node ESM
Nobody has claimed this yet.
- Dominant language
- ReScript
- Stars
- 517
- Forks
- 45
- PR merge metrics
- No merged PRs in 30d
Description
hello 👋
great work on the release!
I just found out that the new bindings, omitting the .js extension break when using node in ESM mode, as it tries to resolve to .mjs when unspecified. It currently breaks ReScript Pages (https://github.com/bloodyowl/rescript-pages/tree/upgrade-rescript-react) at runtime with the following error:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Volumes/Dev/bloodyowl/rescript-pages/node_modules/react/jsx-runtime' imported from /Volumes/Dev/bloodyowl/rescript-pages/src/PagesServer.mjs
Did you mean to import react/jsx-runtime.js?
at new NodeError (node:internal/errors:393:5)
at finalizeResolution (node:internal/modules/esm/resolve:305:11)
at moduleResolve (node:internal/modules/esm/resolve:866:10)
at defaultResolve (node:internal/modules/esm/resolve:1074:11)
at nextResolve (node:internal/modules/esm/loader:164:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:839:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:426:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
at link (node:internal/modules/esm/module_job:75:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
and will most likely break any project in this configuration.
would you consider a PR adding the extensions back into the declarations?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure using the ReScript Pages upgrade linked in the report and inspect the generated src/PagesServer.mjs import of react/jsx-runtime. Trace where the React module declarations are generated and verify the emitted imports under Node ESM. Done means the generated bindings resolve at runtime without ERR_MODULE_NOT_FOUND.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100