Skip to content

Commit 0431c2b

Browse files
committed
ref: Extract getWorkerURL into worker package
1 parent 4919b06 commit 0431c2b

File tree

8 files changed

+13
-6
lines changed

8 files changed

+13
-6
lines changed

packages/replay-worker/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor

packages/replay-worker/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ node_modules
22
/*.tgz
33
.eslintcache
44
build
5-
!types/*.d.ts
5+
!vendor/*.d.ts

packages/replay-worker/rollup.worker.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { terser } from 'rollup-plugin-terser';
77
import copy from 'rollup-plugin-copy';
88

99
const config = defineConfig({
10-
input: ['./src/index.ts'],
10+
input: ['./src/worker.ts'],
1111
output: {
1212
dir: './build/',
1313
format: 'esm',
@@ -27,7 +27,7 @@ const config = defineConfig({
2727
},
2828
},
2929
copy({
30-
targets: [{ src: 'types/*', dest: 'build' }],
30+
targets: [{ src: 'vendor/*', dest: 'build' }],
3131
}),
3232
],
3333
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export function getWorkerURL(): string;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import workerString from './worker';
2+
3+
export function getWorkerURL() {
4+
const workerBlob = new Blob([workerString]);
5+
return URL.createObjectURL(workerBlob);
6+
}

packages/replay/src/eventBuffer/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import workerString from '@sentry-internal/replay-worker';
1+
import { getWorkerURL } from '@sentry-internal/replay-worker';
22
import { logger } from '@sentry/utils';
33

44
import type { EventBuffer } from '../types';
@@ -16,8 +16,7 @@ export function createEventBuffer({ useCompression }: CreateEventBufferParams):
1616
// eslint-disable-next-line no-restricted-globals
1717
if (useCompression && window.Worker) {
1818
try {
19-
const workerBlob = new Blob([workerString]);
20-
const workerUrl = URL.createObjectURL(workerBlob);
19+
const workerUrl = getWorkerURL();
2120

2221
__DEBUG_BUILD__ && logger.log('[Replay] Using compression worker');
2322
const worker = new Worker(workerUrl);

0 commit comments

Comments
 (0)