Search code examples
webpackflowtypepackage.jsonyarn-workspaces

How to fix flow to look at package.json “module” instead of “main”


I'm currently importing a yarn workspace package that has the main and module field defined in the package.json

{
  "name": "@mycompany/utils",
  "version": "0.0.3",
  "main": "dist/index.js",
  "module": "src/index.js"
}

My create-react-app setup automatically uses the module through webpack but flow is complaining that @mycompany/utils package is undefined.

So my question is how do I flow to look at the module path instead of main

Edit: I realize I wasn't clear when I first asked the question

  • Note: This is important. I want to be able to have updates to the flow types while developing without having to re-build every time I make changes.

Solution

  • you could publish a flow version of your source as dist/index.js.flow within this file, you can have export * from '../src/index.mjs';