Skip to content

chore: Use the isolated pnpm node_modules layout - #25368

Draft
JPeer264 wants to merge 4 commits into
jp/move-to-pnpmfrom
jp/pnpm-isolated
Draft

JPeer264 wants to merge 4 commits into
jp/move-to-pnpmfrom
jp/pnpm-isolated

Conversation

@JPeer264

@JPeer264 JPeer264 commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

This moves the monorepo from the hoisted node_modules layout to the isolated pnpm default. Each package now declares the packages that it imports, instead of using what the root folder had. A full build gives the same files as with the hoisted layout.

  • Packages declare the dependencies that they imported from the hoisted root folder, with the version that the root folder had. The lockfile gets no new versions.
  • The root package.json no longer lists every workspace package as workspace:*. Each package declares the workspace packages that it imports, for example @sentry-internal/rollup-utils in the rollup configs. The root keeps three of them: @sentry-internal/node-integration-tests (its suites import it by name, also from tmp folders with their own package.json), @sentry/eslint-plugin-sdk (oxlint plugin) and @sentry/sveltekit (size-limit bundles its self-import).
  • @sentry/replay declares @sentry/conventions as a devDependency, so its build still inlines the constant from there.
  • rollup-utils reads the sideEffects field of external packages from the nearest node_modules of the built package, not only from the root folder.
  • The integration test runner adds the bins of node-integration-tests to the PATH of setup commands (for example prisma generate), because the Bun and Deno packages run the shared suites with their own PATH.
  • The install-playwright action runs npx playwright outside the repository. In the repository, npm finds that version in node_modules/.pnpm and then looks for node_modules/.bin/playwright, which the root folder no longer has.

SDK fix

modulesIntegration did not find the versions of CJS modules in the isolated pnpm layout (node_modules/.pnpm/<id>/node_modules/<name>), so pnpm apps got the version ranges of their package.json instead. It now reads these folders too. The suites/modules CJS test covers it, because it now runs on this layout.

packageExtensions decisions

@apm-js-collab/code-transformer-bundler-plugins imports the types of Vite, Rollup, webpack and esbuild without declaring them. pnpm-workspace.yaml declares them as optional peers, so its types use the Vite of the importing package. The real fix belongs upstream.

Peer decisions

autoInstallPeers stays false. The pnpm default (true) adds 674 package versions for peers that no package needs, for example @glimmer/component and the GraphQL tools of Gatsby.

Known issues

  • Size Check shows about 4 KB more for the unminified @sentry/cloudflare (withSentry) entry, so its limit goes from 514 KiB to 515 KiB. Some other entries change by up to 200 bytes. The bundled code is the same, but the bundles contain the longer node_modules/.pnpm/... file paths.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.88 kB - -
@sentry/browser - with treeshaking flags 28.02 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.92 kB - -
@sentry/browser (incl. Tracing) 52.07 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.07 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.02 kB - -
@sentry/browser (incl. Tracing, Replay) 91.82 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 80.68 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 96.55 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 109.49 kB - -
@sentry/browser (incl. Feedback) 47.4 kB - -
@sentry/browser (incl. sendFeedback) 34.94 kB - -
@sentry/browser (incl. FeedbackAsync) 40.05 kB - -
@sentry/browser (incl. Metrics) 30.9 kB - -
@sentry/browser (incl. Logs) 31.18 kB - -
@sentry/browser (incl. Metrics & Logs) 31.81 kB - -
@sentry/react 31.7 kB +0.01% +1 B 🔺
@sentry/react (incl. Tracing) 54.39 kB +0.01% +2 B 🔺
@sentry/vue 38.04 kB - -
@sentry/vue (incl. Tracing) 55.01 kB - -
@sentry/svelte 29.9 kB - -
@sentry/remix (Remix 3 client bundle) 57.08 kB - -
CDN Bundle 31.64 kB - -
CDN Bundle (incl. Tracing) 52.58 kB - -
CDN Bundle (incl. Logs, Metrics) 33.84 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 54.52 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.77 kB - -
CDN Bundle (incl. Tracing, Replay) 90.25 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 92.18 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.4 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.34 kB - -
CDN Bundle - uncompressed 93.18 kB - -
CDN Bundle (incl. Tracing) - uncompressed 156.03 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.72 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 161.99 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.76 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 276.2 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 282.14 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 289.9 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 295.84 kB - -
@sentry/nextjs (client) 56.8 kB +0.01% +1 B 🔺
@sentry/sveltekit (client) 52.45 kB - -
@sentry/core/server 41.12 kB - -
@sentry/core/browser 13.81 kB - -
@sentry/node 152.48 kB +0.01% +15 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.81 kB -0.01% -1 B 🔽
@sentry/node - without tracing 94.61 kB +0.01% +1 B 🔺
@sentry/node - without channel injection 130.7 kB +0.01% +11 B 🔺
@sentry/aws-serverless 102.77 kB +0.01% +3 B 🔺
@sentry/cloudflare (withSentry) - minified 210.6 kB - -
@sentry/cloudflare (withSentry) 526.49 kB +0.76% +3.96 kB 🔺
@sentry/nextjs/cloudflare (withSentry) - minified 228.27 kB - -

