Repository navigation
docs: Add guide for testing SDK packages with pnpm link #25512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Using `pnpm link` for Local SDK Testing | ||
|
|
||
| [`pnpm link`](https://pnpm.io/cli/link) symlinks a local SDK package into a test project. Changes are available in the | ||
| test project after a rebuild, without a publish step. For packages where linking causes problems (e.g. SvelteKit or | ||
| Angular), use [`yalc`](./using-yalc.md) instead. | ||
|
|
||
| ## Building packages | ||
|
|
||
| Build the SDK package and the packages it depends on. Run this in the root of the repo: | ||
|
|
||
| ```sh | ||
| pnpm run build:dev:filter @sentry/node # or any other SDK package | ||
| ``` | ||
|
|
||
| ## Linking packages | ||
|
|
||
| In your test project, run `pnpm link` with the path to the SDK package: | ||
|
|
||
| ```sh | ||
| pnpm link /path/to/sentry-javascript/packages/node | ||
| ``` | ||
|
|
||
| You only need to link the SDK package that your project imports. Its dependencies (e.g. `@sentry/core`) resolve from | ||
| the monorepo, so they are also the local versions. If your project also imports a dependency directly (e.g. | ||
| `@sentry/core`), that import still uses the version from the registry. Link that package too. | ||
|
|
||
| `pnpm link` adds a `link:` override to the `pnpm-workspace.yaml` of your test project. If the file does not exist, | ||
| `pnpm link` creates it. Do not commit this override. | ||
|
|
||
| ## Updating packages | ||
|
|
||
| The link points to the `build/` folder of the package. After a code change, rebuild the package and restart your test | ||
| project. You do not need to link again. | ||
|
|
||
| ```sh | ||
| # in the package you changed, e.g. packages/core | ||
| pnpm run build:transpile | ||
| ``` | ||
|
|
||
| ## Unlinking packages | ||
|
|
||
| In your test project, run `pnpm unlink` with the package name. This removes the `link:` override and installs the | ||
| registry version again. | ||
|
|
||
| ```sh | ||
| pnpm unlink @sentry/node | ||
| ``` | ||
|
|
||
| In pnpm 10, `pnpm unlink` shows "Nothing to unlink" and does not remove the override. Remove the override | ||
| for the package from `pnpm-workspace.yaml` manually, then run `pnpm install`. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### My test project still uses the registry version | ||
|
|
||
| Make sure that `node_modules/@sentry/node` in your test project is a symlink to the monorepo: | ||
|
|
||
| ```sh | ||
| ls -la node_modules/@sentry/node | ||
| ``` | ||
|
|
||
| If you run Node.js or your bundler with `--preserve-symlinks`, dependencies resolve from the `node_modules` of your | ||
| test project and not from the monorepo. Do not use this flag. | ||
|
|
||
| ### My test project uses Vite and I still don't see changes | ||
|
|
||
| Vite pre-bundles and caches dependencies for dev builds. Run `vite dev --force` to clear the cache. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: We're on v12. Is it still worth to mention pnpm v10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran into this which is why it was there but fair. Removing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, just because we use 12 in the repo, doesn't mean external projects you are trying to link into use 12. Keeping it.