facebook / facebook/relay

Custom `artifactDirectory` has to exist and is not automatically created (like `__generate__`)

Open
#3,782 10 comments 6 reactions 0 assignees View on GitHub
help wanted rust
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

When specifying a custom `artifactDirectory` in the relay compiler config, ​the compiler requires this directory to exist. Otherwise you get:

```
[ERROR] Config `/home/.../frontend/relay.config.js` is invalid:
​- The `artifactDirectory` does not exist at `/home/.../frontend/src/query-types`.
```

This is particularly annoying when using git, as you cannot check empty folders into git. The typical "`.gitkeep` file in folder" trick does not work well, because the relay-compiler deletes all files from the artifact directory on each compile, always leading to a dirty working directory.

I think the best is to use the same behavior as for the default `__generated__` folder: create it, if it doesn't exist.

---

This problem only occurred after upgrading to v13 (i.e. the compiler written in Rust).

Contributor guide

Open the contributing guide

Research direction

Reproduce the v13 Rust relay compiler behavior with a relay.config.js that sets artifactDirectory to a missing path, and compare it with the default __generated__ directory. Trace the artifactDirectory validation and creation path; done means a missing custom directory is created automatically without requiring a .gitkeep file.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.