View base workflow run

@JPeer264
JPeer264 force-pushed the jp/pnpm-isolated branch 2 times, most recently from 755fc00 to 00d9d69 Compare October 14, 2026 20:33
@JPeer264
JPeer264 added this pull request to stack #25387 October 15, 2026 08:47
@JPeer264
JPeer264 force-pushed the jp/pnpm-isolated branch 2 times, most recently from f1386d1 to 5c6dd85 Compare October 15, 2026 11:20
@JPeer264
JPeer264 force-pushed the jp/pnpm-isolated branch 2 times, most recently from 3ab242c to 621c3a3 Compare October 15, 2026 14:57
JPeer264 and others added 4 commits October 15, 2026 12:10
`modulesIntegration` reads the version of each CJS module in
`require.cache` from its package.json in a node_modules folder of the
main module. The isolated pnpm layout keeps the package files in
`node_modules/.pnpm/<package id>/node_modules/<name>`, so the
integration found no version there and reported the version range from
the app's package.json instead.

Read these folders like the node_modules folders of the main module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test runs a webpack production build. On the Node 20 CI runners it
takes 3 to 5 seconds, close to the 5 second default timeout, and some
runs time out. Locally it takes about 0.3 seconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove `nodeLinker: hoisted` and `shamefullyHoist`, so pnpm installs its
default isolated layout. Each package now resolves only the dependencies
that it or the root package.json declares.

- Packages declare the dependencies that they imported from the hoisted
  root folder, with the version that the root folder had. The lockfile
  gets no new versions.
- `tslib` is a root devDependency, because the shared tsconfig sets
  `importHelpers`.
- @sentry/replay declares `@sentry/conventions` as a devDependency, so
  its build still inlines the constant that it imports from there.
- react-router, solidstart, sveltekit and tanstackstart-react declare
  `@types/node` 18 like the root. Without it, the optional `@types/node`
  peer of Vite resolves to version 20, and the Vite plugin types of
  @sentry/server-utils do not match.
- `packageExtensions` declares the bundlers as optional peers of
  @apm-js-collab/code-transformer-bundler-plugins, because its type
  declarations import them.
- rollup-utils reads the `sideEffects` field of an external package from
  the nearest node_modules folder of the built package, not only from the
  root folder. Without this, the builds keep empty imports of packages
  that are not in the root folder, for example `import '@sentry/core'`.
- The integration test runner adds the bins of node-integration-tests
  to the `PATH` of setup commands such as `prisma generate`, because the
  Bun and Deno packages run the shared suites with their own `PATH`.
- The install-playwright action runs `npx playwright` outside the
  repository. In the repository, npm finds the playwright version in
  `node_modules/.pnpm` and then runs `node_modules/.bin/playwright`,
  which the root folder no longer has.
- The size limit of `@sentry/cloudflare (withSentry)` goes from 514 KiB
  to 515 KiB. This check bundles without minification, so the bundle
  keeps the module paths, which are about 4 KB longer under
  `node_modules/.pnpm`. The code in the bundle is the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The root package.json listed every workspace package as a `workspace:*`
devDependency, so that each package could import any of them from the
root node_modules folder like with Yarn. Remove these entries and
declare the workspace packages in the packages that import them, for
example `@sentry-internal/rollup-utils` in the rollup configs.

The root keeps three of them:
- `@sentry-internal/node-integration-tests`, because its suites import
  it by its own name, also from tmp folders that have their own
  package.json.
- `@sentry/eslint-plugin-sdk`, because the root oxlint config loads it
  as a JS plugin.
- `@sentry/sveltekit`, because size-limit bundles its build output,
  which imports `@sentry/sveltekit/browser-tracing-variant`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant