Skip to content

Commit

Permalink
move internal dependency to devDependencies (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
bucko13 authored Jun 10, 2024
1 parent 9d912f6 commit 7e34665
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/forty-dolphins-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@caravan/wallets": patch
"@caravan/psbt": patch
---

move internal deps to devDependencies
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,26 @@ anything else that relies on it should be tested to make sure they're not broken
If you want to break this coupling, a published package version can be referenced instead of
using `*` (this is not recommended however).

#### Note about internal packages

Sometimes it makes sense to move code you want to share between packages into an internal package.
In fact this is [recommended by Turborepo](https://turbo.build/repo/docs/crafting-your-repository/creating-an-internal-package#best-practices-for-internal-packages).

> When you're creating Internal Packages, it's recommended to create packages that have a single "purpose".
Internal packages should be added to the `devDependencies` list of the packages/apps that depend on them.
This is because the bundlers (tsup by default in caravan) won't include `dependencies` into the bundle
and then when the package is attempted to be installed by external downstream projects it will try
and find the internal dependency in a remote registry (which will fail). By including it in the
devDependency:

* the dependency graph will be correct
* the bundler will build it in with the final package
* other projects won't try and install the internal dependency

@caravan/multisig is an example of such a package that is depended on by other packages
like @caravan/psbt and @caravan/wallets.

### Adding a new package
NOTE: Turborepo provides [code generator capability](https://turbo.build/repo/docs/core-concepts/monorepos/code-generation)
for bootstrapping a new project. You can run `turbo gen` or `npm run gen`
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/caravan-psbt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
],
"dependencies": {
"@caravan/bitcoin": "*",
"@caravan/multisig": "*",
"bignumber.js": "^8.1.1",
"bip174": "^2.1.1",
"bitcoinjs-lib-v6": "npm:bitcoinjs-lib@^6.1.5",
Expand All @@ -52,6 +51,7 @@
"author": "unchained capital",
"license": "ISC",
"devDependencies": {
"@caravan/multisig": "*",
"@caravan/eslint-config": "*",
"@caravan/typescript-config": "*",
"@inrupt/jest-jsdom-polyfills": "^3.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/caravan-wallets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@babel/preset-env": "^7.7.1",
"@babel/preset-typescript": "^7.18.6",
"@caravan/eslint-config": "*",
"@caravan/multisig": "*",
"@caravan/typescript-config": "*",
"@inrupt/jest-jsdom-polyfills": "^3.2.1",
"@types/jest": "^29.5.12",
Expand Down Expand Up @@ -81,7 +82,6 @@
"@babel/polyfill": "^7.7.0",
"@babel/runtime": "^7.23.9",
"@caravan/bitcoin": "*",
"@caravan/multisig": "*",
"@caravan/psbt": "*",
"@ledgerhq/hw-app-btc": "^5.34.1",
"@ledgerhq/hw-transport-u2f": "^5.34.0",
Expand Down
3 changes: 0 additions & 3 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
]
},
"dev": {
"dependsOn": [
"^dev"
],
"cache": false,
"persistent": true
},
Expand Down

0 comments on commit 7e34665

Please sign in to comment.