Skip to content

Commit 3faba06

Browse files
committed
Merge pull request #715 from sszuflita/master
Support rewriteTsconfig flag in tsconfig.json
2 parents 87b44bc + 2d95e76 commit 3faba06

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

dist/main/tsconfig/tsconfig.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ function getDefaultInMemoryProject(srcFile) {
178178
formatCodeOptions: formatting.defaultFormatCodeOptions(),
179179
compileOnSave: true,
180180
buildOnSave: false,
181-
scripts: {}
181+
scripts: {},
182+
atom: { rewriteTsconfig: true },
182183
};
183184
return {
184185
projectFileDirectory: dir,
@@ -214,7 +215,7 @@ function getProjectSync(pathOrSrcFile) {
214215
}
215216
if (projectSpec.filesGlob) {
216217
var prettyJSONProjectSpec = prettyJSON(projectSpec, detectIndent(projectFileTextContent).indent);
217-
if (prettyJSONProjectSpec !== projectFileTextContent) {
218+
if (prettyJSONProjectSpec !== projectFileTextContent && projectSpec.atom.rewriteTsconfig) {
218219
fs.writeFileSync(projectFile, prettyJSONProjectSpec);
219220
}
220221
}
@@ -244,7 +245,8 @@ function getProjectSync(pathOrSrcFile) {
244245
typings: [],
245246
externalTranspiler: projectSpec.externalTranspiler == undefined ? undefined : projectSpec.externalTranspiler,
246247
scripts: projectSpec.scripts || {},
247-
buildOnSave: !!projectSpec.buildOnSave
248+
buildOnSave: !!projectSpec.buildOnSave,
249+
atom: { rewriteTsconfig: true }
248250
};
249251
var validationResult = validator.validate(projectSpec.compilerOptions);
250252
if (validationResult.errorMessage) {

docs/faq.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
## I keep getting changes to tsconfig.json
44
This is probably because of us keeping `files` updated with the `filesGlob` option. The reason why we do this is because the official `tsconfig.json` spec does not support `filesGlob`. Therefore we keep `files` in sync with the `filesGlob` so that your team mates can use whatever editor they prefer (sublime text, visual studio etc.).
55

6+
You can now disable this behavior by setting the `rewriteTsconfig` flag to `false` in your project's `tsconfig.json` under the `atom` key.
7+
8+
[Further Details](https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#atom)
9+
610
## For really large projects atom-typescript gets slow
711
If you have `tsconfig.json` in a folder that contains `node_modules`, atom-typescript might become slow (due to extensive file listing). Two possible fixes:
812
* Move `tsconfig.json` into a sub folder e.g. `src`

docs/tsconfig.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ i.e. an empty JSON file at the *root* of your project :heart: This will be suffi
2020
* [`compileOnSave`](https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#compileonsave) : Should AtomTS compile on save
2121
* [`buildOnSave`](https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#buildonsave) : Should AtomTS build on save
2222
* [`scripts`](https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#scripts) : Sometimes its useful to have post build scripts
23-
23+
* [`atom`](https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#rewriteTsconfig) : Configuration specific to Atom. Currently
24+
only contains `rewriteTsconfig` which prevents Atom from rewriting a project's `tsconfig.json`.
2425

2526
## Examples
2627

@@ -115,5 +116,23 @@ Build means *compile all files*. Useful if for some reason you are using `--out`
115116
}
116117
```
117118

119+
### atom
120+
Configuration options specific to Atom.
121+
122+
123+
**rewriteTsconfig**
124+
125+
Atom-Typescript constantly resolves the `filesGlob` listed in your `tsconfig.json` to ensure that the glob is in sync
126+
with your project. If your project doesn't require this (you are managing your `filesGlob` some other way), set this
127+
to `false` (this defaults to `true`).
128+
129+
```json
130+
{
131+
"atom": {
132+
"rewriteTsconfig": true
133+
}
134+
}
135+
```
136+
118137
## Additional Notes
119138
FWIW [a json schema is also available](http://json.schemastore.org/tsconfig)

lib/main/tsconfig/tsconfig.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ interface TypeScriptProjectRawSpecification {
137137
buildOnSave?: boolean;
138138
externalTranspiler?: string | { name: string; options?: any };
139139
scripts?: { postbuild?: string };
140+
atom?: { rewriteTsconfig?: boolean };
140141
}
141142

142143
/**
@@ -154,6 +155,7 @@ export interface TypeScriptProjectSpecification {
154155
package?: UsefulFromPackageJson;
155156
externalTranspiler?: string | { name: string; options?: any };
156157
scripts: { postbuild?: string };
158+
atom: { rewriteTsconfig: boolean };
157159
}
158160

159161
///////// FOR USE WITH THE API /////////////
@@ -345,7 +347,8 @@ export function getDefaultInMemoryProject(srcFile: string): TypeScriptProjectFil
345347
formatCodeOptions: formatting.defaultFormatCodeOptions(),
346348
compileOnSave: true,
347349
buildOnSave: false,
348-
scripts: {}
350+
scripts: {},
351+
atom: { rewriteTsconfig: true },
349352
};
350353

351354
return {
@@ -396,7 +399,7 @@ export function getProjectSync(pathOrSrcFile: string): TypeScriptProjectFileDeta
396399
if (projectSpec.filesGlob) { // for filesGlob we keep the files in sync
397400
var prettyJSONProjectSpec = prettyJSON(projectSpec, detectIndent(projectFileTextContent).indent);
398401

399-
if (prettyJSONProjectSpec !== projectFileTextContent) {
402+
if (prettyJSONProjectSpec !== projectFileTextContent && projectSpec.atom.rewriteTsconfig) {
400403
fs.writeFileSync(projectFile, prettyJSONProjectSpec);
401404
}
402405
}
@@ -429,7 +432,8 @@ export function getProjectSync(pathOrSrcFile: string): TypeScriptProjectFileDeta
429432
typings: [],
430433
externalTranspiler: projectSpec.externalTranspiler == undefined ? undefined : projectSpec.externalTranspiler,
431434
scripts: projectSpec.scripts || {},
432-
buildOnSave: !!projectSpec.buildOnSave
435+
buildOnSave: !!projectSpec.buildOnSave,
436+
atom: { rewriteTsconfig: true }
433437
};
434438

435439
// Validate the raw compiler options before converting them to TS compiler options

0 commit comments

Comments
 (0)