Custom resolver in FlowType

Viewed 33

We're using a custom resolver to figure out where a certain import points to, mostly to support overwriting default behavior throughout instances of a base library. The structure of our project is pretty much this:

-base/
-instanceA/
-instanceB/
-.flowconfig

We support a special alias, let's call it @app, that tries to import files from the current instance, but fallbacks to base if the file is not found. So, if an import like

import Colors from '@app/theme/colors';

is found in a file from instanceB, this will be resolved to instanceB/theme/colors if such a file exists, or to base/theme/colors otherwise.

I am trying to replicate this behavior using Flow, but the configuration mechanism doesn't seem powerful enough (module.name_mapper comes close to this, but it's pretty much only a string replacement).

Did anyone experience this before, and maybe found a hack around it?

1 Answers
Related