Skip to content

Replace hardcoded virtual module IDs with caller-provided import function#613

Draft
Copilot wants to merge 2 commits intodevfrom
copilot/update-plugins-to-use-import-function
Draft

Replace hardcoded virtual module IDs with caller-provided import function#613
Copilot wants to merge 2 commits intodevfrom
copilot/update-plugins-to-use-import-function

Conversation

Copy link

Copilot AI commented Feb 5, 2026

Plugins previously hardcoded virtual module IDs ("virtual:remix/server-build", "virtual:react-router/server-build") as string parameters passed to createPlugin. This couples the implementation to specific Vite virtual module paths.

Changes

PluginOptions

  • Added serverBuildImport?: () => Promise<ServerBuild> - caller provides the import function instead of a string ID

createPlugin

  • Removed virtualModule parameter
  • Uses serverBuildImport() to load development builds
  • Throws clear error if serverBuildImport missing in Vite development mode

remixFastify / reactRouterFastify

  • Provide default implementations: () => import("virtual:remix/server-build") and () => import("virtual:react-router/server-build")
  • Backward compatible - existing code works unchanged

Usage

Default behavior unchanged:

await app.register(remixFastify);

Custom virtual module now possible:

await app.register(remixFastify, {
  serverBuildImport: () => import("virtual:custom-build")
});
Original prompt

Update the Remix/Fastify plugins to stop hardcoding Vite virtual module IDs and instead accept a caller-provided import function.

Scope:

  • Repo: mcansh/remix-fastify
  • Files likely involved:
    • packages/remix-fastify/src/plugins/index.ts
    • packages/remix-fastify/src/plugins/remix.ts
    • packages/remix-fastify/src/plugins/react-router.ts

Requirements:

  1. Introduce a new option in the shared PluginOptions for providing a virtual module import function.
    • The caller will pass something like: () => import("virtual:remix/server-build") or () => import("virtual:react-router/server-build").
    • This should replace any hardcoded virtual module ID strings.
  2. Update createPlugin (and any related types) to use the new option instead of receiving a hardcoded virtual module ID.
  3. Update remixFastify and reactRouterFastify to accept the new option and pass it through.
  4. Ensure types reflect that the import function returns a ServerBuild (or Promise of it).
  5. Update any docs/comments if necessary to reflect the new option behavior.

Target base branch: dev (if it exists; it does).

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2026

⚠️ No Changeset found

Latest commit: 9e0f046

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Co-authored-by: mcansh <11698668+mcansh@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Remix/Fastify plugins to accept import function for virtual modules Replace hardcoded virtual module IDs with caller-provided import function Feb 5, 2026
Copilot AI requested a review from mcansh February 5, 2026 02:35
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 5, 2026

More templates

npm i https://pkg.pr.new/@mcansh/remix-fastify@613

commit: 9e0f046

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 5, 2026

More templates

npm i https://pkg.pr.new/@mcansh/remix-fastify@613

commit: 9e0f046

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.

2 participants