facebook / flow

Adds static typing to JavaScript to improve developer productivity and code quality.
https://flow.org/
MIT License
22.09k stars 1.86k forks source link

Support sourcesmaps as an alternative to .flow files #6180

Closed ghost closed 1 year ago

ghost commented 6 years ago

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?

TrySound commented 6 years ago

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

ghost commented 6 years ago

@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

TrySound commented 6 years ago

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

ghost commented 6 years ago

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

TrySound commented 6 years ago

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/react-beautiful-dnd@7.1.0/dist/

ghost commented 6 years ago

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.