Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary copies #16

Open
rhoskal opened this issue Aug 27, 2018 · 3 comments
Open

Unnecessary copies #16

rhoskal opened this issue Aug 27, 2018 · 3 comments

Comments

@rhoskal
Copy link

rhoskal commented Aug 27, 2018

I came across this on my journey learning how to export my own npm module's flow types. While this module does save a lot of "hand jamming", it also copies EVERY *.{js,mjs,jsx} even if they don't have the Flow Type annotation comment (e.g. // @flow or /* @flow */) thus "bloating" the lib/ or dist/ folders. The most simplistic and elegant approach I came up with was to use a simple one-liner script in my package.json

  "scripts": {
    "build": "babel src/ -d lib/ && yarn copy-flow-source",
    "copy-flow-source": "for f in `grep --include=\\*.js -rlw src/ -e '^//\\s*@flow'`; do cp ${f} lib/${f#*/}.flow; done;",
    ...
  }

This would be a nice feature to add to your module, however I'm not sure kefir read contents of files like grep can. This way we follow the philosophy of keeping modules as lean as possible.

@Macil
Copy link
Owner

Macil commented Aug 28, 2018

Do you have many javascript files that don't use Flow? (Do you think it might be common to have many non-Flow .js files in projects using flow-copy-source?) This feature wouldn't be too hard to implement, but I'm not sure I want to add the performance or conceptual overhead for what might be a rare case.

@rhoskal
Copy link
Author

rhoskal commented Aug 28, 2018

Probably not if you are starting a project from scratch. However, I could definitely see how this "enhancement" would be beneficial if you are transitioning legacy code--especially on a large code base. You definitely don't have to commit the work since both of we both have working solutions to solve each of our point of views. Just my 2 cents.

@ilyalesik
Copy link

@hansjhoffman you can try to use https://github.com/ilyalesik/gen-flow-files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants