-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
frontend/Dockerfile
Outdated
@@ -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/ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. 🤷
There was a problem hiding this comment.
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
3764b42
to
8b05893
Compare
8b05893
to
8f4da2c
Compare
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/ |
There was a problem hiding this comment.
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.
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.