Skip to content

No obvious way to disable haste implementation #1592

@jzaefferer

Description

@jzaefferer

https://metrobundler.dev/docs/configuration/#hasteimplmodulepath documents how to map files for the haste opt-in mechanism. The default config for React Native seems to enable this for any file, like import Foo from 'Foo'

Since Jest does not support this, we want to turn this feature off, so we don't end up with imports that are only valid in metro, but not in jest.

Following the docs, this seems like the right implementation for that:

module.exports = {
  getHasteName() {
    return null;
  },
};

With hasteImplModulePath: './nullHasteImpl.js', in our metro.config.js.

Yet when starting metro, we always get this error:

metro-file-map: Expected `./nullHasteImpl.js` to export `getCacheKey: () => string`

I tried to implement variations of getCacheKey as a separate export or a return value inside of getHastName, but nothing makes a difference.

Are we doing it wrong? Or is this a bug in the hasteImplModulePath implementation? Or in the documentation?

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