Skip to content

Commit

Permalink
[development] Add turborepo convenience npm script using dot (#927)
Browse files Browse the repository at this point in the history
  • Loading branch information
silesky authored Aug 15, 2023
1 parent 4da8339 commit 9ba0dc6
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ steps:
- echo "--- Install dependencies"
- PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 HUSKY=0 yarn install --immutable
- echo "--- Build bundles"
- yarn run -T core+deps build
- yarn run -T core . build
- echo "+++ Run tests"
- yarn run -T core lint
- yarn run -T core test
Expand Down
24 changes: 23 additions & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
## Development
# Development

This project uses [Turborepo](https://turbo.build/repo/docs), for dependency-aware builds and linting. Please read up!

### Setup
```sh
git clone git@github.com:segmentio/analytics-next.git && cd analytics-next
nvm use # install version of node defined in .nvmrc.
yarn && yarn build
yarn lint && yarn test
```

###

### Build a specific package and all dependencies
You have a couple options:
1. you can _cd_ into a single package and run `yarn . build` build a package and all its dependencies (most convenient!).

2. You can use turborepo directly to build a package and all dependencies. See: Turborepo https://turbo.build/repo/docs/core-concepts/monorepos/filtering#filter-syntax.

For example:
```
yarn run -T turbo run build --filter=@segment/analytics-next
```
or
```
yarn run -T turbo run build --filter='./packages/node*'
```

^ Note, the following applies to not only `build`, but other tasks such as `test`, `lint`, etc.
1 change: 1 addition & 0 deletions examples/standalone-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"hoistingLimits": "workspaces"
},
"scripts": {
".": "yarn run -T turbo run --filter=@example/standalone-playground",
"dev": "yarn concurrently 'yarn run -T watch --filter=standalone-playground' 'sleep 10 && yarn http-server .'",
"concurrently": "yarn run -T concurrently"
},
Expand Down
1 change: 1 addition & 0 deletions examples/with-next-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
".": "yarn run -T turbo run --filter=@example/with-next-js",
"concurrently": "yarn run -T concurrently",
"dev": "yarn partytown && yarn concurrently 'yarn run -T watch --filter=with-next-js' 'sleep 10 && next dev'",
"build": "yarn partytown && next build",
Expand Down
1 change: 1 addition & 0 deletions examples/with-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@example/with-vite",
"private": true,
"scripts": {
".": "yarn run -T turbo run --filter=@example/with-vite",
"concurrently": "yarn run -T concurrently",
"dev": "yarn concurrently 'yarn run -T watch --filter=with-vite' 'sleep 10 && vite'",
"build": "tsc && vite build",
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
"release": "yarn clean && yarn build --force && changeset publish && git push origin HEAD:master --follow-tags --no-verify",
"version-run-all": "yarn workspaces foreach -vpt --no-private run version",
"core": "yarn workspace @segment/analytics-core",
"core+deps": "turbo run --filter=@segment/analytics-core",
"browser": "yarn workspace @segment/analytics-next",
"browser+deps": "turbo run --filter=@segment/analytics-next",
"node": "yarn workspace @segment/analytics-node",
"node+deps": "turbo run --filter=@segment/analytics-node",
"clean": "bash scripts/clean.sh",
"turbo": "turbo"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ build-browser: build # build dependencies
.PHONY: build-browser

build: ## Builds libraries in prod mode, and all dependencies
yarn run -T browser+deps build
yarn run -T browser . build
.PHONY: build

clean: ## Clean the build directory
Expand Down
3 changes: 2 additions & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
],
"sideEffects": false,
"scripts": {
".": "yarn run -T turbo run --filter=@segment/analytics-next",
"build-prep": "sh scripts/build-prep.sh",
"version": "yarn run build-prep && git add src/generated/version.ts",
"umd": "webpack",
Expand All @@ -33,7 +34,7 @@
"concurrently": "yarn run -T concurrently",
"watch": "yarn concurrently 'NODE_ENV=production WATCH=true yarn umd --watch' 'yarn pkg --watch'",
"build": "yarn clean && yarn build-prep && yarn concurrently 'NODE_ENV=production yarn umd' 'yarn pkg' 'yarn cjs'",
"release:cdn": "yarn run -T browser+deps build && NODE_ENV=production bash scripts/release.sh && NODE_ENV=stage bash scripts/release.sh",
"release:cdn": "yarn . build && NODE_ENV=production bash scripts/release.sh && NODE_ENV=stage bash scripts/release.sh",
"pkg": "yarn tsc -p tsconfig.build.json",
"cjs": "yarn tsc -p tsconfig.build.json --outDir ./dist/cjs --module commonjs",
"clean": "rm -rf dist",
Expand Down
3 changes: 1 addition & 2 deletions packages/consent/consent-tools-integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ Why is this using wd.io instead of playwright?
## Development
### 1. Build this package + deps
```sh
# include the "..."
yarn build...
yarn . build
```
### 2. Start server + run tests (and exit gracefully)
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "@internal/consent-tools-integration-tests",
"private": true,
"scripts": {
".": "yarn -T turbo run --filter=@internal/consent-tools-integration-tests",
"dev": "yarn concurrently 'yarn watch' 'yarn build serve --open'",
"build": "webpack",
"watch": "yarn build --watch",
"build...": "yarn run -T turbo run build --filter=@internal/consent-tools-integration-tests",
"test:local": "wdio wdio.conf.local.ts",
"start-server-and-test": "yarn concurrently -k 'yarn build serve' 'sleep 5 && yarn test:local'",
"lint": "yarn concurrently 'yarn:eslint .' 'yarn:tsc --noEmit'",
Expand Down
3 changes: 1 addition & 2 deletions packages/consent/consent-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ See the complete list of settings in the **[Settings interface](src/types/settin
## Development
1. Build this package + all dependencies
```sh
# include the "..."
yarn build...
yarn . build
```

2. Run tests
Expand Down
2 changes: 1 addition & 1 deletion packages/consent/consent-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"!*.tsbuildinfo"
],
"scripts": {
".": "yarn run -T turbo run --filter=@segment/analytics-consent-tools",
"test": "yarn jest",
"lint": "yarn concurrently 'yarn:eslint .' 'yarn:tsc --noEmit'",
"build": "rm -rf dist && yarn concurrently 'yarn:build:*'",
"build...": "yarn run -T turbo run build --filter=@segment/analytics-consent-wrapper-onetrust",
"build:esm": "yarn tsc -p tsconfig.build.json",
"build:cjs": "yarn tsc -p tsconfig.build.json --outDir ./dist/cjs --module commonjs",
"watch": "yarn build:esm --watch",
Expand Down
2 changes: 1 addition & 1 deletion packages/consent/consent-wrapper-onetrust/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"!*.tsbuildinfo"
],
"scripts": {
".": "yarn run -T turbo run --filter=@segment/analytics-consent-wrapper-onetrust",
"test": "yarn jest",
"lint": "yarn concurrently 'yarn:eslint .' 'yarn:tsc --noEmit'",
"build": "rm -rf dist && yarn concurrently 'yarn:build:*'",
"build...": "yarn run -T turbo run build --filter=@segment/analytics-consent-wrapper-onetrust",
"build:esm": "yarn tsc -p tsconfig.build.json",
"build:cjs": "yarn tsc -p tsconfig.build.json --outDir ./dist/cjs --module commonjs",
"watch": "yarn build:esm --watch",
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"sideEffects": false,
"scripts": {
".": "yarn run -T turbo run --filter=@segment/analytics-core",
"test": "yarn jest",
"lint": "yarn concurrently 'yarn:eslint .' 'yarn:tsc --noEmit'",
"build": "yarn concurrently 'yarn:build:*'",
Expand Down
1 change: 1 addition & 0 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"node": ">=14"
},
"scripts": {
".": "yarn run -T turbo run --filter=@segment/analytics-node",
"test": "yarn jest",
"lint": "yarn concurrently 'yarn:eslint .' 'yarn:tsc --noEmit'",
"build": "rm -rf dist && yarn concurrently 'yarn:build:*'",
Expand Down
1 change: 1 addition & 0 deletions packages/test-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"scripts": {
".": "yarn run -T turbo run --filter=@internal/test-helpers",
"lint": "yarn concurrently 'yarn:eslint .' 'yarn:tsc --noEmit'",
"build": "yarn concurrently 'yarn:build:*'",
"build:cjs": "yarn tsc -p tsconfig.build.json --outDir ./dist/cjs --module commonjs",
Expand Down

0 comments on commit 9ba0dc6

Please sign in to comment.