Flow: Support sourcesmaps as an alternative to .flow files

Created on 21 Apr 2018  路  6Comments  路  Source: facebook/flow

We're already including sourcemaps in all of our transpiled code for debugging purposes, so it's completely redundant to also include .flow files that are (also) just 1:1 copies of the original source.

Would it be possible for flow to fall-back to using source from a provided sourcemap if there isn't a .flow file or lib def available?

feature request

All 6 comments

@MarkKahn Use echo "export * from '../src'" > dist/index.js.flow and publish sources to avoid duplication.

@TrySound - Thanks, but that doesn't actually work for us as we have loads of generated files. We're generating flow source then echoing that to .flow files, and through babel+sourcemaps

That should work if you have only one entry point specified in main field of package.json.

I don't see how with generated files. Many of our src/ folders have 1 file to hundreds in dist/

There is only one file which has an access to every api. It's entry point specified in main field. So when user import from the lib that flow file takes all types from src/index.js which is mirrored with dist/index.js.

Take a look here. It works perfectly.
https://unpkg.com/[email protected]/dist/

I appreciate that you're trying to help and your response would generally be helpful, but you're not seeming to listen when I say it doesn't work for us or that we have generated files. For example our src/index.js is often akin to:

const models = glob('../models/*.json');
models.forEach(model => writeFile(`../dist/${model.name}`, genClass(model)));

At which point dist gets populated with hundreds of files. src often does not have flow annotations in it in our codebase so pointing dist/index.js.flow at src doesn't work.

Was this page helpful?
0 / 5 - 0 ratings