Skip to content

[APPS][Connections Part 5] Move apps Vite behavior into getVitePlugin#357

Open
sdkennedy2 wants to merge 3 commits into
masterfrom
sdkennedy2/get-vite-plugin-refactor
Open

[APPS][Connections Part 5] Move apps Vite behavior into getVitePlugin#357
sdkennedy2 wants to merge 3 commits into
masterfrom
sdkennedy2/get-vite-plugin-refactor

Conversation

@sdkennedy2
Copy link
Copy Markdown
Collaborator

@sdkennedy2 sdkennedy2 commented May 11, 2026

Motivation

build-plugins#353 needs to find action-catalog call sites that are reachable from a *.backend.* entry file, even when the calls are defined in imported helper modules instead of directly inside the backend entry file.

That graph traversal needs more of the Vite/Rollup plugin context available where backend transformation happens: module resolution, module loading, watch-file registration, and eventually TypeScript-to-JavaScript fallback transforms for local modules. Keeping backend transform ownership split between packages/plugins/apps/src/index.ts and getVitePlugin would force the graph PR to thread more Vite-specific state through the top-level apps plugin entrypoint.

This PR isolates that behavior-neutral ownership move first. The follow-up graph PR can then focus on the actual traversal and extraction behavior instead of mixing it with structural movement.

Changes

Moves existing Vite-owned apps plugin behavior into getVitePlugin without changing the connection ID extraction boundary or upload behavior.

getVitePlugin now owns:

  • backend .backend.* transform and proxy generation
  • runtime injection at InjectPosition.MIDDLE
  • backend function registry creation and replacement semantics
  • backend build/upload sequencing during closeBundle
  • dev-server middleware registration

The top-level apps plugin entrypoint now validates options, checks that the bundler is Vite, and delegates Vite-specific behavior to getVitePlugin. getVitePlugin receives the factory context directly so it can read Vite/build metadata and use the same ownership boundary that the module traversal PR will extend.

The upload/archive/manifest path was also extracted into a focused Vite helper module. That keeps vite/index.ts centered on Vite hook wiring while preserving the existing frontend/backend archive layout, root manifest.json shape, upload errors/warnings, and cleanup behavior.

This remains behavior-neutral: the transform still uses the current entry-only connection ID extraction path, so imported helper modules are not newly analyzed in this PR.

QA Instructions

Automated:

  • yarn workspace @dd/apps-plugin typecheck
  • yarn workspace @dd/tests test:unit packages/plugins/apps/src/index.test.ts packages/plugins/apps/src/vite/index.test.ts --runInBand
  • yarn eslint packages/plugins/apps/src/index.ts packages/plugins/apps/src/vite/index.ts packages/plugins/apps/src/vite/handle-upload.ts packages/plugins/apps/src/index.test.ts packages/plugins/apps/src/vite/index.test.ts --quiet
  • git diff --check

Blast Radius

Affects @dd/apps-plugin Vite hook organization only. This PR should preserve generated backend proxies, runtime injection position, backend function registry replacement semantics, upload archive layout, manifest shape, upload cleanup, and dev-server middleware behavior.

The review risk is mostly refactor risk around preserving existing hook timing and upload inputs. New module traversal behavior remains isolated to the child PR.

Documentation

Copy link
Copy Markdown
Collaborator Author

sdkennedy2 commented May 11, 2026

@sdkennedy2 sdkennedy2 changed the title Move apps Vite behavior into getVitePlugin [APPS] Move apps Vite behavior into getVitePlugin May 11, 2026
@sdkennedy2
Copy link
Copy Markdown
Collaborator Author

@codex review
@cursor review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sdkennedy2 sdkennedy2 changed the title [APPS] Move apps Vite behavior into getVitePlugin [APPS][Connections Part 5] Move apps Vite behavior into getVitePlugin May 11, 2026
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/get-vite-plugin-refactor branch from d7a3e8c to cb0c1ca Compare May 11, 2026 16:54
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/same-module-connection-id-object-values branch from 3b2301a to 91ea1f0 Compare May 11, 2026 16:54
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/get-vite-plugin-refactor branch from cb0c1ca to 5ce434d Compare May 11, 2026 17:50
Base automatically changed from sdkennedy2/same-module-connection-id-object-values to master May 11, 2026 18:50
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/get-vite-plugin-refactor branch from 5ce434d to 67e2595 Compare May 11, 2026 18:58
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/get-vite-plugin-refactor branch from 67e2595 to ad770f4 Compare May 11, 2026 19:04
@sdkennedy2 sdkennedy2 marked this pull request as ready for review May 11, 2026 22:24
@sdkennedy2 sdkennedy2 requested review from a team and yoannmoinet as code owners May 11, 2026 22:24
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