Skip to content

Commit

Permalink
fix: types with ipjs build (#165)
Browse files Browse the repository at this point in the history
Currently, the published package.json has `"types": "dist/src/index.d.ts"` and should be `"types": "src/index.d.ts",` according to where the types really are.

The problem here is that we need to both:
- have type paths correct in the dist folder
- have type paths correct for local dev in src

Given the path will change, we need to guarantee this is updated in the build `package.json`. Using an approach like `multiformats` and `uint8arrays` having a `types` folder which is moved to `dist` is not possible because of the inline `d.ts` files in this repo, which will be inside `dist` folder as `dist/src/*.d.ts`, breaking the imports from the types around it.

With the above in mind, this PR adds a postbuild script where the package.json is changed in post build to have `dist` removed.
  • Loading branch information
vasco-santos authored Aug 19, 2021
1 parent 2ea467f commit fea85b5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"update-contributors": "aegir release --lint=false --test=false --bump=false --build=false --changelog=false --commit=false --tag=false --push=false --ghrelease=false --docs=false --publish=false"
},
"devDependencies": {
"lerna": "^3.22.1"
"lerna": "^3.22.1",
"json": "^11.0.0"
},
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions packages/ipfs-unixfs-exporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"prepare": "aegir build --no-bundle",
"test": "aegir test",
"build": "aegir build --esm-tests",
"postbuild": "npx json -I -f dist/package.json -e this.types='\"src/index.d.ts\"'",
"clean": "rimraf ./dist",
"lint": "aegir ts -p check && aegir lint",
"coverage": "nyc -s npm run test -t node && nyc report --reporter=html",
Expand Down
1 change: 1 addition & 0 deletions packages/ipfs-unixfs-importer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"prepare": "aegir build --no-bundle",
"test": "aegir test",
"build": "aegir build --esm-tests",
"postbuild": "npx json -I -f dist/package.json -e this.types='\"src/index.d.ts\"'",
"clean": "rimraf ./dist",
"lint": "aegir ts -p check && aegir lint",
"coverage": "nyc -s npm run test -t node && nyc report --reporter=html",
Expand Down
1 change: 1 addition & 0 deletions packages/ipfs-unixfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"prepare:types": "aegir build --no-bundle",
"test": "aegir test",
"build": "aegir build --esm-tests",
"postbuild": "npx json -I -f dist/package.json -e this.types='\"src/index.d.ts\"'",
"clean": "rimraf ./dist",
"lint": "aegir ts -p check && aegir lint",
"coverage": "nyc -s aegir test -t node && nyc report --reporter=html",
Expand Down

0 comments on commit fea85b5

Please sign in to comment.