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: add dependencies for subpackages #87

Merged
merged 6 commits into from
Feb 29, 2024
Merged

Conversation

samsiegart
Copy link
Contributor

@samsiegart samsiegart commented Feb 27, 2024

The publish NPM workflow is failing https://github.com/Agoric/ui-kit/actions/runs/8053306725/job/21995398192

It seems like it's not building and linking the packages in the order according to

ui-kit/package.json

Lines 5 to 9 in 2ae3e21

"workspaces": [
"packages/ui-components",
"packages/rpc",
"packages/web-components",
"packages/react-components"
, so @agoric/react-components fails to build because @agoric/web-components isn't built yet. It seems like the way to fix this is to declare the dependencies on other sub-packages in their package.jsons, which seems to be what agoric-sdk does for its sub-packages, but we'll see what happens when the workflow runs.

I also replaced an any type with the proper ChainStorageWatcher type in @agoric/web-components, now that the dependency is included.

@samsiegart samsiegart marked this pull request as ready for review February 28, 2024 05:32
@samsiegart samsiegart requested a review from turadg February 28, 2024 05:32
Comment on lines 76 to 77
"@agoric/rpc": "^0.9.0",
"@agoric/web-components": "^0.15.0",
Copy link
Member

Choose a reason for hiding this comment

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

They're either dependencies or peerDependencies but not both.

peer has less burden on the consumer, so if that works go with it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think they should be dependencies because they're imported and used directly in this package: https://github.com/Agoric/ui-kit/blob/main/packages/react-components/src/lib/context/AgoricProviderLite.tsx#L10-L18

It's possible the consumer doesn't directly use the exposed chainStorageWatcher or walletConnection types from the context so I think it would be more burden to require them to add these as dependencies on their own.

However, if the client is using those types elsewhere, I figured it would make sense to put them in peerDependencies as well to avoid conflicts. Am I thinking about this wrong?

Copy link
Member

Choose a reason for hiding this comment

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

yeah then they're dependencies.

I see your motivation to constrain the peerDependencies as well, but I don't think it's warranted.

@@ -30,14 +30,15 @@
"lit": "2.0.2"
},
"devDependencies": {
"@agoric/rpc": "^0.9.0",
Copy link
Member

Choose a reason for hiding this comment

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

I see this is a new dependency as of this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea I figured it was a dependency at first but then realized it was just using any for the chainStorageWatcher type, but left this in since that should be fixed anyway.

@@ -52,6 +52,7 @@ describe('makeAgoricWalletConnection', () => {

// Don't bother faking keplr, just expect it to try to enable and fail.
await expect(() =>
// @ts-expect-error fake partial watcher implementation
Copy link
Member

Choose a reason for hiding this comment

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

you could cast the watcher so you don't have to ignore at each site. up to you

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Casting requires stubbing out more of the functions than the test uses, or else I'm getting type errors. Unless you mean casting to any, but I think the expect-error with explanation would be better.

Copy link
Member

Choose a reason for hiding this comment

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

I meant to put the one ts-expect-error at the cast site. then it will let you lie about what the type is.

i agree that any expect-error should have an explanation

@@ -21,7 +21,7 @@ jobs:
cache-dependency-path: yarn.lock

- run: yarn install --frozen-lockfile

- run: yarn workspaces run prepack
Copy link
Member

Choose a reason for hiding this comment

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

this shouldn't be necessary. lerna publish will pack along the way. I suppose you had it here for debugging? please either remove or add a comment explaining why this redundant command is included

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was to be safe because the lerna publish wasn't prepacking in the correct order and failing as seen in https://github.com/Agoric/ui-kit/actions/runs/8053306725/job/21995398192

I read that lerna would pack in the correct order if we explicitly added the dependencies in the package.jsons, but added this to be safe because I noticed MAINTAINERS.md includes an explicit prepack step as well. Just took this back out though so we can be sure if it's needed, but worst case we'll have to do another PR to add it back.

.github/workflows/ci.yml Show resolved Hide resolved
@samsiegart samsiegart requested a review from turadg February 28, 2024 18:47
Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

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

I leave the outstanding items to your judgement

Comment on lines 76 to 77
"@agoric/rpc": "^0.9.0",
"@agoric/web-components": "^0.15.0",
Copy link
Member

Choose a reason for hiding this comment

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

yeah then they're dependencies.

I see your motivation to constrain the peerDependencies as well, but I don't think it's warranted.

@@ -52,6 +52,7 @@ describe('makeAgoricWalletConnection', () => {

// Don't bother faking keplr, just expect it to try to enable and fail.
await expect(() =>
// @ts-expect-error fake partial watcher implementation
Copy link
Member

Choose a reason for hiding this comment

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

I meant to put the one ts-expect-error at the cast site. then it will let you lie about what the type is.

i agree that any expect-error should have an explanation

@@ -21,7 +21,6 @@ jobs:
cache-dependency-path: yarn.lock

- run: yarn install --frozen-lockfile

Copy link
Member

Choose a reason for hiding this comment

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

ignorable nit: removing this newline makes the comment a little harder to read

@samsiegart samsiegart merged commit b8fd8f1 into main Feb 29, 2024
1 check passed
@samsiegart samsiegart deleted the add-workspace-dependencies branch February 29, 2024 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants