Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TS references to link monorepo packages #1277

Merged
merged 6 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/tasty-masks-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@api3/airnode-abi': minor
'@api3/airnode-adapter': minor
'@api3/airnode-admin': minor
'@api3/airnode-deployer': minor
'@api3/airnode-examples': minor
'@api3/airnode-node': minor
'@api3/airnode-ois': minor
'@api3/airnode-operation': minor
'@api3/airnode-protocol': minor
'@api3/airnode-utilities': minor
'@api3/airnode-validator': minor
---

Link monorepo packages using project references
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ examples) will work out of the box.
We heavily recommend using UNIX based systems for development. If you are using Windows, consider
[WSL](https://docs.microsoft.com/en-us/windows/wsl/install).

We use [TS project references](https://www.typescriptlang.org/docs/handbook/project-references.html) to see
cross-package errors in real time. However, we use `ts-node` to run our development scripts and it
[does not support project references](https://github.com/TypeStrong/ts-node/issues/897) at the moment. This means that
some of the errors are only shown in the IDE or at build time, not when run using `ts-node`.

## Changelog

We use [changesets](https://github.com/atlassian/changesets) to manage the changelog for us. What that means for
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"docker:build:client": "docker build --tag api3/airnode-client:latest --file packages/airnode-node/docker/Dockerfile .",
"format:check": "yarn prettier:check && yarn terraform:fmt:check",
"format:write": "yarn prettier:write && yarn terraform:fmt:write",
"lint": "yarn run lint:eslint && yarn run lint:solhint && yarn format:check && yarn lint:deps-versions",
"lint": "yarn run lint:eslint && yarn run lint:solhint && yarn format:check && yarn lint:deps-versions && yarn ts-node scripts/validate-ts-references.ts",
"lint:deps-versions": "syncpack list-mismatches",
"lint:eslint": "eslint . --ext .js,.ts",
"lint:eslint:fix": "eslint . --ext .js,.ts --fix",
Expand Down Expand Up @@ -93,6 +93,7 @@
"@types/node": "^17.0.18",
"@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1",
"comment-json": "^4.2.2",
"eslint": "^8.17.0",
"eslint-plugin-functional": "^4.2.1",
"eslint-plugin-import": "^2.26.0",
Expand Down
1 change: 1 addition & 0 deletions packages/airnode-abi/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/node_modules
/dist
/build

# Test files
coverage/
2 changes: 1 addition & 1 deletion packages/airnode-abi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"scripts": {
"build": "yarn run clean && yarn run compile",
"clean": "rimraf -rf *.tsbuildinfo ./dist *.tgz",
"clean": "rimraf -rf *.tsbuildinfo ./dist ./build *.tgz",
"compile": "tsc --build tsconfig.json",
"pack": "yarn pack",
"test": "SILENCE_LOGGER=true jest --coverage",
Expand Down
1 change: 1 addition & 0 deletions packages/airnode-abi/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "../build/src-tsconfig.tsbuildinfo",

"rootDir": "./",
"outDir": "../dist"
Expand Down
4 changes: 3 additions & 1 deletion packages/airnode-abi/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "..",
"noEmit": true
// The output files of this TS config are for development only. See the referenced TS configs
// which build the sources into the "dist" folder in the root of the validator project.
"outDir": "../build"
},
"references": [{ "path": "../src" }],
"include": ["./**/*.ts", "../src/**/*.test.ts"]
Expand Down
1 change: 1 addition & 0 deletions packages/airnode-adapter/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/node_modules
/dist
/build
/.serverless
/.build

Expand Down
4 changes: 3 additions & 1 deletion packages/airnode-adapter/e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"compilerOptions": {
"types": ["@nomiclabs/hardhat-waffle", "@nomiclabs/hardhat-ethers", "chai", "mocha", "hardhat"],
"rootDir": "..",
"noEmit": true
// The output files of this TS config are for development only. See the referenced TS configs
// which build the sources into the "dist" folder in the root of the validator project.
"outDir": "../build"
},
"references": [{ "path": "../src" }],
// Mocha tests use only the ".ts" (not ".test.ts") extension not to conflict with Jest tests
Expand Down
2 changes: 1 addition & 1 deletion packages/airnode-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"scripts": {
"build": "yarn run clean && yarn run compile",
"clean": "rimraf -rf *.tsbuildinfo ./dist *.tgz",
"clean": "rimraf -rf *.tsbuildinfo ./dist ./build *.tgz",
"compile": "hardhat compile && tsc --build tsconfig.json",
"pack": "yarn pack",
"test": "yarn test:ts && yarn test:hardhat",
Expand Down
2 changes: 2 additions & 0 deletions packages/airnode-adapter/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "../build/src-tsconfig.tsbuildinfo",

"rootDir": "./",
"outDir": "../dist"
},
"references": [{ "path": "../../airnode-ois/src" }],
"include": ["./**/*.ts"],
"exclude": ["./**/*.test.ts"]
}
4 changes: 3 additions & 1 deletion packages/airnode-adapter/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "..",
"noEmit": true
// The output files of this TS config are for development only. See the referenced TS configs
// which build the sources into the "dist" folder in the root of the validator project.
"outDir": "../build"
},
"references": [{ "path": "../src" }],
"include": ["./**/*.ts", "../src/**/*.test.ts"]
Expand Down
1 change: 1 addition & 0 deletions packages/airnode-admin/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules
/dist
/build
2 changes: 1 addition & 1 deletion packages/airnode-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"scripts": {
"build": "yarn run clean && yarn run compile",
"clean": "rimraf -rf *.tsbuildinfo ./dist *.tgz",
"clean": "rimraf -rf *.tsbuildinfo ./dist ./build *.tgz",
"cli": "ts-node bin/admin.ts",
"compile": "tsc --build tsconfig.json",
"pack": "yarn pack",
Expand Down
7 changes: 7 additions & 0 deletions packages/airnode-admin/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "../build/src-tsconfig.tsbuildinfo",

"rootDir": "..",
"rootDirs": ["./src", "./bin"],
"outDir": "../dist"
},
"references": [
{ "path": "../../airnode-abi/src" },
{ "path": "../../airnode-protocol/src" },
{ "path": "../../airnode-utilities/src" },
{ "path": "../../airnode-validator/src" }
],
"include": ["./**/*.ts", "../bin/**/*.ts", "../package.json"],
"exclude": ["./**/*.test.ts"]
}
4 changes: 3 additions & 1 deletion packages/airnode-admin/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "..",
"noEmit": true
// The output files of this TS config are for development only. See the referenced TS configs
// which build the sources into the "dist" folder in the root of the validator project.
"outDir": "../build"
},
"references": [{ "path": "../src" }],
"include": ["./**/*.ts", "../src/**/*.test.ts"]
Expand Down
1 change: 1 addition & 0 deletions packages/airnode-deployer/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/node_modules
/dist
/build
/.serverless
/.build
/.webpack
Expand Down
2 changes: 1 addition & 1 deletion packages/airnode-deployer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"scripts": {
"build": "yarn clean && yarn compile && yarn webpack && yarn copy:webpack && yarn copy:terraform",
"clean": "rimraf -rf *.tsbuildinfo ./dist ./.webpack *.tgz",
"clean": "rimraf -rf *.tsbuildinfo ./dist ./.webpack ./build *.tgz",
"cli": "ts-node bin/deployer.ts",
"compile": "tsc --build tsconfig.json",
"copy:terraform": "copyfiles terraform/**/**/**/*.tf terraform/**/**/**/*.tpl dist/",
Expand Down
7 changes: 7 additions & 0 deletions packages/airnode-deployer/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "../build/src-tsconfig.tsbuildinfo",

"rootDir": "..",
"rootDirs": ["./src", "./bin"],
"outDir": "../dist"
},
"references": [
{ "path": "../../airnode-node/src" },
{ "path": "../../airnode-protocol/src" },
{ "path": "../../airnode-utilities/src" },
{ "path": "../../airnode-validator/src" }
],
"include": ["./**/*.ts", "../bin/**/*.ts", "../package.json"],
"exclude": ["./**/*.test.ts"]
}
4 changes: 3 additions & 1 deletion packages/airnode-deployer/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "..",
"noEmit": true
// The output files of this TS config are for development only. See the referenced TS configs
// which build the sources into the "dist" folder in the root of the validator project.
"outDir": "../build"
},
"references": [{ "path": "../src" }],
"include": ["./**/*.ts", "../src/**/*.test.ts"]
Expand Down
1 change: 1 addition & 0 deletions packages/airnode-examples/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
log.json
/dist
/build

