From 5448b33eb01dc334bf3a1beeada77d47902683fb Mon Sep 17 00:00:00 2001 From: Mofei Zhang Date: Wed, 16 Aug 2023 15:38:30 -0400 Subject: [PATCH] [yarn workspaces] Add typescript dependencies to tsconfig --- Previously, I used `yarn workspace build fixture-test-utils` and `yarn workspace build babel-plugin-react-forget` to recompile dependencies on sprout. However, tsc supports project references which was intended to solve this problem https://www.typescriptlang.org/docs/handbook/project-references.html Note that apparently this places `.tsbuildinfo` in package roots, according to https://github.com/microsoft/TypeScript/issues/30925 --- .../babel-plugin-react-forget/tsconfig.json | 6 +++++- .../packages/fixture-test-utils/tsconfig.json | 6 +++++- compiler/forget/packages/snap/package.json | 2 +- compiler/forget/packages/snap/tsconfig.json | 10 +++++++++- compiler/forget/packages/sprout/package.json | 3 ++- compiler/forget/packages/sprout/tsconfig.json | 15 ++++++++++----- 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/compiler/forget/packages/babel-plugin-react-forget/tsconfig.json b/compiler/forget/packages/babel-plugin-react-forget/tsconfig.json index 4420706d67..d2f01fb8d6 100644 --- a/compiler/forget/packages/babel-plugin-react-forget/tsconfig.json +++ b/compiler/forget/packages/babel-plugin-react-forget/tsconfig.json @@ -2,7 +2,10 @@ "extends": "@tsconfig/node16-strictest/tsconfig.json", "compilerOptions": { "declaration": true, + "rootDir": "src", "outDir": "dist", + // https://github.com/microsoft/TypeScript/issues/30925 + "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo", "jsx": "react-jsxdev", // weaken strictness from preset @@ -13,7 +16,8 @@ "target": "ES2015", // ideally turn off only during dev, or on a per-file basis "noUnusedLocals": false, - "sourceMap": true + "sourceMap": true, + "composite": true }, "exclude": ["node_modules"], "include": ["src/**/*.ts"] diff --git a/compiler/forget/packages/fixture-test-utils/tsconfig.json b/compiler/forget/packages/fixture-test-utils/tsconfig.json index 4420706d67..d2f01fb8d6 100644 --- a/compiler/forget/packages/fixture-test-utils/tsconfig.json +++ b/compiler/forget/packages/fixture-test-utils/tsconfig.json @@ -2,7 +2,10 @@ "extends": "@tsconfig/node16-strictest/tsconfig.json", "compilerOptions": { "declaration": true, + "rootDir": "src", "outDir": "dist", + // https://github.com/microsoft/TypeScript/issues/30925 + "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo", "jsx": "react-jsxdev", // weaken strictness from preset @@ -13,7 +16,8 @@ "target": "ES2015", // ideally turn off only during dev, or on a per-file basis "noUnusedLocals": false, - "sourceMap": true + "sourceMap": true, + "composite": true }, "exclude": ["node_modules"], "include": ["src/**/*.ts"] diff --git a/compiler/forget/packages/snap/package.json b/compiler/forget/packages/snap/package.json index c86bfd3b6b..2ec242d1a9 100644 --- a/compiler/forget/packages/snap/package.json +++ b/compiler/forget/packages/snap/package.json @@ -9,7 +9,7 @@ "src" ], "scripts": { - "build": "yarn workspace fixture-test-utils run build && rimraf dist && tsc", + "build": "rimraf dist && tsc --build", "test": "echo 'no tests'", "lint": "yarn eslint src" }, diff --git a/compiler/forget/packages/snap/tsconfig.json b/compiler/forget/packages/snap/tsconfig.json index 4420706d67..a5262f1880 100644 --- a/compiler/forget/packages/snap/tsconfig.json +++ b/compiler/forget/packages/snap/tsconfig.json @@ -16,5 +16,13 @@ "sourceMap": true }, "exclude": ["node_modules"], - "include": ["src/**/*.ts"] + "include": ["src/**/*.ts"], + "references": [ + { + "path": "../fixture-test-utils" + }, + { + "path": "../babel-plugin-react-forget" + } + ] } diff --git a/compiler/forget/packages/sprout/package.json b/compiler/forget/packages/sprout/package.json index 86da534090..c7dce7393c 100644 --- a/compiler/forget/packages/sprout/package.json +++ b/compiler/forget/packages/sprout/package.json @@ -8,7 +8,7 @@ "src" ], "scripts": { - "build": "yarn workspace babel-plugin-react-forget run build && yarn workspace fixture-test-utils run build && rimraf dist && tsc", + "build": "rimraf dist && tsc --build", "prettier": "prettier --write src", "test": "echo 'no tests'" }, @@ -22,6 +22,7 @@ "@babel/types": "^7.19.0", "@parcel/watcher": "^2.1.0", "@testing-library/react": "^13.4.0", + "babel-plugin-react-forget": "*", "chalk": "4", "fixture-test-utils": "*", "jsdom": "^22.1.0", diff --git a/compiler/forget/packages/sprout/tsconfig.json b/compiler/forget/packages/sprout/tsconfig.json index f56e994f09..988ee6fceb 100644 --- a/compiler/forget/packages/sprout/tsconfig.json +++ b/compiler/forget/packages/sprout/tsconfig.json @@ -14,11 +14,16 @@ // ideally turn off only during dev, or on a per-file basis "noUnusedLocals": false, "sourceMap": true, - "baseUrl": ".", - "paths": { - "fixture-test-utils": ["../packages/fixture-test-utils"] - } + "baseUrl": "." }, "exclude": ["node_modules"], - "include": ["src/**/*.ts"] + "include": ["src/**/*.ts"], + "references": [ + { + "path": "../fixture-test-utils" + }, + { + "path": "../babel-plugin-react-forget" + } + ] }