Skip to content
This repository was archived by the owner on Aug 24, 2021. It is now read-only.

Commit 7800e62

Browse files
Gozalavmx
authored andcommitted
feat: add flow type annotations
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
1 parent 96576b9 commit 7800e62

File tree

9 files changed

+801
-718
lines changed

9 files changed

+801
-718
lines changed

.aegir.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict'
2+
3+
module.exports = {
4+
// Have not used webpack so just copied proposed setup from
5+
// https://babeljs.io/docs/setup/#installation
6+
webpack: {
7+
module: {
8+
rules: [
9+
{
10+
test: /\.js$/,
11+
exclude: /node_modules/,
12+
loader: 'babel-loader'
13+
}
14+
]
15+
}
16+
}
17+
}

.babelrc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"env": {
3+
"development": {
4+
"sourceMaps": "inline",
5+
"comments": false,
6+
"presets": [
7+
[
8+
"env",
9+
{
10+
"targets": {
11+
"node": "current"
12+
}
13+
}
14+
],
15+
"flow-node"
16+
]
17+
},
18+
"umd": {
19+
"comments": false,
20+
"presets": [
21+
[
22+
"env",
23+
{
24+
"modules": false,
25+
"targets": {
26+
"browsers": "last 2 versions"
27+
}
28+
}
29+
],
30+
"flow-node"
31+
]
32+
}
33+
}
34+
}

.flowconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[ignore]
2+
.*/node_modules/documentation/*
3+
4+
[libs]
5+
6+
[include]
7+
8+
[options]
9+
suppress_comment= \\(.\\|\n\\)*\\@FlowIgnore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ node_modules
3535

3636
dist
3737
docs
38+
lib

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ install:
2424
- npm install
2525

2626
test_script:
27+
- npm run build:node
2728
- npm run test:node
2829

2930
build: off

package.json

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@
22
"name": "multihashes",
33
"version": "0.4.13",
44
"description": "multihash implementation",
5-
"main": "src/index.js",
5+
"main": "lib/index.js",
66
"scripts": {
7-
"lint": "aegir lint",
8-
"test:browser": "aegir test --target browser",
9-
"test:node": "aegir test --target node",
10-
"build": "aegir build",
11-
"test": "aegir test",
7+
"lint": "aegir lint && npm run type-check",
8+
"test:browser": "npm run build && aegir test --target browser",
9+
"test:node": "npm run build:node && aegir test --target node",
10+
"type-check": "flow check",
11+
"build": "npm run build:node && BABEL_ENV=umd aegir build",
12+
"test": "npm run build:node && aegir test",
1213
"docs": "aegir docs",
1314
"release": "aegir release --docs",
1415
"release-minor": "aegir release --type minor --docs",
1516
"release-major": "aegir release --type major --docs",
1617
"coverage": "aegir coverage",
17-
"coverage-publish": "aegir coverage --provider coveralls"
18+
"coverage-publish": "aegir coverage --provider coveralls",
19+
"build:types": "flow-copy-source --verbose src lib",
20+
"build:lib": "babel --out-dir lib src",
21+
"build:node": "npm run build:types && npm run build:lib",
22+
"start": "flow-copy-source --watch --verbose src lib & babel --watch --out-dir lib src"
1823
},
1924
"pre-commit": [
2025
"lint",
@@ -42,10 +47,16 @@
4247
"varint": "^5.0.0"
4348
},
4449
"devDependencies": {
45-
"aegir": "^12.3.0",
50+
"aegir": "git+https://github.com/ipfs/aegir#flow",
51+
"babel-cli": "6.26.0",
52+
"babel-core": "6.26.0",
53+
"babel-loader": "7.1.2",
54+
"babel-preset-flow-node": "2.0.1",
4655
"buffer-equal": "1.0.0",
4756
"chai": "^4.1.2",
4857
"dirty-chai": "^2.0.1",
58+
"flow-bin": "^0.66.0",
59+
"flow-copy-source": "^1.2.0",
4960
"pre-commit": "^1.2.2"
5061
},
5162
"contributors": [

0 commit comments

Comments
 (0)