Skip to content

Commit fea85b5

Browse files
authored
fix: types with ipjs build (#165)
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.
1 parent 2ea467f commit fea85b5

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"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"
1717
},
1818
"devDependencies": {
19-
"lerna": "^3.22.1"
19+
"lerna": "^3.22.1",
20+
"json": "^11.0.0"
2021
},
2122
"repository": {
2223
"type": "git",

packages/ipfs-unixfs-exporter/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"prepare": "aegir build --no-bundle",
1313
"test": "aegir test",
1414
"build": "aegir build --esm-tests",
15+
"postbuild": "npx json -I -f dist/package.json -e this.types='\"src/index.d.ts\"'",
1516
"clean": "rimraf ./dist",
1617
"lint": "aegir ts -p check && aegir lint",
1718
"coverage": "nyc -s npm run test -t node && nyc report --reporter=html",

packages/ipfs-unixfs-importer/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"prepare": "aegir build --no-bundle",
1313
"test": "aegir test",
1414
"build": "aegir build --esm-tests",
15+
"postbuild": "npx json -I -f dist/package.json -e this.types='\"src/index.d.ts\"'",
1516
"clean": "rimraf ./dist",
1617
"lint": "aegir ts -p check && aegir lint",
1718
"coverage": "nyc -s npm run test -t node && nyc report --reporter=html",

packages/ipfs-unixfs/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"prepare:types": "aegir build --no-bundle",
1616
"test": "aegir test",
1717
"build": "aegir build --esm-tests",
18+
"postbuild": "npx json -I -f dist/package.json -e this.types='\"src/index.d.ts\"'",
1819
"clean": "rimraf ./dist",
1920
"lint": "aegir ts -p check && aegir lint",
2021
"coverage": "nyc -s aegir test -t node && nyc report --reporter=html",

0 commit comments

Comments
 (0)