# Hardhat files
/cache
Expand Down
4 changes: 3 additions & 1 deletion packages/airnode-examples/dev-scripts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"noEmit": true
// The output files of this TS config are for development only. See the referenced TS configs
// which build the sources into the "dist" folder in the root of the validator project.
"outDir": "../build"
},
"references": [{ "path": "../src" }],
"include": ["./**/*.ts"]
Expand Down
2 changes: 1 addition & 1 deletion packages/airnode-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"scripts": {
"build": "yarn run clean && yarn compile",
"clean": "rimraf -rf *.tsbuildinfo ./dist *.tgz",
"clean": "rimraf -rf *.tsbuildinfo ./dist ./build *.tgz",
"choose-integration": "ts-node src/scripts/choose-integration.ts",
"compile": "hardhat compile && tsc --build tsconfig.json",
"create-airnode-config": "ts-node src/scripts/create-airnode-config.ts",
Expand Down
8 changes: 8 additions & 0 deletions packages/airnode-examples/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
"rootDir": "./",
"outDir": "../dist"
},
"references": [
{ "path": "../../airnode-abi/src" },
{ "path": "../../airnode-admin/src" },
{ "path": "../../airnode-deployer/src" },
{ "path": "../../airnode-node/src" },
{ "path": "../../airnode-protocol/src" },
{ "path": "../../airnode-utilities/src" }
],
"include": ["./**/*.ts"],
"exclude": ["./**/*.test.ts"]
}
4 changes: 3 additions & 1 deletion packages/airnode-examples/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "..",
"noEmit": true
// The output files of this TS config are for development only. See the referenced TS configs
// which build the sources into the "dist" folder in the root of the validator project.
"outDir": "../build"
},
"references": [{ "path": "../src" }],
"include": ["./**/*.ts", "../src/**/*.test.ts"]
Expand Down
1 change: 1 addition & 0 deletions packages/airnode-node/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/node_modules
/dist
/build
/.serverless
/.build

