microsoft / microsoft/TypeScript

`tsBuildInfoFile` is not extendable. Add an alternative `tsBuildInfoDir` option

Ouverte
#61,794 0 commentaires 6 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Awaiting More Feedback Suggestion
Langage dominant
Go
Étoiles
111k
Forks
14.3k
Merge moyen
2 j 4 h
PR mergées (30 j)
132

Description

🔍 Search Terms

tsBuildInfoFile tsbuildinfo output directory

✅ Viability Checklist
⭐ Suggestion

Add a tsBuildInfoDir config option for specifying the output directory for the .tsbuildinfo file.

📃 Motivating Example
tsconfig/
├── tsconfig.base.json
├── tsconfig.client.json
├── tsconfig.config.json
└── tsconfig.server.json
tsconfig.json

With a project structure like this, there is no way to have the individual project configs (tsconfig.client.ts etc.) derive their tsBuildInfoFile setting from the base config (tsconfig.base.json). If we set tsBuildInfoFile to some custom value in the base config, the individual project configs all end up having the same output path for their .tsbuildinfo files, which is of course wrong, so we have no better option than to set tsBuildInfoFile for each of the projects individually.

The recently introduced ${configDir} template variable can't help us here since the config files are all located in the same folder. Even if they weren't, it still wouldn't give us enough flexibility.

One possible solution is to rely on the outDir option which also affects where .tsbuildinfo files are placed, but it's only fine if we don't mind them being placed beside other output files, or if there are no other output files because we are using noEmit.

What I suggest is adding a tsBuildInfoDir option for specifying the output directory for the .tsbuildinfo file as an alternative to tsBuildInfoFile. The process of determining how the file is placed within that directory should be identical to that of outDir / declarationDir, meaning that the config file's placement relative to rootDir should be replicated.

With the following tsconfig.base.json,

// tsconfig.base.json
{
  "compilerOptions": {
    "rootDir": "${configDir}",
    "outDir": "${configDir}/dist",
    "tsBuildInfoDir": "./node_modules/.tsbuildinfo",
    "incremental": true
  }
}

this would enable structure as complicated as this one:

client/
│── dist/
│   │── index.js
│── index.ts
└── tsconfig.client.json
node_modules/
└── .tsbuildinfo/
    ├── tsconfig.client.tsbuildinfo
    ├── tsconfig.config.tsbuildinfo
    ├── tsconfig.server.tsbuildinfo
    └── tsconfig.tsbuildinfo
server/
│── dist/
│   │── index.js
│── index.ts
└── tsconfig.server.json
tsconfig.base.json
tsconfig.config.json
tsconfig.json
vite.config.ts

Here is what I assumed about the other config files:

Click to expand
// client/tsconfig.client.json
{
  "include": ["**/*.ts"]
}

// client/tsconfig.server.json
{
  "include": ["**/*.ts"]
}

// tsconfig.config.json
{
  "compilerOptions": {
    "noEmit": true
  },
  "include": ["*.config.ts"]
}

// tsconfig.json
{
  "files": [],
  "references": [
    { "path": "./client/tsconfig.client.json" },
    { "path": "./server/tsconfig.server.json" },
    { "path": "./tsconfig.config.json" }
  ]
}

When both tsBuildInfoDir and tsBuildInfoFile are set, the latter could be interpreted as the desired file name rather than the path (the path is then ${tsBuildInfoDir}/${tsBuildInfoFile}).

💻 Use Cases
  1. What do you want to use this for?
    → Putting .tsbuildinfo files under node_modules/.tsbuildinfo so that they are not in the way, but I still get the advantages of incremental builds.
  2. What shortcomings exist with current approaches?
    → The shortcomings of tsBuildInfoFile and outDir are described above.
  3. What workarounds are you using in the meantime?
    → Setting tsBuildInfoFile for each project individually :(

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Aucun fichier source ni test n’est nommé. Commencez par retracer comment tsBuildInfoFile, outDir et declarationDir déterminent les chemins des fichiers de build et comment la configuration héritée est résolue. Le travail est terminé lorsqu’une option tsBuildInfoDir prend en charge la disposition de répertoires proposée, préserve le comportement existant et couvre les exemples de configuration et les interactions décrits ici.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
build-system, compilers
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
30/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.