Repository navigation
fix(astro): defer to @sentry/cloudflare/vite on Cloudflare Workers
#25347
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { defineCloudflareOptions } from '@sentry/cloudflare'; | ||
|
|
||
| export default defineCloudflareOptions(env => ({ | ||
| dsn: env.E2E_TEST_DSN, | ||
| environment: 'qa', | ||
| tracesSampleRate: 1.0, | ||
| tunnel: 'http://localhost:3031/', // proxy server | ||
| debug: true, | ||
| })); |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { sentryCloudflareVitePlugin } from '../../src/integration/cloudflare'; | ||
|
|
||
| function transform(code: string, id: string) { | ||
| const plugin = sentryCloudflareVitePlugin() as { transform: (code: string, id: string) => unknown }; | ||
| return plugin.transform(code, id); | ||
| } | ||
|
|
||
| describe('sentryCloudflareVitePlugin', () => { | ||
| it('wraps the default export of the @astrojs/cloudflare v12 virtual entry', () => { | ||
| const code = ['const _exports = createExports(manifest);', 'export default _exports.default;'].join('\n'); | ||
|
|
||
| expect(transform(code, '\0@astrojs-ssr-virtual-entry')).toEqual({ | ||
| code: [ | ||
| "import { withSentry } from '@sentry/cloudflare';", | ||
| 'const _exports = createExports(manifest);', | ||
| 'export default withSentry(() => undefined, _exports.default);', | ||
| ].join('\n'), | ||
| map: null, | ||
| }); | ||
| }); | ||
|
|
||
| it('wraps the default export of the @cloudflare/vite-plugin worker entry', () => { | ||
| const code = [ | ||
| 'import { getExportTypes } from "virtual:cloudflare/export-types";', | ||
| 'import * as mod from "virtual:cloudflare/user-entry";', | ||
| 'export * from "virtual:cloudflare/user-entry";', | ||
| 'export default mod.default ?? {};', | ||
| 'if (import.meta.hot) { import.meta.hot.accept(); }', | ||
| ].join('\n'); | ||
|
|
||
| expect(transform(code, '\0virtual:cloudflare/worker-entry')).toEqual({ | ||
| code: [ | ||
| "import { withSentry } from '@sentry/cloudflare';", | ||
| 'import { getExportTypes } from "virtual:cloudflare/export-types";', | ||
| 'import * as mod from "virtual:cloudflare/user-entry";', | ||
| 'export * from "virtual:cloudflare/user-entry";', | ||
| 'export default withSentry(() => undefined, mod.default ?? {});', | ||
| 'if (import.meta.hot) { import.meta.hot.accept(); }', | ||
| ].join('\n'), | ||
| map: null, | ||
| }); | ||
| }); | ||
|
|
||
| it('leaves other modules alone', () => { | ||
| expect(transform('export default handler;', '/src/pages/index.astro')).toBeUndefined(); | ||
| }); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.