Expand Down
2 changes: 1 addition & 1 deletion packages/airnode-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"scripts": {
"build": "yarn run clean && yarn run compile",
"clean": "rimraf -rf *.tsbuildinfo ./dist *.tgz",
"clean": "rimraf -rf *.tsbuildinfo ./dist ./build *.tgz",
"compile": "tsc --build tsconfig.json",
"dev:invoke": "ts-node src/cli/validate-config.ts && ts-node src/cli/invoke.ts",
"dev:testApi": "ts-node src/cli/test-api.ts",
Expand Down
10 changes: 10 additions & 0 deletions packages/airnode-node/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "../build/src-tsconfig.tsbuildinfo",

"rootDir": "..",
"outDir": "../dist"
},
"references": [
{ "path": "../../airnode-abi/src" },
{ "path": "../../airnode-adapter/src" },
{ "path": "../../airnode-ois/src" },
{ "path": "../../airnode-protocol/src" },
{ "path": "../../airnode-utilities/src" },
{ "path": "../../airnode-validator/src" },
{ "path": "../../airnode-operation/src" }
],
"include": ["./**/*.ts", "../package.json"],
"exclude": ["./**/*.test.ts"]
}
4 changes: 3 additions & 1 deletion packages/airnode-node/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "..",
"noEmit": true
// The output files of this TS config are for development only. See the referenced TS configs
// which build the sources into the "dist" folder in the root of the validator project.
"outDir": "../build"
},
"references": [{ "path": "../src" }],
"include": ["./**/*.ts", "../src/**/*.test.ts"]
Expand Down
1 change: 1 addition & 0 deletions packages/airnode-ois/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/node_modules
/dist
/build
/.serverless
/.build

Expand Down
2 changes: 1 addition & 1 deletion packages/airnode-ois/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"scripts": {
"build": "yarn run clean && yarn run compile",
"clean": "rimraf -rf *.tsbuildinfo ./dist *.tgz",
"clean": "rimraf -rf *.tsbuildinfo ./dist ./build *.tgz",
"compile": "tsc --build tsconfig.json",
"pack": "yarn pack"
},
Expand Down
1 change: 1 addition & 0 deletions packages/airnode-ois/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"rootDir": "./",
"outDir": "../dist"
},
"references": [{ "path": "../../airnode-validator/src" }],
"include": ["./**/*.ts"],
"exclude": ["./**/*.test.ts"]
}
4 changes: 3 additions & 1 deletion packages/airnode-ois/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "..",
"noEmit": true
// The output files of this TS config are for development only. See the referenced TS configs
// which build the sources into the "dist" folder in the root of the validator project.
"outDir": "../build"
},
"references": [{ "path": "../src" }],
"include": ["./**/*.ts", "../src/**/*.test.ts"]
Expand Down
1 change: 1 addition & 0 deletions packages/airnode-operation/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
/dist
/build

# Hardhat files
cache
Expand Down
2 changes: 1 addition & 1 deletion packages/airnode-operation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"scripts": {
"build": "yarn run clean && yarn run compile",
"clean": "rimraf -rf *.tsbuildinfo ./dist *.tgz",
"clean": "rimraf -rf *.tsbuildinfo ./dist ./build *.tgz",
"compile": "tsc --build tsconfig.json",
"compile:watch": "tsc --build tsconfig.json -w",
"dev:api": "ts-node src/server.ts",
Expand Down
6 changes: 6 additions & 0 deletions packages/airnode-operation/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "../build/src-tsconfig.tsbuildinfo",

"rootDir": "./",
"outDir": "../dist"
},
"references": [
{ "path": "../../airnode-abi/src" },
{ "path": "../../airnode-protocol/src" },
{ "path": "../../airnode-utilities/src" }
],
"include": ["./**/*.ts"],
"exclude": ["./**/*.test.ts"]
}
1 change: 1 addition & 0 deletions packages/airnode-protocol/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/node_modules
/dist
/build

/cache
/artifacts
Expand Down
Loading