Skip to content

Single-source the client templates duplicated between plugin-axios and plugin-fetch #671

Description

@stijnvanhulle

Follow-up to #670. A Fallow duplication scan (fallow dupes --mode mild) shows the shipped client templates are maintained as hand-synced copies:

  • packages/plugin-axios/templates/serializers.ts and packages/plugin-fetch/templates/serializers.ts are 427 identical lines (the largest hand-written clone in the repo).
  • templates/standardSchema.ts exists three times, byte-identical: internals/client/templates/, packages/plugin-axios/templates/, packages/plugin-fetch/templates/.

There is no copy script or CI check keeping them in sync today; they are identical only by discipline. The copies have to keep shipping inside each published package (both list templates in files and expose ./templates/* in exports), so simply importing from @internals/client is not an option.

Goal

One source of truth per template. A fix to the query-string serializer or the standard-schema shim lands once and cannot drift between the axios and fetch clients.

Approach

  • Treat internals/client/templates/ as the source of truth and move serializers.ts there next to standardSchema.ts.
  • Add a build or prepublish step (a small script wired into the turbo build task) that copies internals/client/templates/* into each client plugin's templates/ directory.
  • Add a CI check (or generate into a gitignored path) so a stale copy fails the build instead of shipping.

Acceptance

  • serializers.ts and standardSchema.ts each have exactly one hand-edited source.
  • Published packages still ship templates/serializers.ts and templates/standardSchema.ts at the same paths (no consumer-facing change).
  • Editing a plugin-local copy directly fails CI or is impossible.
  • fallow dupes no longer reports the serializers or standardSchema clone groups.

🤖 Generated with Claude Code

https://claude.ai/code/session_014dHSbuoSN5pYaXowWwZj5B

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions