Skip to content

Commit

Permalink
Added npm linking instructions, fixes #36
Browse files Browse the repository at this point in the history
  • Loading branch information
CMCDragonkai committed Mar 21, 2022
1 parent f86591a commit 5299b37
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,27 @@ Due to https://github.com/microsoft/TypeScript/issues/10866, you cannot use path

However, we have left the path alias configuration in `tsconfig.json`, `jest.config.js` and in the tests we are making use of the `@` alias.

### Local Package Linking

When developing on multiple NPM packages, it can be easier to use `npm link` so that changes are immediately reflected rather than repeatedly publishing packages. To do this, you need to use `npm link`. After linking a local directory, you need to provide `tsconfig.json` paths so TypeScript compiler can find the right files.

For example when linking `@matrixai/db` located in `../js-db`:

```sh
npm link ../js-db
```

You would need to add these paths to `tsconfig.json`:

```
"paths": {
"@": ["index"],
"@/*": ["*"],
"@matrixai/db": ["../node_modules/@matrixai/db/src"],
"@matrixai/db/*": ["../node_modules/@matrixai/db/src/*"]
},
```

### Native Module Toolchain

There are some nuances when packaging with native modules.
Expand Down
3 changes: 3 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ in
set +o allexport
set -v
# Enables npm link
export npm_config_prefix=~/.npm
export PATH="$(pwd)/dist/bin:$(npm bin):$PATH"
# pkg is installed in package.json
Expand Down

0 comments on commit 5299b37

Please sign in to comment.