diff --git a/.changeset/thirty-shirts-grow.md b/.changeset/thirty-shirts-grow.md
new file mode 100644
index 0000000000..9281088ee4
--- /dev/null
+++ b/.changeset/thirty-shirts-grow.md
@@ -0,0 +1,16 @@
+---
+"all": patch
+"packer": patch
+"plugins": patch
+"record": patch
+"replay": patch
+"rrdom": patch
+"rrdom-nodejs": patch
+"rrweb": patch
+"rrweb-player": patch
+"rrweb-snapshot": patch
+"types": patch
+"utils": patch
+---
+
+Provide a /umd/ output folder alongside the /dist/ one so that we can serve UMD (Universal Module Definition) files with a .js extension, without upsetting expectations set by package.json that all .js files in /dist/ are modules
diff --git a/guide.md b/guide.md
index 764e359fb4..8ab8c17a7a 100644
--- a/guide.md
+++ b/guide.md
@@ -15,13 +15,13 @@ You are recommended to install rrweb via jsdelivr's CDN service:
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/rrweb@latest/dist/style.css"
/>
-
+
```
Also, you can link to a specific version number that you can update manually:
```html
-
+
```
#### Only include the recorder code
@@ -30,7 +30,7 @@ rrweb's code includes both the record and the replay parts. Most of the time you
This also can be done by using the `@rrweb/record` package and the CDN service:
```html
-
+
```
#### Other packages
diff --git a/guide.zh_CN.md b/guide.zh_CN.md
index 4078cb2b6a..2bbeb4c9a5 100644
--- a/guide.zh_CN.md
+++ b/guide.zh_CN.md
@@ -13,13 +13,13 @@
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/rrweb@latest/dist/style.css"
/>
-
+
```
也可以在 URL 中指定具体的版本号,例如:
```html
-
+
```
#### 仅引入录制部分
@@ -27,7 +27,7 @@
rrweb 代码分为录制和回放两部分,大多数时候用户在被录制的应用中只需要引入录制部分代码。同样可以通过使用 @rrweb/record 包和 CDN 服务来实现:
```html
-
+
```
#### 其他包
diff --git a/packages/rrweb-player/README.md b/packages/rrweb-player/README.md
index 866adc7c67..855b559763 100644
--- a/packages/rrweb-player/README.md
+++ b/packages/rrweb-player/README.md
@@ -19,7 +19,7 @@ rrweb-player can also be included with `
+
```
Or installed by using NPM:
diff --git a/packages/rrweb/src/record/index.ts b/packages/rrweb/src/record/index.ts
index 1308c378a6..e4f0f8a777 100644
--- a/packages/rrweb/src/record/index.ts
+++ b/packages/rrweb/src/record/index.ts
@@ -209,7 +209,16 @@ function record(
e.type !== EventType.FullSnapshot &&
!(
e.type === EventType.IncrementalSnapshot &&
- e.data.source === IncrementalSource.Mutation
+ [
+ IncrementalSource.Mutation,
+ IncrementalSource.MediaInteraction, // often automatic e.g. background video loop
+ IncrementalSource.StyleSheetRule,
+ IncrementalSource.CanvasMutation,
+ IncrementalSource.Font,
+ IncrementalSource.Log,
+ IncrementalSource.StyleDeclaration,
+ IncrementalSource.AdoptedStyleSheet,
+ ].includes(e.data.source)
)
) {
// we've got a user initiated event so first we need to apply
diff --git a/vite.config.default.ts b/vite.config.default.ts
index 46af9327a6..b6a4867d9d 100644
--- a/vite.config.default.ts
+++ b/vite.config.default.ts
@@ -1,9 +1,9 @@
///
import dts from 'vite-plugin-dts';
-import { copyFileSync } from 'node:fs';
+import { copyFileSync, mkdirSync, existsSync } from 'node:fs';
import { defineConfig, LibraryOptions, LibraryFormats, Plugin } from 'vite';
import { build, Format } from 'esbuild';
-import { resolve } from 'path';
+import { resolve, dirname } from 'path';
import { umdWrapper } from 'esbuild-plugin-umd-wrapper';
import * as fs from 'node:fs';
import { visualizer } from 'rollup-plugin-visualizer';
@@ -51,22 +51,36 @@ function minifyAndUMDPlugin({
outDir,
});
} else {
+ const umdDir = dirname(outputFilePath).replace('/dist', '/umd');
+ if (!existsSync(umdDir)) {
+ mkdirSync(umdDir);
+ }
+ const outUmd = `${outputFilePath}.umd.cjs`;
await buildFile({
name,
input: inputFilePath,
- output: `${outputFilePath}.umd.cjs`,
+ output: outUmd,
minify: false,
isCss: false,
outDir,
});
+ copyFileSync(
+ outUmd,
+ `${outputFilePath.replace('/dist/', '/umd/')}.js`,
+ );
+ const outUmdMin = `${outputFilePath}.umd.min.cjs`;
await buildFile({
name,
input: inputFilePath,
- output: `${outputFilePath}.umd.min.cjs`,
+ output: outUmdMin,
minify: true,
isCss: false,
outDir,
});
+ copyFileSync(
+ outUmdMin,
+ `${outputFilePath.replace('/dist/', '/umd/')}.min.js`,
+ );
}
}
}