[APPS] Use separate vite.build() for backend functions, drop Rollup backend support#292
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🔗 Commit SHA: 5421cb8 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
| * Build all backend functions using a separate vite.build() call. | ||
| * Produces one standalone JS file per function in a temp directory. | ||
| */ | ||
| export async function buildBackendFunctions( |
There was a problem hiding this comment.
I put this here because the logic is largely coupled to vite versus the code in the backend folder.
| // viteBuild always returns RolldownOutput here since we don't set build.watch. | ||
| // RolldownWatcher would only be returned if watch mode were enabled. |
There was a problem hiding this comment.
Not sure I understand this comment.
Can you expand on to why it's clarifying exactly.
sarenji
left a comment
There was a problem hiding this comment.
I have a small potential improvement. Otherwise LGTM
| backendOutDir = await buildBackendFunctions( | ||
| viteBuild, | ||
| functions, | ||
| backendOutputs, |
There was a problem hiding this comment.
backendOutputs is potentially something you can instantiate within the plugin and pass to handleUpload.
Note that tests currently have to do a workaround to reset backendOutputs, so test isolation is reduced. However, if you pass backendOutputs to handleUpload then backendOutputs is properly isolated and you can put a spy on handleUpload and still be able to test backendOutputs even outside the function.
…ackend support Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… existing repo version
d2b2a1b to
03c5f9c
Compare

Motivation
Backend functions were previously built by injecting virtual modules into the host bundler's build via
resolveId/loadhooks, with separate Rollup and Vite plugin implementations that duplicated logic. This approach was fragile — it coupled backend function bundling to the host build's configuration (plugins, aliases, output settings) and required maintaining two codepaths (Rollup + Vite).This PR switches to a standalone
vite.build()call that runs after the host build completes, giving full control over the backend build configuration. It also drops Rollup backend support entirely, simplifying to vite-only.Changes
Replaced the "inject into host build" approach with a dedicated
vite.build()for backend functions:Why a separate build? Backend functions need different build settings than the frontend — no minification, ES module format, preserved entry signatures, and no interference from the user's vite plugins. Running a standalone
vite.build()withconfigFile: falseprovides this isolation cleanly.Key changes:
backend/rollup.ts— Rollup backend support removedbackend/index.ts— removedresolveId/loadhooks, now just delegates to the vite pluginbuildBackendFunctions()inbackend/vite/index.ts— runs a separatevite.build()viacloseBundlehook, writes output to a temp directory, populatesbackendOutputsmap for the upload pluginvirtual-entry.ts— extractedgenerateMainBody()helper for reuseshared.ts—isActionCatalogInstalled()now accepts afromDirparameter for correct resolution when the plugin is linked, fixed regex escaping in action-catalog bridgebackendSupportedBundlersfrom['rollup', 'vite']to['vite']QA Instructions
yarn devin build-pluginsnpx vite build) and verify backend function.jsfiles are generated and included in the upload archiveBlast Radius
apps.backendDiris configuredDocumentation