Skip to content

Bindings to React modules are incompatible with node ESM #88

Open
@bloodyowl

Description

@bloodyowl

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions