Repository navigation
perf(ui): Take shared libraries from the portal and upload source maps - #613
Merged
Merged
Conversation
The plugin bundled its own copy of every module it shares with cloud-portal: react, react-dom, react-router, react-query and the curated datum-ui subset. The host's copy always wins at runtime, but the browser still fetched and parsed each fallback on every load. Builds now mark those modules import: false, so they rely on the host, which registers every one of them. Dev keeps the fallbacks so the standalone preview runs without a host. react/jsx-runtime keeps its own small copy: the host does not share that subpath, and left implicit it would inherit import: false from react and fail to load. The built bundle drops from 80 to 46 JavaScript files, 2.4MB to 2.0MB raw and 770KB to 622KB gzipped. Ported from #481, which predates #606 and the move to pnpm.
The plugin runs inside cloud-portal, so its errors land in the portal's Sentry project with minified frames. The build now uploads its maps there, matched by debug ID rather than release, since the portal's release names its own build. The maps stay in the image as well, so devtools keep showing source as they have since #606. - @sentry/vite-plugin 5.4.1, the version cloud-portal resolves, uploads only when SENTRY_AUTH_TOKEN is set. Local and fork builds skip it, and a failed upload logs without failing the build. - @sentry/cli may run its install script locally. CI and the image install with --ignore-scripts and use its prebuilt Linux packages. - The token reaches the image build as a BuildKit secret through publish-docker's build-secrets. The consumer job drops `secrets: inherit`, which would also forward the token as a build argument that persists in the exported build cache. Ported from #481.
ecv
approved these changes
Nov 4, 2026
ecv
left a comment
Contributor
There was a problem hiding this comment.
Approve.
Production builds stop bundling local copies of react, react-dom, react-router, react-query and the datum-ui subpaths and take them from the portal, and the build uploads source maps to the portal's Sentry project. CI is green, including the consumer plugin image build.
- The token is passed only as a BuildKit secret to the one consumer-plugin job (
secrets: inheritis removed so it never reaches publish-docker's build-arg path, which persists in the exported cache), mounted withrequired=falsefor a singleRUN, and the repo currently has noSENTRY_AUTH_TOKENsecret, so the upload is skipped and the build succeeds until one is added. - The portal's
federation-host.tsshares every key this plugin marksimport: false(react, react-dom, react-router, react-query and the nine datum-ui subpaths), so the plugin resolves at runtime today.react/jsx-runtimekeeps its local fallback. - The upload does not make the maps private.
build.sourcemap: truestill emits.mapfiles plussourceMappingURLcomments into the image, which the portal serves, as before. The portal itself useshidden.
Follow-ups:
- Version coupling is now harder: with
import: falsethere is no local fallback, so if the portal stops sharing a datum-ui subpath or bumps a major past the plugin'srequiredVersion, the plugin pages fail to load instead of degrading. Add a plugin-side check against the portal's shared list, or release plugin and portal changes in order (portal exports first). - Set
build.sourcemap: 'hidden'orsourcemaps.filesToDeleteAfterUploadon the Sentry plugin once a token exists, so the maps live only in Sentry. Consider a Sentryreleaseso frames are not tied to debug IDs alone. - Standalone
vite previewof a production build no longer works without the host. - Once a token exists,
vite.config.tssets no SentryerrorHandler, so a Sentry outage or a bad token fails the build and blocks the image publish. Add anerrorHandlerthat logs and continues if publishing should not depend on Sentry. - BuildKit leaves secret values out of the cache key, so a cached tokenless
pnpm buildstep can be reused after the token is added and silently skip the upload. Bust that step's cache once when the secret first lands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The compute plugin shipped its own copy of every library it shares with the portal, so the browser downloaded and parsed each one on every load even though the portal's copy always wins.
Production builds now take those libraries from the portal, cutting the plugin from 80 to 46 script files and from 770KB to 622KB gzipped.
The build also uploads source maps to the portal's Sentry project, so plugin errors show readable frames, with the token passed as a build secret that never lands in the image or its cache.
This ports the parts of #481 that are still missing, since that PR predates the minified build and the move to pnpm.
Notes for reviewers
Nobody has confirmed that the org's Sentry token is shared with this repository. Without it the upload is skipped and the build still succeeds.
Test plan
Fixes #612