Skip to content

Commit

Permalink
chore: added local dev instructions using local paths intead of pnpm …
Browse files Browse the repository at this point in the history
…link (#1189)

* added local dev instructions using local paths intead of pnpm link

* a few more docs
  • Loading branch information
dmarticus authored May 21, 2024
1 parent 5569435 commit c6154d7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,25 @@ You can use the create react app setup in `playground/nextjs` to test posthog-js

## Developing together with another project

Install pnpm to link a local version of `posthog-js` in another JS project: `npm install -g pnpm`
Install pnpm to link a local version of `posthog-js` in another JS project: `npm install -g pnpm`

#### Run this to link the local version
### Run this to link the local version

We have 2 options for linking this project to your local version: via [pnpm link](https://docs.npmjs.com/cli/v8/commands/npm-link) or via [local paths](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#local-paths)

#### local paths (preferred)

- from whichever repo needs to require `posthog-js`, go to the `package.json` of that file, and replace the `posthog-js` dependency version number with `file:<relative_or_absolute_path_to_local_module>`
- e.g. from the `package.json` within `posthog`, replace `"posthog-js": "1.131.4"` with `"posthog-js": "file:../posthog-js"`
- run `pnpm install` from the root of the project in which you just created a local path

Then, once this link has been created, any time you need to make a change to `posthog-js`, you can run `pnpm build` from the `posthog-js` root and the changes will appear in the other repo.

#### `pnpm link`

- In the `posthog-js` directory: `pnpm link --global`
- (for `posthog` this means: `pnpm link --global posthog-js && pnpm i && pnpm copy-scripts`)
- You can then remove the link with `pnpm link --global posthog-js

- You can then remove the link by, e.g., running `pnpm link --global posthog-js` from within `posthog`

## Releasing a new version

Expand All @@ -73,9 +83,11 @@ To release an alpha or beta version, you'll need to use the CLI locally:
2. Make sure you're logged into the npm CLI (`npm login`).
3. Check out your work-in-progress branch (do not release an alpha/beta from `main`).
4. Run the following commands, using the same bump level (major/minor/patch) as your PR:

```bash
npm version [premajor | preminor | prepatch] --preid=beta
npm publish --tag beta
git push --tags
```

5. Enjoy the new prerelease version. You can now use it locally, in a dummy app, or in the [main repo](https://github.com/posthog/PostHog).

0 comments on commit c6154d7

Please sign in to comment.