Skip to content

Commit 8601855

Browse files
authored
fix(nuxt): Add @sentry/cloudflare as optional peerDependency (#16782)
In order to not have all users of the SDK auto-install the `@sentry/cloudflare` dependency, it's added as `peerDependency`. ref #15597
1 parent dccf0aa commit 8601855

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

docs/creating-a-new-sdk.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,34 @@ provide an abstraction layer of options that we expose on top of that.
144144
We generally want to support Node runtimes for the server. However, sometimes there may be alternate runtimes that may
145145
be supported, e.g. Cloudflare Workers or Vercel Edge Functions. We generally do not need to support these in an MVP, but
146146
may decide to support them later.
147+
148+
#### Cloudflare Workers/Pages
149+
150+
To add support for Cloudflare Workers or Pages in a specific SDK, you need to do the following:
151+
152+
1. Add `@sentry/cloudflare` as an optional peer dependency to the `package.json` of the SDK.
153+
This ensures that users who want to use the SDK with Cloudflare will install the necessary package, but it won't be a requirement for users on other platforms.
154+
155+
```json
156+
"peerDependencies": {
157+
"@sentry/cloudflare": ">=9.33.0"
158+
},
159+
"peerDependenciesMeta": {
160+
"@sentry/cloudflare": {
161+
"optional": true
162+
}
163+
}
164+
```
165+
166+
2. Add `@sentry/cloudflare` to the `devDependencies` in the SDK's `package.json`.
167+
This is necessary for local development and testing, allowing you to use the Cloudflare-specific APIs in the development environment.
168+
169+
```json
170+
"devDependencies": {
171+
"@sentry/cloudflare": "9.33.0",
172+
}
173+
```
174+
175+
3. Add documentation to the [Cloudflare Frameworks docs](https://docs.sentry.io/platforms/javascript/guides/cloudflare/frameworks/) explaining how to set up the SDK for Cloudflare Workers/Pages.
176+
This documentation should include instructions for users to add the `@sentry/cloudflare` package to their project.
177+
You can then link from the framework-specific docs pages to the Cloudflare SDK docs page by adding an entry to "Next Steps" on the "Getting Started" and "Manual Setup" pages.

packages/nuxt/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,17 @@
4343
"access": "public"
4444
},
4545
"peerDependencies": {
46-
"nuxt": ">=3.7.0 || 4.x"
46+
"nuxt": ">=3.7.0 || 4.x",
47+
"@sentry/cloudflare": ">=9.34.0"
48+
},
49+
"peerDependenciesMeta": {
50+
"@sentry/cloudflare": {
51+
"optional": true
52+
}
4753
},
4854
"dependencies": {
4955
"@nuxt/kit": "^3.13.2",
5056
"@sentry/browser": "9.34.0",
51-
"@sentry/cloudflare": "9.34.0",
5257
"@sentry/core": "9.34.0",
5358
"@sentry/node": "9.34.0",
5459
"@sentry/rollup-plugin": "^3.5.0",
@@ -57,6 +62,7 @@
5762
},
5863
"devDependencies": {
5964
"@nuxt/module-builder": "^0.8.4",
65+
"@sentry/cloudflare": "9.34.0",
6066
"nuxt": "^3.13.2"
6167
},
6268
"scripts": {

0 commit comments

Comments
 (0)