Skip to content

Commit 9b427b0

Browse files
authored
ref(build): Align package.json build scripts with JS SDK scripts (getsentry/sentry-replay#320)
Align the scripts in `package.json` with the scripts we use in the JS SDK repo. Doing this now doesn't hurt us and it's one less thing to worry about when migrating. Admittedly, the `build:*` scripts look a little scary now but this is just because I wanted to preserve the separate build scripts for worker and core. Therefore, we'll end up with a few more scripts than we have in most other SDKs (s.g. [Svelte](https://github.com/getsentry/sentry-javascript/blob/d22380097b70bc503613cebbf2b914175174221c/packages/svelte/package.jsongetsentry/sentry-replay#L34-L42)). In the monorepo, we don't set env variables for prod vs. dev builds. I still need to think about what we're going to do about them but we can make these changes iteratively. Here's a quick overview of the most important changes. All these scripts are used in the monorepo, not just by us but also by CI, so we need to align them: * `build` now serves as a "default" build command. I renamed what used to be the `build` script to `build:rollup` (which is also consistent with the monorepo). I left `build:prod` from devEx reasons for now but we can remove it after migrating. * `build:dev` basically remains unchanged as it's already mostly consistent with the monorepo * Added `build:watch` and `build:dev:watch` to re-build on file changes. I think previously, the `--watch` param was only applied to `build-core` but I figured we could also watch for worker changes. Which is why I added the `build:all:watch` sub-script to do this. I left the `dev` script for now to not disturb devEx but after migrating we can remove it, as it isn't used in the monorepo at all. * Added `build:npm` script to pack a tarball when publishing. In the monorepo, we use a script that makes some changes to `package.json` before packing. We'll need to add this here as well but not now, as it requires more changes. Also, I changed the "Build" GH workflow to use this command instead of `npm pack`. * Added `lint` and `fix` scripts that use eslint and prettier. I left the original commands eslint untouched, just changed the script names around it (and added the prettier stuff) I added the `npm-run-all` dev dependency for the time being, to get the `run-p/s` commands we use in the monorepo. After migrating, we can remove the dependency again from this package because it's registered as a top-level dependency in the monorepo.
1 parent c54fd24 commit 9b427b0

File tree

3 files changed

+491
-15
lines changed

3 files changed

+491
-15
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
yarn test
2424
2525
- run: |
26-
yarn pack
26+
yarn build:npm
2727
2828
- uses: actions/[email protected]
2929
with:

package.json

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,31 @@
77
"types": "dist/types/src/index.d.ts",
88
"sideEffects": false,
99
"scripts": {
10-
"bootstrap": "yarn && cd demo && yarn",
11-
"build": "yarn rollup --configPlugin @rollup/plugin-typescript",
12-
"build:all": "yarn clean && yarn build:worker && yarn build:core",
10+
"bootstrap": "yarn && cd demo && yarn #TODO: change after migration",
11+
"build": "NODE_ENV=production yarn build:all",
1312
"build:dev": "NODE_ENV=development yarn build:all",
14-
"build:prod": "NODE_ENV=production yarn build:all",
15-
"build:core": "yarn build --config config/rollup.config.core.ts",
16-
"build:worker": "yarn build --config config/rollup.config.worker.ts",
17-
"clean": "yarn rimraf dist",
18-
"dev": "yarn build:dev --watch",
19-
"lint": "yarn eslint . --ext .js,.jsx,.ts,.tsx",
20-
"prepack": "yarn build:prod",
13+
"build:all": "run-s clean build:worker build:core",
14+
"build:core": "yarn build:rollup --config config/rollup.config.core.ts",
15+
"build:worker": "yarn build:rollup --config config/rollup.config.worker.ts",
16+
"build:rollup": "rollup --configPlugin @rollup/plugin-typescript",
17+
"build:watch": "NODE_ENV=production yarn build:all:watch",
18+
"build:dev:watch": "NODE_ENV=development yarn build:all:watch",
19+
"build:all:watch": "yarn clean && run-p \"build:worker --watch\" \"build:core --watch\"",
20+
"build:npm": "yarn pack #TODO: use JS sdk prepack script after migration",
21+
"circularDepCheck": "#TODO comment in after migration: madge --circular src/index.ts",
22+
"clean": "rimraf dist sentry-replay-*.tgz",
23+
"fix": "run-s fix:eslint fix:prettier",
24+
"fix:eslint": "eslint . --format stylish --fix",
25+
"fix:prettier": "prettier --write \"{src,test,scripts,worker}/**/*.ts\"",
26+
"lint": "run-s lint:prettier lint:eslint",
27+
"lint:eslint": "eslint . --ext .js,.jsx,.ts,.tsx #TODO: we might want to use eslintcache after migration",
28+
"lint:prettier": "prettier --check \"{src,test,scripts,worker}/**/*.ts\"",
29+
"test": "jest",
30+
"test:watch": "jest --watch",
2131
"start:demo": "yarn build:dev && cd demo && yarn start",
22-
"test": "yarn jest"
32+
"prepack": "yarn build #TODO: remove after migration",
33+
"build:prod": "yarn build #TODO remove, we don't need this anymore after migration",
34+
"dev": "yarn build:dev:watch #TODO remove, we don't need this anymore after migration"
2335
},
2436
"files": [
2537
"dist"
@@ -56,6 +68,7 @@
5668
"jest": "27.5.1",
5769
"jest-environment-jsdom": "27.5.1",
5870
"jsdom-worker": "^0.2.1",
71+
"npm-run-all": "^4.1.5",
5972
"pako": "^2.0.4",
6073
"prettier": "^2.5.1",
6174
"rimraf": "^3.0.2",

0 commit comments

Comments
 (0)