-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(deno): Build Sentry dependencies for tests (#9312)
Co-authored-by: Luca Forstner <luca.forstner@sentry.io>
- Loading branch information
Showing
10 changed files
with
100 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1 +1,3 @@ | ||
build-types | ||
build-test | ||
lib.deno.d.ts |
This file contains 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 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,42 @@ | ||
// @ts-check | ||
import dts from 'rollup-plugin-dts'; | ||
import nodeResolve from '@rollup/plugin-node-resolve'; | ||
import sucrase from '@rollup/plugin-sucrase'; | ||
import { defineConfig } from 'rollup'; | ||
|
||
export default [ | ||
defineConfig({ | ||
input: ['test/build.ts'], | ||
output: { | ||
file: 'build-test/index.js', | ||
sourcemap: true, | ||
preserveModules: false, | ||
strict: false, | ||
freeze: false, | ||
interop: 'auto', | ||
format: 'esm', | ||
banner: '/// <reference types="./index.d.ts" />', | ||
}, | ||
plugins: [ | ||
nodeResolve({ | ||
extensions: ['.mjs', '.js', '.json', '.node', '.ts', '.tsx'], | ||
}), | ||
sucrase({ transforms: ['typescript'] }), | ||
], | ||
}), | ||
defineConfig({ | ||
input: './build-test/build.d.ts', | ||
output: [{ file: 'build-test/index.d.ts', format: 'es' }], | ||
plugins: [ | ||
dts({ respectExternal: true }), | ||
// The bundled types contain a declaration for the __DEBUG_BUILD__ global | ||
// This can result in errors about duplicate global declarations so we strip it out! | ||
{ | ||
name: 'strip-global', | ||
renderChunk(code) { | ||
return { code: code.replace(/declare global \{\s*const __DEBUG_BUILD__: boolean;\s*\}/g, '') }; | ||
}, | ||
}, | ||
], | ||
}), | ||
]; |
This file contains 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 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,4 @@ | ||
// We use this as the entry point to bundle Sentry dependencies that are used by the tests. | ||
export * as sentryTypes from '@sentry/types'; | ||
export * as sentryUtils from '@sentry/utils'; | ||
export * as sentryCore from '@sentry/core'; |
This file contains 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 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 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 |
---|---|---|
@@ -1,30 +1,25 @@ | ||
import { createTransport } from 'npm:@sentry/core'; | ||
import type { | ||
BaseTransportOptions, | ||
Envelope, | ||
Transport, | ||
TransportMakeRequestResponse, | ||
TransportRequest, | ||
} from 'npm:@sentry/types'; | ||
import { parseEnvelope } from 'npm:@sentry/utils'; | ||
import type { sentryTypes } from '../build-test/index.js'; | ||
import { sentryCore, sentryUtils } from '../build-test/index.js'; | ||
|
||
export interface TestTransportOptions extends BaseTransportOptions { | ||
callback: (envelope: Envelope) => void; | ||
export interface TestTransportOptions extends sentryTypes.BaseTransportOptions { | ||
callback: (envelope: sentryTypes.Envelope) => void; | ||
} | ||
|
||
/** | ||
* Creates a Transport that uses the Fetch API to send events to Sentry. | ||
*/ | ||
export function makeTestTransport(callback: (envelope: Envelope) => void) { | ||
return (options: BaseTransportOptions): Transport => { | ||
async function doCallback(request: TransportRequest): Promise<TransportMakeRequestResponse> { | ||
await callback(parseEnvelope(request.body, new TextEncoder(), new TextDecoder())); | ||
export function makeTestTransport(callback: (envelope: sentryTypes.Envelope) => void) { | ||
return (options: sentryTypes.BaseTransportOptions): sentryTypes.Transport => { | ||
async function doCallback( | ||
request: sentryTypes.TransportRequest, | ||
): Promise<sentryTypes.TransportMakeRequestResponse> { | ||
await callback(sentryUtils.parseEnvelope(request.body, new TextEncoder(), new TextDecoder())); | ||
|
||
return Promise.resolve({ | ||
statusCode: 200, | ||
}); | ||
} | ||
|
||
return createTransport(options, doCallback); | ||
return sentryCore.createTransport(options, doCallback); | ||
}; | ||
} |
This file contains 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,10 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["./lib.deno.d.ts", "test/build.ts"], | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationMap": false, | ||
"emitDeclarationOnly": true, | ||
"outDir": "build-test" | ||
} | ||
} |