aspect-build / aspect-build/rules_js

[FR]: Clean source in js_run_binary to prevent conflict

Open
#1,115 5 comments 2 reactions 0 assignees View on GitHub
enhancement need: more info
Dominant language
Starlark
Stars
378
Forks
183
Avg merge
1d 9h
Merged PRs (30d)
32

Description

### What is the current behavior?

`js_run_binary` has copy_srcs_to_bin action, this action only copy new/modified files, but do not remove deleted files.

For example, I have `a.ts` in a new branch, after I use `js_run_binary` to compile my source code, `a.ts` will be copied into bazel-bin directory. Later I checkout my master branch, the `a.ts` still exists in bazel-bin directory, following compiling may be failure cause `a.ts` is not compatible with master branch code.

Follow up the problem, I tried to use `genrule` to delete all the source code in `bazel-bin`, then I found `js_run_binary` will not copy all source code to `bazel-bin` again. I guess it because copy_src_to_bin use action to declare every source code, when the source code has no change, bazel treat it as cached output in analysis stage, but remove action in `genrule` effects in process stage.

### Describe the feature

I hope there is some way to remove deleted files in `bazel-bin`, in bazel way.

Contributor guide

Open the contributing guide

Research direction

Start with the js_run_binary rule and its copy_srcs_to_bin action, then reproduce the branch-switch scenario described in the issue. Examine how Bazel caching interacts with deleted sources and the genrule cleanup attempt. Done means deleted source files no longer remain in bazel-bin while unchanged sources are still available for subsequent compilation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.