Skip to content

Commit

Permalink
build: automatically build types in prepack (#2258)
Browse files Browse the repository at this point in the history
refs: #1488 

## Description

Simplify build by using NPM lifecycle hooks. Adds a CI test for the
package graph sensitivity that the extant method was checking.

Part of making it work was adding "typescript" to `devDependencies` of
packages that need it. The root `build:types` was running with the root
`tsc` but when building in each package separately they wouldn't get the
root's typescript version and fall back to the global one, which didn't
know the `@import` syntax.


### Security Considerations

None

### Scaling Considerations

None

### Documentation Considerations

Less to document 

### Testing Considerations

I tried the "publish" commands in CONTRIBUTING.md. 

integration PR in agoric-sdk:
Agoric/agoric-sdk#9385

### Compatibility Considerations

Removes a necessary accommodation on agoric-sdk

### Upgrade Considerations

None
  • Loading branch information
turadg committed May 21, 2024
2 parents 2f3b66b + b5dffa4 commit 0a91fbe
Show file tree
Hide file tree
Showing 36 changed files with 106 additions and 111 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,14 @@ jobs:
- name: build
run: yarn run build

- name: build:types
run: yarn lerna run build:types

- name: pack
# Cannot use yarn lerna run pack
run: yarn lerna exec yarn pack

- name: clean:types
run: yarn lerna run clean:types
# Prepack (without cleanup per package) to ensure that type resolution in
# dependent packages continues to work when the typedefs are generated by
# their upstream packages. This helps avoid a situation in which the types
# only resolve because of the state of the local filesystem, and fails
# when imported in an NPM node_modules tree.
- name: Prepack packages
run: yarn lerna run --reject-cycles --concurrency 1 prepack
29 changes: 0 additions & 29 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,6 @@ https://github.com/endojs/endo/labels/next-release
yarn build
```

* Generate types.

```sh
yarn lerna run build:types
```

We generate types from the bottom up before publishing because this allows
each package to rely on the generated types of its dependencies in the
workspace.

* Commit the generated types.

```sh
git add .
git commit -m 'chore: Add generated types'
```

* Recreate the changelogs with the current date *and* generate tags for the new
versions. This is the effect of removing the `--no-git-tag-version` flag.

Expand Down Expand Up @@ -161,18 +144,6 @@ https://github.com/endojs/endo/labels/next-release
npm view ses
```

* Revert the change that added generated types.

```sh
git revert HEAD^
```

This command should then efect no changes.

```sh
yarn lerna run clean:types
```

* Force push these changes back to the pull request branch.

```sh
Expand Down
4 changes: 2 additions & 2 deletions packages/base64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"cover": "c8 ava",
"lint": "yarn lint:types && yarn lint:eslint",
"lint-fix": "eslint --fix .",
Expand Down
7 changes: 4 additions & 3 deletions packages/bundle-source/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"test": "ava",
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0",
Expand All @@ -40,7 +40,8 @@
"@endo/lockdown": "^1.0.7",
"@endo/ses-ava": "^1.2.2",
"ava": "^6.1.2",
"c8": "^7.14.0"
"c8": "^7.14.0",
"typescript": "5.5.0-beta"
},
"keywords": [],
"files": [
Expand Down
7 changes: 4 additions & 3 deletions packages/captp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"test": "ava",
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0",
Expand All @@ -50,7 +50,8 @@
"@endo/init": "^1.1.2",
"@endo/ses-ava": "^1.2.2",
"ava": "^6.1.2",
"c8": "^7.14.0"
"c8": "^7.14.0",
"typescript": "5.5.0-beta"
},
"dependencies": {
"@endo/errors": "^1.2.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/check-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"lint": "yarn lint:types && yarn lint:eslint",
"lint-fix": "eslint --fix .",
"lint:eslint": "eslint .",
Expand Down
4 changes: 2 additions & 2 deletions packages/cjs-module-analyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"cover": "c8 ava",
"lint": "yarn lint:types && yarn lint:eslint",
"lint-fix": "eslint --fix .",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"exports": {},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"lint": "yarn lint:types && yarn lint:eslint",
"lint-fix": "eslint --fix .",
"lint:eslint": "eslint .",
Expand Down
7 changes: 4 additions & 3 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"lint": "yarn lint:types && yarn lint:eslint",
"lint-check": "yarn lint",
"lint-fix": "yarn lint:eslint --fix && yarn lint:types",
Expand All @@ -50,7 +50,8 @@
"@endo/ses-ava": "^1.2.2",
"ava": "^6.1.2",
"c8": "^7.14.0",
"tsd": "^0.30.7"
"tsd": "^0.30.7",
"typescript": "5.5.0-beta"
},
"files": [
"*.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/compartment-mapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"cover": "c8 ava",
"lint": "yarn lint:types && yarn lint:eslint",
"lint-fix": "eslint --fix .",
Expand Down
4 changes: 2 additions & 2 deletions packages/daemon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"cover": "c8 ava",
"lint": "yarn lint:types && yarn lint:eslint",
"lint-fix": "eslint --fix .",
Expand Down
4 changes: 2 additions & 2 deletions packages/env-options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"lint-fix": "eslint --fix .",
"lint:eslint": "eslint .",
"lint:types": "tsc",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"test": "exit 0"
},
"devDependencies": {
Expand Down
7 changes: 4 additions & 3 deletions packages/errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"lint-fix": "yarn lint:eslint --fix && yarn lint:types",
"lint:eslint": "eslint '**/*.js'",
"lint:types": "tsc",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"test": "ava",
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0"
Expand All @@ -44,7 +44,8 @@
"ava": "^6.1.2",
"c8": "^7.14.0",
"ses0_18_3": "npm:ses@0.18.3",
"tsd": "^0.30.7"
"tsd": "^0.30.7",
"typescript": "5.5.0-beta"
},
"files": [
"*.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/evasive-transform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0",
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"lint-fix": "yarn lint:eslint --fix && yarn lint:types",
"lint-check": "yarn lint",
"lint": "yarn lint:types && yarn lint:eslint",
Expand Down
7 changes: 4 additions & 3 deletions packages/eventual-send/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"test:xs": "exit 0",
"build": "exit 0",
"clean": "git clean -f '*.d.ts*'",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"lint-fix": "yarn lint:eslint --fix && yarn lint:types",
"lint-check": "yarn lint",
"lint": "yarn lint:types && yarn lint:eslint",
Expand Down Expand Up @@ -42,7 +42,8 @@
"@endo/lockdown": "^1.0.7",
"ava": "^6.1.2",
"c8": "^7.14.0",
"tsd": "^0.30.7"
"tsd": "^0.30.7",
"typescript": "5.5.0-beta"
},
"keywords": [
"eventual send",
Expand Down
4 changes: 2 additions & 2 deletions packages/exo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"lint": "yarn lint:types && yarn lint:eslint",
"lint-fix": "eslint --fix .",
"lint:eslint": "eslint .",
Expand Down
7 changes: 4 additions & 3 deletions packages/far/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0",
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"lint-fix": "yarn lint:eslint --fix && yarn lint:types",
"lint-check": "yarn lint",
"lint": "yarn lint:types && yarn lint:eslint",
Expand All @@ -41,7 +41,8 @@
"@endo/init": "^1.1.2",
"@endo/ses-ava": "^1.2.2",
"ava": "^6.1.2",
"c8": "^7.14.0"
"c8": "^7.14.0",
"typescript": "5.5.0-beta"
},
"keywords": [
"eventual send",
Expand Down
7 changes: 4 additions & 3 deletions packages/import-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0",
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"lint-fix": "eslint --fix '**/*.js'",
"lint": "yarn lint:types && yarn lint:eslint",
"lint:eslint": "eslint .",
Expand All @@ -50,7 +50,8 @@
"@endo/init": "^1.1.2",
"@endo/ses-ava": "^1.2.2",
"ava": "^6.1.2",
"c8": "^7.14.0"
"c8": "^7.14.0",
"typescript": "5.5.0-beta"
},
"files": [
"LICENSE*",
Expand Down
7 changes: 4 additions & 3 deletions packages/init/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"test": "ava",
"test:xs": "exit 0",
"lint-check": "yarn lint",
Expand All @@ -30,7 +30,8 @@
},
"devDependencies": {
"@endo/compartment-mapper": "^1.1.5",
"ava": "^6.1.2"
"ava": "^6.1.2",
"typescript": "5.5.0-beta"
},
"dependencies": {
"@endo/base64": "^1.0.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/lp32/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"cover": "c8 ava",
"lint": "yarn lint:types && yarn lint:eslint",
"lint-fix": "eslint --fix .",
Expand Down
7 changes: 4 additions & 3 deletions packages/marshal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"test": "ava",
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0",
Expand Down Expand Up @@ -54,7 +54,8 @@
"@endo/ses-ava": "^1.2.2",
"@fast-check/ava": "^1.1.5",
"ava": "^6.1.2",
"c8": "^7.14.0"
"c8": "^7.14.0",
"typescript": "5.5.0-beta"
},
"files": [
"LICENSE*",
Expand Down
4 changes: 2 additions & 2 deletions packages/memoize/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"lint-fix": "eslint --fix .",
"lint:eslint": "eslint .",
"lint:types": "tsc",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"test": "ava"
},
"dependencies": {
Expand Down
7 changes: 4 additions & 3 deletions packages/nat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"scripts": {
"build": "exit 0",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"lint": "yarn lint:types && yarn lint:eslint",
"lint-fix": "eslint --fix .",
"lint:eslint": "eslint .",
Expand All @@ -37,7 +37,8 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.2.5",
"ses": "^1.5.0"
"ses": "^1.5.0",
"typescript": "5.5.0-beta"
},
"directories": {
"test": "test"
Expand Down

0 comments on commit 0a91fbe

Please sign in to comment.