Skip to content

fix(core): stop generating test-manifest-stub.ts into src/manifest during build #1024

@willgriffin

Description

@willgriffin

Summary

smrtPlugin still has legacy build behavior that writes a generated test-manifest-stub.ts into src/manifest whenever that directory exists. This dirties working trees in consumer packages and mixes generated build artifacts into tracked source.

Current behavior

In packages/core/src/vite-plugin/index.ts, closeBundle() does this:

  • writes dist/manifest.json
  • checks whether src/manifest/ exists
  • if it does, writes src/manifest/test-manifest-stub.ts

This means a package can end up with a modified tracked source file just from running a build.

Why this is a problem

  • Generated build/test artifacts should not be written into src/
  • It creates noisy dirty worktrees
  • It is easy for packages to accidentally keep legacy src/manifest directories around
  • The behavior is surprising because SMRT already prefers .smrt/manifest.json and dist/manifest.json in newer flows

Reproduction

  1. In a package using smrtPlugin, create src/manifest/
  2. Run vite build
  3. Observe src/manifest/test-manifest-stub.ts being generated by the plugin
  4. If that file is tracked, the checkout is now dirty

Evidence

Current logic in packages/core/src/vite-plugin/index.ts:

  • const manifestDir = resolve(projectRoot, "src/manifest")
  • if (existsSync(manifestDir)) { ... writeFileSync(resolve(manifestDir, "test-manifest-stub.ts"), stub) }

Expected behavior

Build output should stay in build/test output locations, not in src/.

Proposed fix

One of:

  1. Remove this legacy src/manifest/test-manifest-stub.ts generation from closeBundle() entirely
  2. Generate the stub into .smrt/ or dist/ instead
  3. Make the stub output path explicit/configurable and default it away from src/

I would lean toward removing the implicit src/manifest write entirely unless there is still a hard compatibility requirement.

Context

This came up in anytown.ai while cleaning up a package that kept getting dirtied by a generated src/manifest/test-manifest-stub.ts on local builds. Removing the stale src/manifest/ directory fixes that package locally, but the root cause is still in smrt-core.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions