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 pnpm catalog feature for shared dependencies #1072

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

myieye
Copy link
Contributor

@myieye myieye commented Sep 25, 2024

I took the opportunity to peruse pnpm's changelog and found this handy new feature to prevent modules in a monorepo from using different versions of dependencies. For lots of dependencies it doesn't matter that much, but for some it does (e.g. vite and svelte) and consistency is nice.

In an intro video it was suggested to put everything in a catalog by default. But, the current caveat of catalogs is that they're not currently supported by pnpm update. Personally, I think we can live with that for the time being.

pnpm outdated works, which is something.

Copy link

github-actions bot commented Sep 25, 2024

UI unit Tests

12 tests  ±0   12 ✅ ±0   0s ⏱️ ±0s
 4 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 8f4da2c. ± Comparison against base commit 23ab4d5.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

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

the catalog is cool nice work.

@@ -2,6 +2,7 @@
# TODO: can't use vanilla alpine version since python is needed for gql-codegen stuff.
FROM node:20 AS builder-base
WORKDIR /app
COPY . /app/
Copy link
Collaborator

Choose a reason for hiding this comment

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

what was the purpose of this change? this means none of the layers below will be cached and so even if a ts file changes then the pnpm install will rerun

Copy link
Contributor Author

@myieye myieye Sep 26, 2024

Choose a reason for hiding this comment

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

Ah. There's my weak docker understanding blazing forth 😭
The viewer needs a couple files from app, because we're using workspaces.
But, I should just copy the ones it needs - just pnpm-lock.yaml and pnpm-workspace.yaml I think.

Our pnpm-lock.yaml situation is still a bit imperfect, but ultimately there should only be one of them and the viewer should need/use the one in the workspace root. So, this is one step in the right direction. I'm not entirely sure how the viewer has been behaving in this Docker image without the lock file. Perhaps it didn't care, because it didn't see the workspace file, so it didn't think it was in a workspace. 🤷

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the viewer was working by building without knowing it was part of a workspace

@myieye myieye marked this pull request as ready for review September 26, 2024 14:34
@myieye myieye marked this pull request as draft September 26, 2024 14:45
RUN --mount=type=cache,target=/root/.local/share/pnpm/store pnpm install

COPY ./viewer /app/viewer
RUN --mount=type=cache,target=/root/.local/share/pnpm/store pnpm run build

FROM builder-base AS builder

COPY package.json pnpm-lock.yaml /app/
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml /app/
COPY viewer/package.json /app/viewer/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that the frontend knows it's part of a workspace, pnpm more strictly enforces its workspace dependencies to be present.

@myieye myieye marked this pull request as ready for review September 27, 2024 11:51
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