BuilderIO / BuilderIO/mitosis

Mitosis does not always accurately delete old files

Open
#280 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
14.4k
Forks
671
PR merge metrics
No merged PRs in 30d

Description

Ran into a tricky bug the other day. Had a file `src/helpers/foo.ts`, and moved it to `src/helpers/foo/index.ts` to be able to add helpers. Unfortunately, the `clean()` function will only delete outputs that match the _current_ list of existing files. Since there was no longer a `src/helpers/foo.ts`, `clean()` did not attempt to delete it.

We don't want to blindly delete the entire output dir. We have cases where we have files there that need to stay, such as a `dist/package.json`, etc.

https://github.com/BuilderIO/mitosis/blob/main/packages/cli/src/build/build.ts#L94-L102

Contributor guide

Open the contributing guide

Research direction

Start in packages/cli/src/build/build.ts around lines 94-102 and trace how clean() determines which outputs to delete. Reproduce the file move from src/helpers/foo.ts to src/helpers/foo/index.ts, while checking that files such as dist/package.json remain untouched. Done means obsolete outputs are removed without deleting unrelated files in the output directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.