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

build: automatically build types in prepack #2258

Merged
merged 3 commits into from
May 21, 2024
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
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
Comment on lines +330 to +331
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what the purpose is to generate types after the build is created?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each package is built with access to the entire monorepo source and without other typedefs. When packages are imported, they'll have only the package dependencies and those will have typedefs instead of original src. I've seen errors in resolving at that point.

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*'",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a reason to believe that cleaning up types in postpack will work now when it did not before? #1864

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many things have changed since then. Named exports and imports for one.

To be sure, can you describe how I could reproduce the problem described in that PR intro? I'd like to try making a regression test, something that failed right before 1864 and passed right after.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integration with Agoric SDK satisfies me. Hopefully it works this time because this is by far the better state.

"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
Loading
Loading