Yarn 4 Migration (#32253)

Migrates the Overleaf monorepo package manager from npm (v11) to Yarn 4 (v4.9.1) using node-modules linker mode.

GitOrigin-RevId: 50d32ab01955c15e29679eff9e9e9cfb897fab2d
This commit is contained in:
Anna Claire Fields
2026-04-28 08:52:37 +00:00
committed by Copybot
parent ed0fb0110a
commit 0d64a88a46
137 changed files with 39227 additions and 538 deletions
+14 -9
View File
@@ -8,25 +8,30 @@ FROM $OVERLEAF_BASE_TAG
WORKDIR /overleaf
# Add required source files for npm install
# -----------------------------------------
COPY --parents libraries/*/package.json patches/ services/*/package.json tools/migrations/ package.json package-lock.json /overleaf/
# Add required source files for yarn install
# -------------------------------------------
COPY --parents libraries/*/package.json .yarn/patches/ services/*/package.json tools/migrations/ package.json yarn.lock .yarnrc.yml /overleaf/
COPY server-ce/genScript.js server-ce/services.js /overleaf/
# Install npm dependencies
# ------------------------
# Pre-install yarn via corepack so it is available at runtime for all users
# -------------------------------------------------------------------------
ENV COREPACK_HOME=/opt/corepack
RUN corepack install
# Install yarn dependencies
# -------------------------
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/.npm \
--mount=type=cache,target=/overleaf/services/web/node_modules/.cache,id=server-ce-webpack-cache \
--mount=type=cache,target=/root/.yarn/berry/cache,id=server-ce-yarn-cache \
--mount=type=tmpfs,target=/tmp node genScript install | bash
# Add the actual source files
# ---------------------------
COPY --parents libraries/ services/ tools/migrations/ /overleaf/
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/.npm \
--mount=type=cache,target=/root/.yarn/berry/cache,id=server-ce-yarn-cache \
--mount=type=cache,target=/overleaf/services/web/node_modules/.cache,id=server-ce-webpack-cache \
--mount=type=tmpfs,target=/tmp node genScript compile | bash
--mount=type=tmpfs,target=/tmp \
YARN_CACHE_FOLDER=/tmp/.yarn-cache node genScript compile | bash
# Copy runit service startup scripts to its location
# --------------------------------------------------
+1
View File
@@ -33,6 +33,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install -y nodejs \
&& corepack enable \
\
&& rm -rf \
# We are adding a custom nginx config in the main Dockerfile.
+5 -5
View File
@@ -5,7 +5,7 @@ console.log('set -ex')
switch (process.argv.pop()) {
case 'install':
console.log('npm install --omit=dev')
console.log('yarn workspaces focus --all --production')
break
case 'compile':
for (const service of services) {
@@ -13,18 +13,18 @@ switch (process.argv.pop()) {
switch (service.name) {
case 'web':
// precompile pug in background
console.log('npm run precompile-pug &')
console.log('yarn run precompile-pug &')
console.log('pug_precompile=$!')
// Avoid downloading of cypress
console.log('export CYPRESS_INSTALL_BINARY=0')
// install webpack and frontend dependencies
console.log('npm install --include=dev')
console.log('yarn install')
// run webpack
console.log('npm run webpack:production')
console.log('yarn run webpack:production')
// uninstall webpack and frontend dependencies
console.log('npm prune --omit=dev')
console.log('yarn workspaces focus --all --production')
// Wait for pug precompile to finish
console.log('wait "$pug_precompile"')
@@ -9,5 +9,5 @@ fi
echo "Running migrations for $environment"
cd /overleaf/tools/migrations
/sbin/setuser www-data npm run migrations -- migrate -t "$environment"
/sbin/setuser www-data yarn run migrations migrate -t "$environment"
echo "Finished migrations"
+1 -1
View File
@@ -35,7 +35,7 @@ test-e2e-native:
CYPRESS_HOST_ADMIN_URL='http://127.0.0.1:3232' \
CYPRESS_SAML_URL='http://127.0.0.1:3233' \
CYPRESS_MAILTRAP_URL='http://127.0.0.1:3234' \
npm run cypress:open
yarn run cypress:open
# For testing "native" on Linux
test-e2e-native-linux:
+1 -1
View File
@@ -72,7 +72,7 @@ services:
- USER_UID
- USER_GID
stop_grace_period: 0s
entrypoint: npm
entrypoint: yarn
command: run cypress:run
# See comment in Makefile regarding matching file paths
working_dir: $PWD
+2 -2
View File
@@ -11,8 +11,8 @@
},
"devDependencies": {
"@isomorphic-git/lightning-fs": "^4.6.0",
"@overleaf/promise-utils": "*",
"@overleaf/validation-tools": "*",
"@overleaf/promise-utils": "workspace:*",
"@overleaf/validation-tools": "workspace:*",
"@testing-library/cypress": "10.1.0",
"@types/adm-zip": "^0.5.7",
"@types/uuid": "^9.0.8",