-
Notifications
You must be signed in to change notification settings - Fork 57
feat: add flow type annotations #49
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good. Would it be possible to move the .babelrc
and aegir.js
webpack settings into aegir itself? That would really reduce the boilerplate code for other projects.
.aegir.js
Outdated
// Have not used webpack so just copied proposed setup from | ||
// https://babeljs.io/docs/setup/#installation | ||
webpack: { | ||
module: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ideally we want to merge this into the aegir flow branch so that we can get inline source maps for tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With and without the file I don't get the correct line numbers. What about if I remove this completely and having proper line numbers in stack traces of the browser tests will be an open issue?
Update: Nevermind, it had to do with some Babel config. I got it working.
example.js
Outdated
@@ -1,5 +1,3 @@ | |||
'use strict' | |||
|
|||
const multihash = require('multihashes') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might still need use strict
here since this isn't a flow file.
exports.defaultLengths = cs.defaultLengths | ||
|
||
const varint = require('varint') | ||
import bs58 from 'bs58' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While now working myself on typing multibase
I came to ask: Don't you have to include type definitions for this? Or are fine with having all our externals default to any?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While now working myself on typing multibase I came to ask: Don't you have to include type definitions for this? Or are fine with having all our externals default to any?
I think in case of bs58 / varint
it might make sense to do it with something like flow-typed as API surface is tiny, but in general trying to cover all the dependencies can be a rabbit hole and in my experience it's more practical to do that afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vmx for pushing this further. Everything looks good to me.
package.json
Outdated
"buffer-equal": "1.0.0", | ||
"chai": "^4.1.2", | ||
"dirty-chai": "^2.0.1", | ||
"flow-bin": "^0.66.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend upgrading to [email protected] at this point and probably it would probably make more sense to have flow-bin bundled with aegir.
I've moved the webpack specific things from Though there is an issue now. |
Sorry I'm not that JS tooling savvy to be honest. Looking at the babel documentation it does not seems like you could provide alternative path to Given this limitation I think best option would be to add some command to |
@Gozala The plan surely is to have a an |
I must have misunderstood you. I don't really know how AEgir is set up sadly. I also realize now that it probably doesn't even makes use of babel so it's not just matter of exposing --watch as initially thought. I took another look and it seems that babel-cli has |
I also couldn't get For the record: What kind of worked with |
I think the only thing left is to move the flow stuff (the type checking command, files copying when watching and the |
I would be keen to take a stab at that. But only next week
… On Apr 11, 2018, at 3:46 PM, Volker Mische ***@***.***> wrote:
I think the only thing left is to move the flow stuff (the type checking command, files copying when watching and the .flowconfig) into AEgir. I won't have time this week, so if anyone wants to pick it up, that would be great.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
For everyone watching this PR: If shouldn't feel blocked on the changes on AEgir if you want to port other modules to Flow. You can use this PR as a template, but don't need to stay up-to-date. We'll figure things out later. |
package.json
Outdated
@@ -2,19 +2,23 @@ | |||
"name": "multihashes", | |||
"version": "0.4.13", | |||
"description": "multihash implementation", | |||
"main": "src/index.js", | |||
"main": "lib/index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this will now point at files that doesn't exists when we checkout the code right? Only after running build? How do we make this easy to work with when you have multiple modules that needs building and npm-linking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you will run a watcher (part of AEgir) in the project that you link. Is that correct @Gozala?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in practice, you would run one watcher for builds and one watcher for tests, per each project you link + top project?
I'm pretty sure this is alright, but let's check in with the person who probably links most projects currently, @diasdavid. Does the above flow work for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you will run a watcher (part of AEgir) in the project that you link. Is that correct @Gozala?
That is at least in my understand on what we agreed to try, except you don't necessary need to run watcher on linked packages that you're not making changes to.
Unfortunately, I do not have the capacity to page in into all the discussions and act as the cat herder for this one. @vmx took the lead to move this endeavor forward -- ipfs/js-ipfs#1260. I did share my thoughts and past experiences with this project on tooling and build steps here -- https://github.com/ipfs/community/issues/278. I'm pinging @hugomrdias here who has shared with me a lot of very careful thoughts on making this very smooth for devs and consumers of these modules. AFAIU, webpack 4 is a game changer, folks do not use anymore the Also, I worry that things like the notes here -- #49 (comment) -- become tribal knowledge. Some of the litmus test to move the awesome endeavor flow are:
Both these questions should have a yes answer. |
All changes I wanted to be part of AEgir are there now. Please review ipfs/aegir#213 as that's the branch that will be used if we merge this PR. |
Also configure build/test/lint scripts for Flow typed JS - Run flow check after linting - Use AEgir config to use babel-loader for webpack builds - Use different babel config for browser builds to avoid inlining source maps
Without setting the `BABEL_ENV` to `umd` failures in the Browser tests won't show the correct files/line numbers in the trace.
Transpiling with Babel is now part of AEgir.
For transpiling with Babel no project specific `.babaelrc` file is needed.
The Flow type checking is now part of `aegir lint`.
`flow-copy-source` is no longer needed as its functionality (copying files from `src` to `lib` and adding the `flow` extension) is now part of `aegir build`.
We are using TypeScript types in JSDoc instead. That endevour is tracked at ipfs/js-ipfs#2945. Hence closing this issue. Thanks everyone who were involved in trying to make Flow happen. |
Also configure build/test/lint scripts for Flow typed JS
This PR supersedes #47. I didn't want to hijack @Gozala's PR. This PR is just a cleaned up version of his work. All credits go to him.
@Gozala please review if it is still doing what it's supposed to do. I've changed the npm scripts a bit to run the build before the test runs. I also removed the hack around Mocha, it's now part of AEgir in the
flow
branch.