Skip to content

Commit ed42b68

Browse files
authored
chore: remove rollup web worker processing (#60)
since we're using vite's built in
1 parent 7c372ca commit ed42b68

File tree

7 files changed

+31
-43
lines changed

7 files changed

+31
-43
lines changed

CHANGELOG.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
## 0.0.12 - 2025-03-17
22

3-
4-
53
## 0.0.11 - 2025-03-14
64

75
## 0.0.10 - 2025-02-28

packages/rrweb-snapshot/test/integration.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ describe('integration tests', function (this: ISuite) {
112112
});
113113

114114
afterAll(async () => {
115-
await browser.close();
116-
await server.close();
115+
await browser?.close();
116+
await server?.close();
117117
});
118118

119119
for (const html of htmls) {

packages/rrweb/package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@
4444
}
4545
},
4646
"./dist/rrweb.css": "./dist/rrweb.css",
47-
"./dist/style.css": "./dist/style.css",
48-
"./dist/assets/*": "./dist/assets/*"
47+
"./dist/style.css": "./dist/style.css"
4948
},
5049
"files": [
5150
"dist",
52-
"dist/assets",
5351
"package.json"
5452
],
5553
"sideEffects": false,
@@ -89,4 +87,4 @@
8987
"@posthog/rrdom": "*",
9088
"@posthog/rrweb-snapshot": "*"
9189
}
92-
}
90+
}

packages/rrweb/rollup.config.js

-14
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import esbuild from 'rollup-plugin-esbuild';
33
import resolve from '@rollup/plugin-node-resolve';
44
import postcss from 'rollup-plugin-postcss';
55
import renameNodeModules from 'rollup-plugin-rename-node-modules';
6-
import webWorkerLoader from 'rollup-plugin-web-worker-loader';
76
import pkg from './package.json';
87

98
function toRecordPath(path) {
@@ -122,12 +121,6 @@ function getPlugins(options = {}) {
122121
const { minify = false, sourceMap = false } = options;
123122
return [
124123
resolve({ browser: true }),
125-
webWorkerLoader({
126-
targetPlatform: 'browser',
127-
inline: true,
128-
preserveSource: true,
129-
sourceMap,
130-
}),
131124
esbuild({
132125
minify,
133126
}),
@@ -144,13 +137,6 @@ for (const c of baseConfigs) {
144137
const basePlugins = [
145138
resolve({ browser: true }),
146139

147-
// supports bundling `web-worker:..filename`
148-
webWorkerLoader({
149-
targetPlatform: 'browser',
150-
inline: true,
151-
preserveSource: true,
152-
}),
153-
154140
typescript(),
155141
];
156142
const plugins = basePlugins.concat(

packages/rrweb/test/integration.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ describe('record integration tests', function (this: ISuite) {
5555
});
5656

5757
afterAll(async () => {
58-
await browser.close();
59-
server.close();
58+
await browser?.close();
59+
server?.close();
6060
});
6161

6262
it('can record clicks', async () => {

packages/rrweb/vite.config.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
import config from '../../vite.config.default';
2+
import { defineConfig } from 'vite';
3+
import { mergeConfig } from 'vite';
24

35
// export default config('src/index.ts', 'rrweb', { outputDir: 'dist/main' });
4-
export default config('src/index.ts', 'rrweb');
6+
const baseConfig = config('src/index.ts', 'rrweb');
7+
8+
export default defineConfig((configEnv) =>
9+
mergeConfig(
10+
baseConfig(configEnv),
11+
{
12+
plugins: [{
13+
name: 'move-worker-sourcemap',
14+
generateBundle(options, bundle) {
15+
Object.entries(bundle).forEach(([fileName, output]) => {
16+
if (fileName.includes('worker') && fileName.endsWith('.map')) {
17+
console.log('Moving worker sourcemap:', fileName);
18+
const newFileName = fileName.replace('assets/', '');
19+
bundle[newFileName] = output;
20+
output.fileName = newFileName; // Update the fileName property
21+
delete bundle[fileName];
22+
}
23+
});
24+
}
25+
}]
26+
}
27+
)
28+
);

vite.config.default.ts

-18
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ import { visualizer } from 'rollup-plugin-visualizer';
1010

1111
// don't empty out dir if --watch flag is passed
1212
const emptyOutDir = !process.argv.includes('--watch');
13-
/**
14-
* Chrome web store does not allow base64 inline workers.
15-
* For chrome extension, we need to disable worker inlining to pass the review.
16-
*/
17-
const disableWorkerInlining = process.env.DISABLE_WORKER_INLINING === 'true';
1813

1914
function minifyAndUMDPlugin({
2015
name,
@@ -162,19 +157,6 @@ export default function (
162157
filename: resolve(__dirname, name + '-bundle-analysis.html'), // Path for the HTML report
163158
open: false, // don't Automatically open the report in the browser
164159
}),
165-
{
166-
name: 'remove-worker-inline',
167-
enforce: 'pre',
168-
transform(code, id) {
169-
if (!disableWorkerInlining) return;
170-
if (/\.(js|ts|jsx|tsx)$/.test(id)) {
171-
return {
172-
code: code.replace(/\?worker&inline/g, '?worker'),
173-
map: null,
174-
};
175-
}
176-
},
177-
},
178160
...plugins,
179161
],
180162
}));

0 commit comments

Comments
 (0)