Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/rrdom-nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"rollup": "^2.56.3",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.31.2",
"rollup-plugin-web-worker-loader": "^1.6.1",
"ts-jest": "^27.1.3"
},
"dependencies": {
Expand Down
5 changes: 0 additions & 5 deletions packages/rrdom-nodejs/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
import webWorkerLoader from 'rollup-plugin-web-worker-loader';
import pkg from './package.json';

function toMinPath(path) {
Expand All @@ -12,10 +11,6 @@ function toMinPath(path) {
const basePlugins = [
resolve({ browser: true }),
commonjs(),

// supports bundling `web-worker:..filename` from rrweb
webWorkerLoader(),

typescript({
tsconfigOverride: { compilerOptions: { module: 'ESNext' } },
}),
Expand Down
1 change: 0 additions & 1 deletion packages/rrdom-nodejs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"include": [
"src",
"test.d.ts",
"../rrweb/src/record/workers/workers.d.ts",
"../rrweb/src/record/constructable-stylesheets.d.ts"
],
"references": [
Expand Down
1 change: 0 additions & 1 deletion packages/rrdom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"rollup": "^2.56.3",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.31.2",
"rollup-plugin-web-worker-loader": "^1.6.1",
"ts-jest": "^27.1.3"
},
"dependencies": {
Expand Down
5 changes: 0 additions & 5 deletions packages/rrdom/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
import webWorkerLoader from 'rollup-plugin-web-worker-loader';
import pkg from './package.json';

function toMinPath(path) {
Expand All @@ -12,10 +11,6 @@ function toMinPath(path) {
const basePlugins = [
resolve({ browser: true }),
commonjs(),

// supports bundling `web-worker:..filename` from rrweb
webWorkerLoader(),

typescript({
tsconfigOverride: { compilerOptions: { module: 'ESNext' } },
}),
Expand Down
1 change: 0 additions & 1 deletion packages/rrdom/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
],
"include": [
"src",
"../rrweb/src/record/workers/workers.d.ts",
"../rrweb/src/record/constructable-stylesheets.d.ts"
]
}
1 change: 0 additions & 1 deletion packages/rrweb-player/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"rollup-plugin-svelte": "^7.1.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.31.2",
"rollup-plugin-web-worker-loader": "^1.6.1",
"sirv-cli": "^0.4.4",
"svelte": "^3.59.2",
"svelte-check": "^3.0.1",
Expand Down
4 changes: 0 additions & 4 deletions packages/rrweb-player/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import commonjs from '@rollup/plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import sveltePreprocess from 'svelte-preprocess';
import webWorkerLoader from 'rollup-plugin-web-worker-loader';
import typescript from 'rollup-plugin-typescript2';
import pkg from './package.json';
import css from 'rollup-plugin-css-only';
Expand Down Expand Up @@ -69,9 +68,6 @@ export default entries.map((output) => ({

commonjs(),

// supports bundling `web-worker:..filename` from rrweb
webWorkerLoader(),

typescript(),

css({
Expand Down
1 change: 0 additions & 1 deletion packages/rrweb-player/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"node_modules/*",
"__sapper__/*",
"public/*",
"../rrweb/src/record/workers/workers.d.ts"
],
"compilerOptions": {
"composite": true
Expand Down
7 changes: 7 additions & 0 deletions packages/rrweb-worker/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": ["../../.eslintrc.js"],
"rules": {
"prefer-template": "off",
"@typescript-eslint/restrict-plus-operands": "off"
}
}
18 changes: 18 additions & 0 deletions packages/rrweb-worker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.vscode
.idea
node_modules
package-lock.json
# yarn.lock
*.tsbuildinfo
build
dist
es
lib
typings

temp

*.log

.env
__diff_output__
35 changes: 35 additions & 0 deletions packages/rrweb-worker/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@sentry-internal/rrweb-worker",
"version": "2.6.0",
"description": "Worker for rrweb",
"main": "lib/rrweb-worker/index.cjs",
"module": "es/rrweb-worker/index.js",
"types": "typings/index.d.ts",
"sideEffects": false,
"private": true,
"scripts": {
"dev": "yarn bundle --watch",
"build:tarball": "npm pack",
"bundle": "rollup --config",
"typings": "tsc -p tsconfig.types.json",
"prepare": "npm run typings && npm run bundle",
"check-types": "tsc -noEmit",
"lint": "yarn eslint src"
},
"repository": {
"type": "git",
"url": "git+https://github.com/getsentry/rrweb.git"
},
"author": "Sentry",
"license": "MIT",
"bugs": {
"url": "https://github.com/getsentry/rrweb/issues"
},
"dependencies": {
"@sentry-internal/rrweb-snapshot": "2.6.0",
"@sentry-internal/rrweb-types": "2.6.0"
},
"engines": {
"node": ">=12"
}
}
83 changes: 83 additions & 0 deletions packages/rrweb-worker/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import { defineConfig } from 'rollup';
import { terser } from 'rollup-plugin-terser';

const workerStrBaseConfig = {
input: ['./src/_image-bitmap-data-url-worker.ts'],
treeshake: 'smallest',
plugins: [
commonjs(),
typescript({
tsconfig: './tsconfig.json',
inlineSourceMap: false,
sourceMap: false,
inlineSources: false,
}),
resolve(),
terser({
mangle: {
module: true,
},
}),
{
name: 'worker-to-string',
renderChunk(code) {
return `export default \`${code}\`;`;
},
},
],
};

const indexBaseConfig = {
input: ['./src/index.ts'],
treeshake: 'smallest',
external: ['./image-bitmap-data-url-worker'],
plugins: [
typescript({
tsconfig: './tsconfig.json',
inlineSourceMap: false,
sourceMap: false,
inlineSources: false,
}),
terser({
mangle: {
module: true,
},
}),
],
};

const config = defineConfig([
{
...workerStrBaseConfig,
output: {
file: './es/rrweb-worker/image-bitmap-data-url-worker.js',
format: 'esm',
},
},
{
...workerStrBaseConfig,
output: {
file: './lib/rrweb-worker/image-bitmap-data-url-worker.cjs',
format: 'cjs',
},
},
{
...indexBaseConfig,
output: {
file: './es/rrweb-worker/index.js',
format: 'esm',
},
},
{
...indexBaseConfig,
output: {
file: './lib/rrweb-worker/index.cjs',
format: 'cjs',
},
},
]);

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function getTransparentBlobFor(
height: number,
dataURLOptions: DataURLOptions,
): Promise<string> {
const id = `${width}-${height}`;
const id = width + '-' + height;
if ('OffscreenCanvas' in globalThis) {
if (transparentBlobMap.has(id)) return transparentBlobMap.get(id)!;
const offscreen = new OffscreenCanvas(width, height);
Expand Down
3 changes: 3 additions & 0 deletions packages/rrweb-worker/src/image-bitmap-data-url-worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This is replaced at build-time with the content from _image-bitmap-data-url-worker.ts, wrapped as a string.
// This is just a placeholder so that types etc. are correct.
export default '' as string;
9 changes: 9 additions & 0 deletions packages/rrweb-worker/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import workerString from './image-bitmap-data-url-worker';

/**
* Get the URL for a web worker.
*/
export function getImageBitmapDataUrlWorkerURL(): string {
const workerBlob = new Blob([workerString]);
return URL.createObjectURL(workerBlob);
Comment on lines +7 to +8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we'll have potential CSP errors now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already had before! Previously this was just being rewritten to a string-based worker by rollup under the hood 😬

}
33 changes: 33 additions & 0 deletions packages/rrweb-worker/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Node",
"target": "ES2020",
"noImplicitAny": true,
"strictNullChecks": true,
"removeComments": true,
"preserveConstEnums": true,
"rootDir": "src",
"outDir": "build",
"lib": [
"webworker",
"scripthost"
],
"allowSyntheticDefaultImports": true,
"declarationMap": false,
"skipLibCheck": true,
"composite": true
},
"references": [
{
"path": "../rrweb-snapshot"
}
],
"exclude": [
"test",
"scripts"
],
"include": [
"src/**/*.ts"
]
}
9 changes: 9 additions & 0 deletions packages/rrweb-worker/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"include": ["src/*.ts"],
"compilerOptions": {
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "typings"
}
}
2 changes: 1 addition & 1 deletion packages/rrweb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@
"rollup-plugin-postcss": "^3.1.1",
"rollup-plugin-rename-node-modules": "^1.3.1",
"rollup-plugin-typescript2": "^0.31.2",
"rollup-plugin-web-worker-loader": "^1.6.1",
"simple-peer-light": "^9.10.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tslib": "^2.3.1"
},
"dependencies": {
"@sentry-internal/rrweb-worker": "2.6.0",
"@sentry-internal/rrdom": "2.6.0",
"@sentry-internal/rrweb-snapshot": "2.6.0",
"@sentry-internal/rrweb-types": "2.6.0",
Expand Down
9 changes: 0 additions & 9 deletions packages/rrweb/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import esbuild from 'rollup-plugin-esbuild';
import resolve from '@rollup/plugin-node-resolve';
import postcss from 'rollup-plugin-postcss';
import renameNodeModules from 'rollup-plugin-rename-node-modules';
import webWorkerLoader from 'rollup-plugin-web-worker-loader';
import pkg from './package.json';

function toRecordPath(path) {
Expand Down Expand Up @@ -122,11 +121,6 @@ function getPlugins(options = {}) {
const { minify = false, sourceMap = false } = options;
return [
resolve({ browser: true }),
webWorkerLoader({
targetPlatform: 'browser',
inline: true,
sourceMap,
}),
esbuild({
minify,
}),
Expand All @@ -143,9 +137,6 @@ for (const c of baseConfigs) {
const basePlugins = [
resolve({ browser: true }),

// supports bundling `web-worker:..filename`
webWorkerLoader({ targetPlatform: 'browser' }),

typescript(),
];
const plugins = basePlugins.concat(
Expand Down
Loading