Skip to content

Commit

Permalink
Use new $configDir setting in tsconfig (#2532)
Browse files Browse the repository at this point in the history
  • Loading branch information
pokey authored Jul 19, 2024
1 parent e1f1b27 commit 99969ac
Show file tree
Hide file tree
Showing 17 changed files with 18 additions and 56 deletions.
2 changes: 0 additions & 2 deletions packages/cheatsheet-local/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "out",
"jsx": "react-jsx",
"lib": ["es5", "es6", "dom"],
"allowSyntheticDefaultImports": true,
Expand Down
2 changes: 0 additions & 2 deletions packages/cheatsheet/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "out",
"jsx": "react-jsx",
"esModuleInterop": true,
"skipLibCheck": true,
Expand Down
4 changes: 0 additions & 4 deletions packages/common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "out",
"rootDir": "src"
},
"include": ["src/**/*.ts", "src/**/*.json", "../../typings/**/*.d.ts"],
"references": []
}
4 changes: 0 additions & 4 deletions packages/cursorless-cheatsheet/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "out",
"rootDir": "src"
},
"include": ["src/**/*.ts", "src/**/*.json", "../../typings/**/*.d.ts"],
"references": [
{
Expand Down
4 changes: 1 addition & 3 deletions packages/cursorless-engine/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "es2020",
"outDir": "out",
"rootDir": "src"
"target": "es2020"
},
"include": ["src/**/*.ts", "src/**/*.json", "../../typings/**/*.d.ts"],
"references": [
Expand Down
4 changes: 1 addition & 3 deletions packages/cursorless-org-docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"extends": ["@tsconfig/docusaurus/tsconfig.json", "../../tsconfig.base.json"],
"compilerOptions": {
"rootDir": "src",
"esModuleInterop": true,
"emitDeclarationOnly": false,
"outDir": "out"
"emitDeclarationOnly": false
},
"references": [],
"include": ["src/**/*.ts", "src/**/*.json", "../../typings/**/*.d.ts"]
Expand Down
4 changes: 1 addition & 3 deletions packages/cursorless-org/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"rootDir": "src",
"outDir": "out"
"incremental": true
},
"include": [
"src/**/*.ts",
Expand Down
4 changes: 0 additions & 4 deletions packages/cursorless-vscode-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "out",
"rootDir": "src"
},
"references": [
{
"path": "../common"
Expand Down
4 changes: 1 addition & 3 deletions packages/cursorless-vscode/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "es2020",
"outDir": "out",
"rootDir": "src"
"target": "es2020"
},
"include": ["src/**/*.ts", "src/**/*.json", "../../typings/**/*.d.ts"],
"references": [
Expand Down
16 changes: 10 additions & 6 deletions packages/meta-updater/src/updateTSConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { pathExists } from "path-exists";
import { PackageJson, TsConfigJson } from "type-fest";
import { toPosixPath } from "./toPosixPath";
import { Context } from "./Context";
import { uniq } from "lodash-es";
import { cloneDeep, isEqual, uniq } from "lodash-es";
import { readFile } from "fs/promises";

/**
Expand Down Expand Up @@ -89,14 +89,18 @@ export async function updateTSConfig(
references.push({ path: relativePath });
}

const compilerOptions = {
...(cloneDeep(input.compilerOptions) ?? {}),
};
delete compilerOptions.outDir;
delete compilerOptions.rootDir;

return {
...input,
extends: getExtends(pathFromPackageToRoot, input.extends),
compilerOptions: {
...(input.compilerOptions ?? {}),
rootDir: "src",
outDir: "out",
},

...(isEqual(compilerOptions, {}) ? {} : { compilerOptions }),

references: references.sort((r1, r2) => r1.path.localeCompare(r2.path)),
include: [
"src/**/*.ts",
Expand Down
2 changes: 0 additions & 2 deletions packages/meta-updater/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "out",
"rootDir": "src",
"target": "es2020",
"module": "ES2020",
"moduleResolution": "node",
Expand Down
4 changes: 0 additions & 4 deletions packages/node-common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "out"
},
"include": ["src/**/*.ts", "src/**/*.json", "../../typings/**/*.d.ts"],
"references": [
{
Expand Down
4 changes: 0 additions & 4 deletions packages/sentence-parser/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "out"
},
"references": [],
"include": ["src/**/*.ts", "src/**/*.json", "../../typings/**/*.d.ts"]
}
4 changes: 0 additions & 4 deletions packages/test-case-recorder/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "out"
},
"include": ["src/**/*.ts", "src/**/*.json", "../../typings/**/*.d.ts"],
"references": [
{
Expand Down
4 changes: 0 additions & 4 deletions packages/test-harness/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "out",
"rootDir": "src"
},
"include": ["src/**/*.ts", "src/**/*.json", "../../typings/**/*.d.ts"],
"references": [
{
Expand Down
4 changes: 1 addition & 3 deletions packages/vscode-common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "es2020",
"outDir": "out",
"rootDir": "src"
"target": "es2020"
},
"include": ["src/**/*.ts", "src/**/*.json", "../../typings/**/*.d.ts"],
"references": [
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"composite": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"strict": true
"strict": true,
"rootDir": "${configDir}/src",
"outDir": "${configDir}/out"
}
}

0 comments on commit 99969ac

Please sign in to comment.