Skip to content

ESM project support broken in 0.76/RN 0.72 #1026

@oblador

Description

@oblador

I'm working in an "isomorphic" project with both react-dom and react-native, where the web part is using vite that requires ESM. To make that setup work with RN/Metro that is still heavily reliant on CJS I simply renamed the metro.config.js to metro.config.cjs to force it to resolve using CJS.

With the latest version of RN (0.72.1) this setup yields No metro config found, and if I rename it to .js and use esm it throws errors originating from metro for using requires in an esm context.

My guess this is originates in an update of cosmiconfig or similar. UPDATE: It seems cosmiconfig hasn't been updated in 5 years, so shouldn't be the cause.

Even though RN setup says Node 16+, metro requires 18+ so maybe this upgrade is somehow related, but with 0.71.x it works fine.

Another solution would be to properly support ESM/TS in the config as suggested in #916

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions