Skip to content

Commit

Permalink
build: fix tsconfig monorepo setup (#10028)
Browse files Browse the repository at this point in the history
Should fix messed up import suggestions and simplifies all tsconfigs
through inheritance.

One main issue was that packages were inheriting `baseURL: "."` from the
root tsconfig. This caused incorrect import suggestions that start with
"packages/...".

This PR ensures that packages do not inherit this baseURL: "." property,
while ensuring the root, non-inherited tsconfig still keeps it to get
tests to work (the importMap needs it)
  • Loading branch information
AlessioGr authored Dec 17, 2024
1 parent 70666a0 commit f5c13de
Show file tree
Hide file tree
Showing 39 changed files with 183 additions and 703 deletions.
9 changes: 1 addition & 8 deletions packages/create-payload-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true, // Make sure typescript knows that this module depends on their references
"noEmit": false /* Do not emit outputs. */,
"emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */,
"strict": true
},
"exclude": ["dist", "build", "tests", "test", "node_modules", "eslint.config.js"],
"include": ["src/**/*.ts", "src/**/*.spec.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"]
}
22 changes: 1 addition & 21 deletions packages/db-mongodb/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true, // Make sure typescript knows that this module depends on their references
"noEmit": false /* Do not emit outputs. */,
"emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */
},
"exclude": [
"dist",
"build",
"tests",
"test",
"node_modules",
"eslint.config.js",
"src/**/*.spec.js",
"src/**/*.spec.jsx",
"src/**/*.spec.ts",
"src/**/*.spec.tsx"
],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
"extends": "../../tsconfig.base.json",
"references": [{ "path": "../payload" }, { "path": "../translations" }]
}
29 changes: 1 addition & 28 deletions packages/db-postgres/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
// Make sure typescript knows that this module depends on their references
"composite": true,
/* Do not emit outputs. */
"noEmit": false,
"emitDeclarationOnly": true,
/* Specify an output folder for all emitted files. */
"outDir": "./dist",
/* Specify the root folder within your source files. */
"rootDir": "./src"
},
"exclude": [
"dist",
"build",
"tests",
"test",
"node_modules",
"eslint.config.js",
"src/**/*.spec.js",
"src/**/*.spec.jsx",
"src/**/*.spec.ts",
"src/**/*.spec.tsx"
],
"include": [
"src",
"src/**/*.ts",
],
"extends": "../../tsconfig.base.json",
"references": [
{
"path": "../payload"
Expand Down
29 changes: 1 addition & 28 deletions packages/db-sqlite/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
// Make sure typescript knows that this module depends on their references
"noEmit": false
/* Do not emit outputs. */,
"emitDeclarationOnly": true,
"outDir": "./dist"
/* Specify an output folder for all emitted files. */,
"rootDir": "./src"
/* Specify the root folder within your source files. */
},
"exclude": [
"dist",
"build",
"tests",
"test",
"node_modules",
"eslint.config.js",
"src/**/*.spec.js",
"src/**/*.spec.jsx",
"src/**/*.spec.ts",
"src/**/*.spec.tsx"
],
"include": [
"src",
"src/**/*.ts"
],
"extends": "../../tsconfig.base.json",
"references": [
{
"path": "../payload"
Expand Down
26 changes: 1 addition & 25 deletions packages/db-vercel-postgres/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"noEmit": false,
"emitDeclarationOnly": true,
"outDir": "./dist",
"rootDir": "./src",
"skipLibCheck": true,
},
"exclude": [
"dist",
"build",
"tests",
"test",
"node_modules",
"eslint.config.js",
"src/**/*.spec.js",
"src/**/*.spec.jsx",
"src/**/*.spec.ts",
"src/**/*.spec.tsx"
],
"include": [
"src",
"src/**/*.ts",
],
"extends": "../../tsconfig.base.json",
"references": [
{
"path": "../payload"
Expand Down
26 changes: 1 addition & 25 deletions packages/drizzle/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
// Make sure typescript knows that this module depends on their references
"composite": true,
/* Do not emit outputs. */
"noEmit": false,
"emitDeclarationOnly": true,
/* Specify an output folder for all emitted files. */
"outDir": "./dist",
/* Specify the root folder within your source files. */
"rootDir": "./src"
},
"exclude": [
"dist",
"build",
"tests",
"test",
"node_modules",
"eslint.config.js",
"src/**/*.spec.js",
"src/**/*.spec.jsx",
"src/**/*.spec.ts",
"src/**/*.spec.tsx"
],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
"extends": "../../tsconfig.base.json",
"references": [{ "path": "../payload" }, { "path": "../translations" }]
}
9 changes: 1 addition & 8 deletions packages/email-nodemailer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true, // Make sure typescript knows that this module depends on their references
"noEmit": false /* Do not emit outputs. */,
"emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */,
"strict": true
},
"exclude": ["dist", "node_modules"],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
"references": [{ "path": "../payload" }]
}
9 changes: 1 addition & 8 deletions packages/email-resend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true, // Make sure typescript knows that this module depends on their references
"noEmit": false /* Do not emit outputs. */,
"emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */,
"strict": true
},
"exclude": ["dist", "node_modules", "src/**/*.spec.ts"],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
"references": [{ "path": "../payload" }]
}
22 changes: 1 addition & 21 deletions packages/graphql/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true, // Make sure typescript knows that this module depends on their references
"noEmit": false /* Do not emit outputs. */,
"emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */
},
"exclude": [
"dist",
"build",
"tests",
"test",
"node_modules",
"eslint.config.js",
"src/**/*.spec.js",
"src/**/*.spec.jsx",
"src/**/*.spec.ts",
"src/**/*.spec.tsx"
],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
"extends": "../../tsconfig.base.json",
"references": [{ "path": "../payload" }]
}
23 changes: 1 addition & 22 deletions packages/live-preview-react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true, // Make sure typescript knows that this module depends on their references
"noEmit": false /* Do not emit outputs. */,
"emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */,
"jsx": "react-jsx"
},
"exclude": [
"dist",
"build",
"tests",
"test",
"node_modules",
"eslint.config.js",
"src/**/*.spec.js",
"src/**/*.spec.jsx",
"src/**/*.spec.ts",
"src/**/*.spec.tsx"
],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
"extends": "../../tsconfig.base.json",
"references": [{ "path": "../payload" }]
}
23 changes: 1 addition & 22 deletions packages/live-preview-vue/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true, // Make sure typescript knows that this module depends on their references
"noEmit": false /* Do not emit outputs. */,
"emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */,
"jsx": "react-jsx"
},
"exclude": [
"dist",
"build",
"tests",
"test",
"node_modules",
"eslint.config.js",
"src/**/*.spec.js",
"src/**/*.spec.jsx",
"src/**/*.spec.ts",
"src/**/*.spec.tsx"
],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
"extends": "../../tsconfig.base.json",
"references": [{ "path": "../payload" }] // db-mongodb depends on payload
}
22 changes: 1 addition & 21 deletions packages/live-preview/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true, // Make sure typescript knows that this module depends on their references
"noEmit": false /* Do not emit outputs. */,
"emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */
},
"exclude": [
"dist",
"build",
"tests",
"test",
"node_modules",
"eslint.config.js",
"src/**/*.spec.js",
"src/**/*.spec.jsx",
"src/**/*.spec.ts",
"src/**/*.spec.tsx"
],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
"extends": "../../tsconfig.base.json",
"references": [{ "path": "../payload" }]
}
13 changes: 0 additions & 13 deletions packages/next/tsconfig.cjs.json

This file was deleted.

22 changes: 1 addition & 21 deletions packages/next/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true, // Required for references to work
"noEmit": false /* Do not emit outputs. */,
"emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */,
"sourceMap": true
},
"exclude": [
"src/**/*.spec.js",
"src/**/*.spec.jsx",
"src/**/*.spec.ts",
"src/**/*.spec.tsx",
"src/**/*.json"
],
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/withPayload.js" /* Include the withPayload.js file in the build */
, "../ui/src/utilities/renderFields.tsx" ],
"extends": "../../tsconfig.base.json",
"references": [
{ "path": "../payload" },
{ "path": "../ui" },
Expand Down
11 changes: 1 addition & 10 deletions packages/payload-cloud/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true, // Make sure typescript knows that this module depends on their references
"noEmit": false /* Do not emit outputs. */,
"emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */
},
"exclude": ["dist", "build", "tests", "test", "node_modules", "eslint.config.js"],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
"extends": "../../tsconfig.base.json",
"references": [{ "path": "../payload" }]
}
Loading

0 comments on commit f5c13de

Please sign in to comment.