From ef28761aca019bae931eabc0b3ba24ba7f2afe75 Mon Sep 17 00:00:00 2001 From: Justin Halsall Date: Wed, 1 Apr 2026 12:00:00 +0800 Subject: [PATCH] add root scripts and update contribution guide (#750) --- README.md | 12 ++++++++---- package.json | 4 ++++ packages/rrweb-snapshot/package.json | 2 ++ packages/rrweb/package.json | 1 + 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 392993c1..60f05284 100644 --- a/README.md +++ b/README.md @@ -59,10 +59,14 @@ Since we want the record and replay sides to share a strongly typed data structu [Typescript handbook](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html) -1. Fork the rrweb component repository you want to patch. -2. Run `yarn install` to install required dependencies. -3. Patch the code and pass all the tests. -4. Push the code and create a pull request. +1. Fork this repository. +2. Run `yarn install` in the root to install required dependencies for all sub-packages (note: `npm install` is _not_ recommended). +3. Run `yarn dev` in the root to get auto-building for all the sub-packages whenever you modify anything. +4. Navigate to one of the sub-packages (in the `packages` folder) where you'd like to make a change. +5. Patch the code and run `yarn test` to run the tests, make sure they pass before you commit anything. +6. Push the code and create a pull request. + +Protip: You can run `yarn test` in the root folder to run all the tests. In addition to adding integration tests and unit tests, rrweb also provides a REPL testing tool. diff --git a/package.json b/package.json index a9bb70e9..16d69e77 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,10 @@ }, "scripts": { "lerna": "lerna", + "build:all": "yarn lerna run prepublish", + "test": "yarn lerna run test", + "test:watch": "yarn lerna run test:watch --parallel", + "dev": "yarn lerna run dev --parallel", "repl": "cd packages/rrweb && npm run repl" } } diff --git a/packages/rrweb-snapshot/package.json b/packages/rrweb-snapshot/package.json index 0231d576..bc90502a 100644 --- a/packages/rrweb-snapshot/package.json +++ b/packages/rrweb-snapshot/package.json @@ -6,8 +6,10 @@ "prepare": "npm run prepack", "prepack": "npm run bundle && npm run typings", "test": "jest", + "test:watch": "jest --watch", "bundle": "rollup --config", "bundle:es-only": "cross-env ES_ONLY=true rollup --config", + "dev": "yarn bundle:es-only --watch", "typings": "tsc -d --declarationDir typings", "prepublish": "npm run typings && npm run bundle" }, diff --git a/packages/rrweb/package.json b/packages/rrweb/package.json index 01b04ba8..deb06da8 100644 --- a/packages/rrweb/package.json +++ b/packages/rrweb/package.json @@ -9,6 +9,7 @@ "test:headless": "npm run bundle:browser && PUPPETEER_HEADLESS=true jest", "test:watch": "PUPPETEER_HEADLESS=true npm run test -- --watch", "repl": "npm run bundle:browser && node scripts/repl.js", + "dev": "yarn bundle:browser --watch", "bundle:browser": "cross-env BROWSER_ONLY=true rollup --config", "bundle": "rollup --config", "typings": "tsc -d --declarationDir typings",