Skip to content

Commit

Permalink
feat: improve monorepo build setup
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsDenBakker committed Aug 4, 2020
1 parent e872022 commit 1d975e3
Show file tree
Hide file tree
Showing 47 changed files with 768 additions and 290 deletions.
8 changes: 8 additions & 0 deletions .changeset/selfish-deers-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@web/test-runner': patch
'@web/test-runner-browser-lib': patch
'@web/test-runner-mocha': patch
'@web/test-runner-server': patch
---

improve repository build setup
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ jobs:
- name: Install Dependencies
run: yarn --frozen-lockfile
env:
ROLLUP_PRODUCTION_BUILD: 'true'

- name: Build for production
run: yarn build:production

- name: Create Release Pull Request or Publish to npm
id: changesets
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ jobs:
- name: Install dependencies
run: yarn --frozen-lockfile

# build for production in CI to make sure tests can run with production build
- name: Build for production
run: yarn build:production

- name: Lint
run: yarn lint

Expand Down
8 changes: 1 addition & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@ To see how your changes integrate with everything together you can use the `test

## Adding new packages

### JS

For JS projects, you can just create a new package in the `packages` directory. You can copy the `package.json` from another project to get started.

### TS

For TS projects the configuration files are auto generated. You need to add an entry to the [config generator script](scripts/update-package-tsconfig.ts) to let it generate a config for you. After adding an entry, run `yarn update:tsconfig`.
For all projects the tsconfig/jsconfig configuration files are auto generated. You need to add an entry to the [./workspace-packages.ts](./workspace-packages.ts) to let it generate a config for you. After adding an entry, run `yarn update-package-configs` to generate the files for you.

## Create a Changeset

Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"private": true,
"license": "MIT",
"scripts": {
"build": "concurrently \"yarn tsc\" \"yarn build:browser\"",
"build:browser": "rimraf packages/*/dist && concurrently \"yarn workspace @web/test-runner-browser-lib build\" \"yarn workspace @web/test-runner-mocha build\" \"yarn workspace @web/test-runner-helpers build\" -m 1",
"build": "rimraf packages/*/tsconfig.tsbuildinfo && tsc --build",
"build:production": "concurrently \"yarn workspace @web/test-runner-browser-lib build:production\" \"yarn workspace @web/test-runner-mocha build:production\" \"yarn workspace @web/test-runner-helpers build:production\" -m 1",
"build:watch": "rimraf packages/*/tsconfig.tsbuildinfo && tsc --build --watch",
"format": "npm run format:eslint && npm run format:prettier",
"format:eslint": "eslint --ext .ts,.js . --fix",
"format:prettier": "prettier \"**/*.{ts,js,md}\" \"**/package.json\" --write --ignore-path .eslintignore",
Expand All @@ -15,16 +16,15 @@
"reinstall-workspace": "rimraf demo/projects/*/node_modules && rimraf packages/*/node_modules && rimraf node_modules && yarn install && yarn build",
"release": "yarn format && changeset publish",
"test": "node scripts/workspaces-scripts.mjs test:ci",
"tsc": "rimraf packages/*/tsconfig.tsbuildinfo && tsc --build packages/tsconfig.project.json",
"tsc:watch": "yarn tsc --watch",
"update-dependency": "node scripts/update-dependency.js",
"update:tsconfig": "ts-node scripts/update-package-tsconfig.ts"
"update-package-configs": "ts-node scripts/update-package-configs.ts"
},
"devDependencies": {
"@changesets/cli": "^2.9.2",
"@rollup/plugin-node-resolve": "^8.4.0",
"@rollup/plugin-typescript": "^5.0.2",
"@types/chai": "^4.2.11",
"@types/mkdirp": "^1.0.1",
"@types/mocha": "^7.0.2",
"@types/sinon": "^9.0.4",
"@typescript-eslint/eslint-plugin": "^3.7.0",
Expand All @@ -35,6 +35,7 @@
"eslint-config-prettier": "^6.11.0",
"husky": "^1.0.0",
"lint-staged": "^8.0.0",
"mkdirp": "^1.0.4",
"mocha": "^7.2.0",
"prettier": "^2.0.5",
"prettier-plugin-package": "^1.0.0",
Expand Down
6 changes: 4 additions & 2 deletions packages/browser-logs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// GENERATED by update-package-tsconfig
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts

{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.node-base.json",
"compilerOptions": {
"outDir": "./dist",
"module": "commonjs",
Expand All @@ -12,6 +13,7 @@
"src"
],
"exclude": [
"src/browser",
"tests",
"dist"
]
Expand Down
6 changes: 4 additions & 2 deletions packages/dev-server-core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// GENERATED by update-package-tsconfig
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts

{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.node-base.json",
"compilerOptions": {
"outDir": "./dist",
"module": "commonjs",
Expand All @@ -12,6 +13,7 @@
"src"
],
"exclude": [
"src/browser",
"tests",
"dist"
]
Expand Down
6 changes: 4 additions & 2 deletions packages/dev-server-esbuild/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// GENERATED by update-package-tsconfig
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts

{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.node-base.json",
"compilerOptions": {
"outDir": "./dist",
"module": "commonjs",
Expand All @@ -16,6 +17,7 @@
"src"
],
"exclude": [
"src/browser",
"tests",
"dist"
]
Expand Down
6 changes: 4 additions & 2 deletions packages/dev-server-legacy/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// GENERATED by update-package-tsconfig
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts

{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.node-base.json",
"compilerOptions": {
"outDir": "./dist",
"module": "commonjs",
Expand All @@ -16,6 +17,7 @@
"src"
],
"exclude": [
"src/browser",
"tests",
"dist"
]
Expand Down
6 changes: 4 additions & 2 deletions packages/dev-server-rollup/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// GENERATED by update-package-tsconfig
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts

{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.node-base.json",
"compilerOptions": {
"outDir": "./dist",
"module": "commonjs",
Expand All @@ -16,6 +17,7 @@
"src"
],
"exclude": [
"src/browser",
"tests",
"dist"
]
Expand Down
8 changes: 5 additions & 3 deletions packages/test-runner-browser-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
"node": ">=10.0.0"
},
"scripts": {
"build": "rimraf dist && rollup -c rollup.config.js",
"build:watch": "rimraf dist && rollup -c rollup.config.js --watch"
"build": "tsc",
"build:production": "rimraf dist && rollup -c rollup.config.js"
},
"files": ["dist"],
"files": [
"dist"
],
"keywords": [
"web",
"test",
Expand Down
2 changes: 1 addition & 1 deletion packages/test-runner-browser-lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
BrowserTestSessionResult,
TestResult,
TestSuiteResult,
} from './types';
} from './types.js';

// mocking libraries might overwrite window.fetch, by grabbing a reference here
// we make sure we are using the original fetch instead of the mocked variant
Expand Down
10 changes: 7 additions & 3 deletions packages/test-runner-browser-lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
// GENERATED by update-package-tsconfig
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts

{
"extends": "../../tsconfig.browser.json",
"extends": "../../tsconfig.browser-base.json",
"compilerOptions": {
"outDir": "./dist",
"module": "ESNext",
"rootDir": "./src"
"rootDir": "./src",
"composite": true
},
"references": [],
"include": [
"src"
],
"exclude": [
"src/browser",
"tests",
"dist"
]
Expand Down
6 changes: 4 additions & 2 deletions packages/test-runner-browserstack/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// GENERATED by update-package-tsconfig
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts

{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.node-base.json",
"compilerOptions": {
"outDir": "./dist",
"module": "commonjs",
Expand All @@ -22,6 +23,7 @@
"src"
],
"exclude": [
"src/browser",
"tests",
"dist"
]
Expand Down
12 changes: 10 additions & 2 deletions packages/test-runner-chrome/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// GENERATED by update-package-tsconfig
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts

{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.node-base.json",
"compilerOptions": {
"outDir": "./dist",
"module": "commonjs",
Expand All @@ -11,6 +12,9 @@
{
"path": "../test-runner-core/tsconfig.json"
},
{
"path": "../test-runner-browser-lib/tsconfig.json"
},
{
"path": "../dev-server-core/tsconfig.json"
},
Expand All @@ -20,6 +24,9 @@
{
"path": "../test-runner-coverage-v8/tsconfig.json"
},
{
"path": "../test-runner-mocha/tsconfig.json"
},
{
"path": "../test-runner-server/tsconfig.json"
}
Expand All @@ -28,6 +35,7 @@
"src"
],
"exclude": [
"src/browser",
"tests",
"dist"
]
Expand Down
10 changes: 6 additions & 4 deletions packages/test-runner-cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// GENERATED by update-package-tsconfig
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts

{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.node-base.json",
"compilerOptions": {
"outDir": "./dist",
"module": "commonjs",
Expand All @@ -9,16 +10,17 @@
},
"references": [
{
"path": "../test-runner-core/tsconfig.json"
"path": "../browser-logs/tsconfig.json"
},
{
"path": "../browser-logs/tsconfig.json"
"path": "../test-runner-core/tsconfig.json"
}
],
"include": [
"src"
],
"exclude": [
"src/browser",
"tests",
"dist"
]
Expand Down
4 changes: 3 additions & 1 deletion packages/test-runner-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"test:ci": "yarn test",
"test:watch": "mocha test/**/*.test.ts --require ts-node/register --watch --watch-files src,test --reporter progress"
},
"files": ["dist"],
"files": [
"dist"
],
"keywords": [
"web",
"test",
Expand Down
6 changes: 4 additions & 2 deletions packages/test-runner-core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// GENERATED by update-package-tsconfig
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts

{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.node-base.json",
"compilerOptions": {
"outDir": "./dist",
"module": "commonjs",
Expand All @@ -12,6 +13,7 @@
"src"
],
"exclude": [
"src/browser",
"tests",
"dist"
]
Expand Down
6 changes: 4 additions & 2 deletions packages/test-runner-coverage-v8/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// GENERATED by update-package-tsconfig
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts

{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.node-base.json",
"compilerOptions": {
"outDir": "./dist",
"module": "commonjs",
Expand All @@ -16,6 +17,7 @@
"src"
],
"exclude": [
"src/browser",
"tests",
"dist"
]
Expand Down
4 changes: 2 additions & 2 deletions packages/test-runner-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"node": ">=10.0.0"
},
"scripts": {
"build": "rimraf dist && rollup -c rollup.config.js",
"build:watch": "rimraf dist && rollup -c rollup.config.js --watch"
"build": "tsc",
"build:production": "rimraf dist && rollup -c rollup.config.js"
},
"files": [
"dist"
Expand Down
10 changes: 7 additions & 3 deletions packages/test-runner-helpers/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
// GENERATED by update-package-tsconfig
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts

{
"extends": "../../tsconfig.browser.json",
"extends": "../../tsconfig.browser-base.json",
"compilerOptions": {
"outDir": "./dist",
"module": "ESNext",
"rootDir": "./src"
"rootDir": "./src",
"composite": true
},
"references": [],
"include": [
"src"
],
"exclude": [
"src/browser",
"tests",
"dist"
]
Expand Down
Loading

0 comments on commit 1d975e3

Please sign in to comment.