Skip to content

Support ES Module / Typescript config #916

Description

@acalvino4

Feature request: support typescript / esm config

What is the current behavior?

Metro does not look for a metro.config.ts, and if it did, I have no idea whether it would be configurable as a module.

This seems necessary sooner or later, as the ecosystem is moving to modules, and majority of people are using typescript (RN just made it the default for new projects).

What is the desired behavior?

Metro uses metro.config.ts if it exists, and the docs include an example of what this looks like.

Activity

  1. self-assigned this
    on Mar 13, 2023
  2. karlhorky commented on Mar 27, 2024

    @karlhorky

    Update on ESM configs:

    In the other issue @robhogan mentioned that ESM configs will need to wait until Node.js v20 is used for the react-native projects:

  3. stefan-schweiger commented on Dec 3, 2024

    @stefan-schweiger

    Now that we have ESM support for react-native.config files how about metro.config?

  4. CodeWithShreyans commented on Mar 20, 2025

    @CodeWithShreyans

    Is this being reconsidered now?

  5. Sid110307 commented on Mar 20, 2025

    @Sid110307

    Any update?

  6. sam-warren-finnair2 commented on Nov 11, 2025

    @sam-warren-finnair2

    I ran into this problem today as well. All files apart from this are now in ESM format, so this is quite frustrating having to find a workaround for.

  7. rdnsan commented on Nov 13, 2025

    @rdnsan

    Any update on this?

  8. robhogan commented on Nov 28, 2025

    @robhogan
    Collaborator

    Metro now supports ESM and TS (requires Node 22+) configs, I still need to update the docs.

    https://github.com/facebook/metro/releases/tag/v0.83.2

  9. Master-Antonio commented on Dec 9, 2025

    @Master-Antonio

    Metro now supports ESM and TS (requires Node 22+) configs, I still need to update the docs.

    https://github.com/facebook/metro/releases/tag/v0.83.2

    How to enable? I have 0.83.3 but still this error

    Image
    
    const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
    /**
     * Metro configuration
     * https://reactnative.dev/docs/metro
     *
     * @type {import('@react-native/metro-config').MetroConfig}
     */
    const config = {};
    module.exports = mergeConfig(getDefaultConfig(__dirname), config);
    
  10. robhogan commented on Dec 9, 2025

    @robhogan
    Collaborator

    @Master-Antonio we’re talking about the config file itself being ESM or TypeScript (eg metro.config.mts). I’m not sure what you’re trying to do there, but please open a separate issue.

  11. zowebs commented on Dec 9, 2025

    @zowebs

    Metro now supports ESM and TS (requires Node 22+) configs, I still need to update the docs.

    https://github.com/facebook/metro/releases/tag/v0.83.2

    @robhogan Can you update the docs accordingly?

  12. dominicinkfnd commented on Jan 27, 2026

    @dominicinkfnd

    Why does resolveRequest not exist on config.resolver (expo 54.0.32)?

    https://docs.expo.dev/versions/latest/config/metro/

    // Doesn't exist on config type from
    // import { getDefaultConfig } from 'expo/metro-config';
    // const config = getDefaultConfig(__dirname);
    
    config.resolver.resolveRequest = (context, moduleName, platform) => {
    
    Image
  13. stevezhu commented on Feb 10, 2026

    @stevezhu

    With the esm or ts config, expo/metro-config now needs to be imported with the js extension because there are no package.json exports for expo, and node esm requires extensions for file imports.

    - import { getDefaultConfig } from "expo/metro-config";
    + import { getDefaultConfig } from "expo/metro-config.js";

    Would be nice if the exports field could be added to the expo package.json so that we can go back to importing with just expo/metro-config.

  14. kraenhansen commented on Feb 11, 2026

    @kraenhansen
    Contributor

    Would be nice if the exports field could be added to the expo package.json

    @stevezhu sounds like a great candidate for a PR 😉💙

  15. robhogan commented on Aug 31, 2026

    @robhogan
    Collaborator

    Closing as done - ESM and TypeScript configs shipped in Metro 0.83.2, and the docs now cover the supported filenames and the Node version requirements.

    @dominicinkfnd that's a separate question about Expo's config types rather than this issue - please raise it at https://github.com/expo/expo if it's still happening.

  16. karlhorky commented on Aug 31, 2026

    @karlhorky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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