chore(build): share assets across the three web targets#3908
Conversation
The main, public and intents targets were three separate rspack compilations, each re-bundling React, the cozy libraries and the editors into its own static tree. The registry tarball paid for every shared module up to three times (18MB, against a 20MB limit) and grew with every editor added. The three targets are now entries of a single compilation: shared modules are emitted once under build/static, served by a new public /static route so the share pages can load them without auth. Each target keeps its own index.html and the / route now points at /main. The tarball drops from 18MB to 10.8MB. Sharing the assets makes the PDF editor free for the public target (its chunks were already shipped for the logged-in app), so the editor is restored on shared links. It is now loaded lazily, which also drops it from the logged-in app's initial payload.
WalkthroughThis PR restructures the Twake Drive build pipeline to use a unified Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Our agent can fix these. Install it.
Gates Passed
3 Quality Gates Passed
Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
BundleMonFiles added (9)
Files removed (10)
Files updated (5)
Unchanged files (6)
Total files change -4.52MB -69.39% Groups updated (3)
Final result: ✅ View report in BundleMon website ➡️ |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/targets/public/components/AppRouter.jsx`:
- Around line 38-39: AppRouter currently calls getPublicPdfRoutes({ isReadOnly
}) but doesn't pass isReadOnly into the viewer components; update AppRouter to
pass the isReadOnly prop into LightFileViewer and PublicFileViewer (the
components returned by getPublicPdfRoutes). Then modify LightFileViewer.jsx
(around the CTA logic) and PublicFileViewer.jsx (around the PDF edit CTA) to
gate the editor CTA with both the feature flag and the read-only state—replace
checks like isPdfEditorEnabled() with isPdfEditorEnabled() && !isReadOnly (using
the isReadOnly prop passed in) so the edit CTA is disabled on read-only shares.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1a78b070-bbaa-4dc0-b34a-103de18868f8
📒 Files selected for processing (8)
.bundlemonrcmanifest.webapprsbuild.config.mjssrc/modules/public/LightFileViewer.jsxsrc/modules/views/Excalidraw/setupAssetPath.jssrc/modules/views/Pdf/routes.jsxsrc/modules/views/Public/PublicFileViewer.jsxsrc/targets/public/components/AppRouter.jsx
|
@Crash-- -69.39% |
zatteo
left a comment
There was a problem hiding this comment.
Interesting!
-
Did you properly tested local dev (
yarn startandyarn watch) with HMR, Excalidraw viewer & PDF viewer, public links, etc ? -
I propose to try 1 or 2 weeks with Drive and then move to rsbuild-config-cozy-app what is common with other app.
yes HMR is intact and the viewers also work fine in public and normal views ( while sharing assets of the editos ). i'm not merging this PR yet until the new release of drive. and yes the idea is to test it on drive and then bring it to the other apps via the shared build config |
Problem
The main, public and intents targets are three separate rspack compilations, so React, the cozy libraries and the editors are re-bundled into each target's own static tree. The registry tarball pays for every shared module up to three times: it sits at 18MB against the 20MB limit, and every new editor or heavy dependency multiplies its cost by the number of targets that use it. That pressure is what previously forced the PDF editor out of the public build.
Solution
The three targets become entries of a single compilation. Shared modules are emitted once under build/static, exposed through a new public /static route so share pages can load them without auth, and each target keeps its own index.html (the / route now points at /main). The react-pdf alias moves to the webpack5 entry so the pdf.js worker lands under static/ instead of the build root, where only the private route could serve it. The tarball drops from 18MB to 10.8MB and stays flat when a dependency is added to more targets.
Since the editor chunks are now shipped once regardless, the PDF editor is restored on shared links. It is also loaded lazily, keeping it out of the initial payload of both the public page and the logged-in app (about 1MB less each).
Worth knowing
All JS becomes publicly fetchable through /static, including chunks only used by the logged-in app. The code is AGPL and already published, so nothing sensitive changes hands.
Summary by CodeRabbit
New Features
Performance