Skip to content

Commit dff8f1b

Browse files
committed
feat(cloudflare): Add dev/prod bundle in favor of spotlight
1 parent bd9bc63 commit dff8f1b

5 files changed

Lines changed: 32 additions & 35 deletions

File tree

.size-limit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ module.exports = [
436436
// Cloudflare SDK (ESM) - compressed, minified to match `wrangler deploy --dry-run --minify` output
437437
{
438438
name: '@sentry/cloudflare (withSentry) - minified',
439-
path: 'packages/cloudflare/build/esm/index.js',
439+
path: 'packages/cloudflare/build/esm/prod/index.js',
440440
import: createImport('withSentry', 'instrumentDurableObjectWithSentry', 'instrumentWorkflowWithSentry'),
441441
ignore: [...builtinModules, ...nodePrefixedBuiltinModules],
442442
gzip: false,
@@ -456,7 +456,7 @@ module.exports = [
456456
// Cloudflare SDK (ESM) - uncompressed, unminified to match `wrangler deploy --dry-run` output
457457
{
458458
name: '@sentry/cloudflare (withSentry)',
459-
path: 'packages/cloudflare/build/esm/index.js',
459+
path: 'packages/cloudflare/build/esm/prod/index.js',
460460
import: createImport('withSentry', 'instrumentDurableObjectWithSentry', 'instrumentWorkflowWithSentry'),
461461
ignore: [...builtinModules, ...nodePrefixedBuiltinModules],
462462
gzip: false,

packages/cloudflare/package.json

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,40 @@
1212
"files": [
1313
"/build"
1414
],
15-
"main": "build/cjs/index.js",
16-
"module": "build/esm/index.js",
15+
"main": "build/cjs/prod/index.js",
16+
"module": "build/esm/prod/index.js",
1717
"types": "build/types/index.d.ts",
1818
"exports": {
1919
"./package.json": "./package.json",
2020
".": {
21-
"import": {
22-
"types": "./build/types/index.d.ts",
23-
"default": "./build/esm/index.js"
21+
"types": "./build/types/index.d.ts",
22+
"development": {
23+
"import": "./build/esm/dev/index.js",
24+
"require": "./build/cjs/dev/index.js"
2425
},
25-
"require": {
26-
"types": "./build/types/index.d.ts",
27-
"default": "./build/cjs/index.js"
26+
"production": {
27+
"import": "./build/esm/prod/index.js",
28+
"require": "./build/cjs/prod/index.js"
29+
},
30+
"default": {
31+
"import": "./build/esm/prod/index.js",
32+
"require": "./build/cjs/prod/index.js"
2833
}
2934
},
3035
"./request": {
31-
"import": {
32-
"types": "./build/types/request.d.ts",
33-
"default": "./build/esm/request.js"
34-
},
35-
"require": {
36-
"types": "./build/types/request.d.ts",
37-
"default": "./build/cjs/request.js"
38-
}
36+
"types": "./build/types/request.d.ts",
37+
"import": "./build/esm/prod/request.js",
38+
"require": "./build/cjs/prod/request.js"
3939
},
4040
"./nodejs_compat": {
41-
"import": {
42-
"types": "./build/types/nodejs_compat/index.d.ts",
43-
"default": "./build/esm/nodejs_compat/index.js"
44-
},
45-
"require": {
46-
"types": "./build/types/nodejs_compat/index.d.ts",
47-
"default": "./build/cjs/nodejs_compat/index.js"
48-
}
41+
"types": "./build/types/nodejs_compat/index.d.ts",
42+
"import": "./build/esm/prod/nodejs_compat/index.js",
43+
"require": "./build/cjs/prod/nodejs_compat/index.js"
4944
},
5045
"./vite": {
51-
"import": {
52-
"types": "./build/types/vite/index.d.ts",
53-
"default": "./build/esm/vite/index.js"
54-
},
55-
"require": {
56-
"types": "./build/types/vite/index.d.ts",
57-
"default": "./build/cjs/vite/index.js"
58-
}
46+
"types": "./build/types/vite/index.d.ts",
47+
"import": "./build/esm/prod/vite/index.js",
48+
"require": "./build/cjs/prod/vite/index.js"
5949
}
6050
},
6151
"publishConfig": {
@@ -98,7 +88,7 @@
9888
"clean": "rimraf build coverage sentry-cloudflare-*.tgz",
9989
"lint:fix": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint . --fix --type-aware",
10090
"lint": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint . --type-aware",
101-
"lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module",
91+
"lint:es-compatibility": "es-check es2022 ./build/cjs/prod/*.js && es-check es2022 ./build/esm/prod/*.js --module",
10292
"test": "yarn test:unit",
10393
"test:unit": "vitest run",
10494
"test:watch": "vitest --watch",

packages/cloudflare/rollup.npm.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export default makeNPMConfigVariants(
44
makeBaseNPMConfig({
55
entrypoints: ['src/index.ts', 'src/nodejs_compat/index.ts', 'src/vite/index.ts'],
66
}),
7+
{ splitDevProd: true },
78
);

packages/cloudflare/src/options.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ export function getFinalOptions(userOptions: CloudflareOptions = {}, env: unknow
5858
// - false or explicit string from options: use as-is
5959
// - true: enable, but prefer a custom URL from the env var if set
6060
// - undefined: defer entirely to the env var (bool or URL)
61+
/*! rollup-include-development-only */
6162
const spotlight = getSpotlightFromEnv(userOptions.spotlight, getEnvVar(env, 'SENTRY_SPOTLIGHT'));
63+
/*! rollup-include-development-only-end */
6264

6365
return {
6466
release,
@@ -68,7 +70,9 @@ export function getFinalOptions(userOptions: CloudflareOptions = {}, env: unknow
6870
tracesSampleRate: isFinite(tracesSampleRate) ? tracesSampleRate : undefined,
6971
debug: userOptions.debug ?? envToBool(getEnvVar(env, 'SENTRY_DEBUG')),
7072
tunnel: userOptions.tunnel ?? getEnvVar(env, 'SENTRY_TUNNEL'),
73+
/*! rollup-include-development-only */
7174
spotlight,
75+
/*! rollup-include-development-only-end */
7276
};
7377
}
7478

packages/cloudflare/src/sdk.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ export function init(options: CloudflareOptions): CloudflareClient | undefined {
8989
flushLock,
9090
};
9191

92+
/*! rollup-include-development-only */
9293
if (options.spotlight && !clientOptions.integrations.some(({ name }) => name === SPOTLIGHT_INTEGRATION_NAME)) {
9394
clientOptions.integrations.push(
9495
spotlightIntegration({
9596
sidecarUrl: typeof options.spotlight === 'string' ? options.spotlight : undefined,
9697
}),
9798
);
9899
}
100+
/*! rollup-include-development-only-end */
99101

100102
/**
101103
* The Cloudflare SDK is not OpenTelemetry native, however, we set up some OpenTelemetry compatibility

0 commit comments

Comments
 (0)