-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Reusing tsconfig file across components #17983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b56dfd9
4d5da1e
f670a93
f93d835
24d3b9b
7e8c32b
b614484
c3ba89c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,3 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": [ | ||
"es2020" | ||
], | ||
"module": "ES2020", | ||
"target": "ES2020", | ||
"moduleResolution": "node", | ||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||
"composite": true, | ||
"outDir": "dist", | ||
"allowSyntheticDefaultImports": true, | ||
}, | ||
"allowJs": true, | ||
"include": [ | ||
"app", | ||
"actions", | ||
"sources" | ||
], | ||
"exclude": [ | ||
"dist", | ||
] | ||
"extends": "../../tsconfig.components.json" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2020"], | ||
"module": "ES2020", | ||
"target": "ES2020", | ||
"moduleResolution": "node", | ||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||
"composite": true, | ||
"outDir": "dist", | ||
"allowSyntheticDefaultImports": true, | ||
}, | ||
"allowJs": true, | ||
"include": [ | ||
"app", | ||
"actions", | ||
"sources", | ||
"common", | ||
], | ||
"exclude": [ | ||
"dist", | ||
] | ||
} | ||
"extends": "../../tsconfig.components.json" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,3 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": [ | ||
"es2020" | ||
], | ||
"module": "ES2020", | ||
"target": "ES2020", | ||
"moduleResolution": "node", | ||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||
"composite": true, | ||
"outDir": "dist", | ||
"allowSyntheticDefaultImports": true, | ||
}, | ||
"allowJs": true, | ||
"include": [ | ||
"app", | ||
"actions", | ||
"sources", | ||
"common" | ||
], | ||
"exclude": [ | ||
"dist", | ||
] | ||
"extends": "../../tsconfig.components.json" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,3 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2020"], | ||
"module": "ES2020", | ||
"target": "ES2020", | ||
"moduleResolution": "node", | ||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||
"composite": true, | ||
"outDir": "dist", | ||
"allowSyntheticDefaultImports": true, | ||
}, | ||
"allowJs": true, | ||
"include": [ | ||
"app", | ||
"actions", | ||
"sources" | ||
], | ||
"exclude": [ | ||
"dist", | ||
] | ||
} | ||
"extends": "../../tsconfig.components.json" | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2020"], | ||
"module": "ES2020", | ||
"target": "ES2020", | ||
"moduleResolution": "node", | ||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||
"composite": true, | ||
"outDir": "dist", | ||
"allowSyntheticDefaultImports": true, | ||
}, | ||
"allowJs": true, | ||
"include": [ | ||
"app", | ||
"actions", | ||
"sources", | ||
"common" | ||
], | ||
"exclude": [ | ||
"dist", | ||
] | ||
"extends": "../../tsconfig.components.json" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2020"], | ||
"module": "ES2020", | ||
"target": "ES2020", | ||
"moduleResolution": "node", | ||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||
"composite": true, | ||
"outDir": "dist", | ||
"allowSyntheticDefaultImports": true, | ||
}, | ||
"allowJs": true, | ||
"include": [ | ||
"app", | ||
"actions", | ||
"sources", | ||
"common" | ||
], | ||
"exclude": [ | ||
"dist", | ||
] | ||
"extends": "../../tsconfig.components.json" | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,24 +1,3 @@ | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
"compilerOptions": { | ||||||||||||||||||||||||||||||||||||||
"lib": [ | ||||||||||||||||||||||||||||||||||||||
"es2020" | ||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||
"module": "ES2020", | ||||||||||||||||||||||||||||||||||||||
"target": "ES2020", | ||||||||||||||||||||||||||||||||||||||
"moduleResolution": "node", | ||||||||||||||||||||||||||||||||||||||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||||||||||||||||||||||||||||||||||||||
"composite": true, | ||||||||||||||||||||||||||||||||||||||
"outDir": "dist", | ||||||||||||||||||||||||||||||||||||||
"allowSyntheticDefaultImports": true, | ||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||
"allowJs": true, | ||||||||||||||||||||||||||||||||||||||
"include": [ | ||||||||||||||||||||||||||||||||||||||
"app", | ||||||||||||||||||||||||||||||||||||||
"actions", | ||||||||||||||||||||||||||||||||||||||
"sources", | ||||||||||||||||||||||||||||||||||||||
"common" | ||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||
"exclude": [ | ||||||||||||||||||||||||||||||||||||||
"dist", | ||||||||||||||||||||||||||||||||||||||
] | ||||||||||||||||||||||||||||||||||||||
"extends": "../../tsconfig.components.json" | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainExtends-only config likely breaks include/exclude and outDir; add local overrides Per our prior learning: include/exclude are resolved relative to the config that defines them. Centralizing these in a base config won’t work for per-component directories, and relative compilerOptions like outDir in the base will also resolve relative to the base file, causing outputs to collide (e.g., emitting to a single top-level dist). Action:
Apply something like this: {
- "extends": "../../tsconfig.components.json"
+ "extends": "../../tsconfig.components.json",
+ "compilerOptions": {
+ // Ensure emitted JS and build info live under this component
+ "outDir": "./dist"
+ },
+ // These must be relative to THIS tsconfig, not the base
+ "include": [
+ "app/**/*.ts",
+ "actions/**/*.ts",
+ "sources/**/*.ts",
+ "common/**/*.ts"
+ ],
+ "exclude": [
+ "dist"
+ ]
} Run to confirm the base config won’t work as-is and that this file lacks local overrides: 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Base config (should exist at repo root):"
if [[ -f "tsconfig.components.json" ]]; then
jq '{include, exclude, compilerOptions: {outDir}}' tsconfig.components.json
else
echo "Missing tsconfig.components.json at repo root"
fi
echo
echo "Check for unsupported variable tokens in base (e.g., \${configDir}):"
rg -n --fixed-strings '${configDir}' tsconfig.components.json || echo "No \${configDir} tokens found."
echo
echo "This component's tsconfig (should have local include/exclude/outDir overrides):"
jq '{extends, include, exclude, compilerOptions: {outDir}}' components/cloudmersive/tsconfig.json || true
echo
echo "Sanity: verify base outDir is not causing cross-component collisions:"
jq -r '.compilerOptions.outDir // "<none>"' tsconfig.components.json
echo
echo "If base includes/excludes are present, remember they are resolved RELATIVE TO THE BASE file."
echo "Each component should define its own include/exclude and outDir." Length of output: 406 I need to re‐inspect both the base and component tsconfig files with corrected jq syntax. Running: 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Base config (tsconfig.components.json) keys:"
if [[ -f tsconfig.components.json ]]; then
jq '{include: .include, exclude: .exclude, outDir: .compilerOptions.outDir}' tsconfig.components.json
else
echo "tsconfig.components.json not found"
fi
echo
echo "Component config (components/cloudmersive/tsconfig.json) keys:"
if [[ -f components/cloudmersive/tsconfig.json ]]; then
jq '{extends: .extends, include: .include, exclude: .exclude, outDir: .compilerOptions.outDir}' components/cloudmersive/tsconfig.json
else
echo "components/cloudmersive/tsconfig.json not found"
fi Length of output: 898 Add local include/exclude and outDir overrides in components/cloudmersive/tsconfig.json TypeScript resolves • File needing changes: components/cloudmersive/tsconfig.json Recommended patch: {
"extends": "../../tsconfig.components.json",
+ "compilerOptions": {
+ // Emit JS/build info under this component
+ "outDir": "./dist"
+ },
+ // Paths are relative to this file
+ "include": [
+ "app/**/*.ts",
+ "actions/**/*.ts",
+ "sources/**/*.ts",
+ "common/**/*.ts"
+ ],
+ "exclude": [
+ "dist"
+ ]
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,23 +1,3 @@ | ||||||||||||||||
{ | ||||||||||||||||
"compilerOptions": { | ||||||||||||||||
"lib": [ | ||||||||||||||||
"es2020" | ||||||||||||||||
], | ||||||||||||||||
"module": "ES2020", | ||||||||||||||||
"target": "ES2020", | ||||||||||||||||
"moduleResolution": "node", | ||||||||||||||||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||||||||||||||||
"composite": true, | ||||||||||||||||
"outDir": "dist", | ||||||||||||||||
"allowSyntheticDefaultImports": true, | ||||||||||||||||
}, | ||||||||||||||||
"allowJs": true, | ||||||||||||||||
"include": [ | ||||||||||||||||
"app", | ||||||||||||||||
"actions", | ||||||||||||||||
"sources" | ||||||||||||||||
], | ||||||||||||||||
"exclude": [ | ||||||||||||||||
"dist", | ||||||||||||||||
] | ||||||||||||||||
"extends": "../../tsconfig.components.json" | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Localize path-based settings. Add local include/exclude/outDir to prevent cross-component compilation and output collisions. {
"extends": "../../tsconfig.components.json",
+ "compilerOptions": { "outDir": "./dist" },
+ "include": ["app", "actions", "sources"],
+ "exclude": ["dist"]
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2020"], | ||
"module": "ES2020", | ||
"target": "ES2020", | ||
"moduleResolution": "node", | ||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||
"composite": true, | ||
"outDir": "dist", | ||
"allowSyntheticDefaultImports": true, | ||
}, | ||
"allowJs": true, | ||
"include": [ | ||
"app", | ||
"actions", | ||
"sources", | ||
"common" | ||
], | ||
"exclude": [ | ||
"dist", | ||
] | ||
} | ||
"extends": "../../tsconfig.components.json" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2020"], | ||
"module": "ES2020", | ||
"target": "ES2020", | ||
"moduleResolution": "node", | ||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||
"composite": true, | ||
"outDir": "dist", | ||
"allowSyntheticDefaultImports": true, | ||
}, | ||
"allowJs": true, | ||
"include": [ | ||
"app", | ||
"actions", | ||
"sources", | ||
"common" | ||
], | ||
"exclude": [ | ||
"dist", | ||
] | ||
} | ||
"extends": "../../tsconfig.components.json" | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,24 +1,3 @@ | ||||||||||||||||
{ | ||||||||||||||||
"compilerOptions": { | ||||||||||||||||
"lib": [ | ||||||||||||||||
"es2020" | ||||||||||||||||
], | ||||||||||||||||
"module": "ES2020", | ||||||||||||||||
"target": "ES2020", | ||||||||||||||||
"moduleResolution": "node", | ||||||||||||||||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||||||||||||||||
"composite": true, | ||||||||||||||||
"outDir": "dist", | ||||||||||||||||
"allowSyntheticDefaultImports": true, | ||||||||||||||||
}, | ||||||||||||||||
"allowJs": true, | ||||||||||||||||
"include": [ | ||||||||||||||||
"app", | ||||||||||||||||
"actions", | ||||||||||||||||
"sources", | ||||||||||||||||
"common" | ||||||||||||||||
], | ||||||||||||||||
"exclude": [ | ||||||||||||||||
"dist", | ||||||||||||||||
] | ||||||||||||||||
"extends": "../../tsconfig.components.json" | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-add per-component include/exclude/outDir; verify allowJs if JS sources exist. Centralizing these in the base won’t resolve relative to this directory and may emit to a global dist. Restore them locally. Patch: {
- "extends": "../../tsconfig.components.json"
+ "extends": "../../tsconfig.components.json",
+ "compilerOptions": { "outDir": "./dist" },
+ "include": ["app", "actions", "sources", "common"],
+ "exclude": ["dist"]
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2020"], | ||
"module": "ES2020", | ||
"target": "ES2020", | ||
"moduleResolution": "node", | ||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||
"composite": true, | ||
"outDir": "dist", | ||
"allowSyntheticDefaultImports": true, | ||
}, | ||
"allowJs": true, | ||
"include": [ | ||
"app", | ||
"actions", | ||
"sources", | ||
"common" | ||
], | ||
"exclude": [ | ||
"dist", | ||
] | ||
} | ||
"extends": "../../tsconfig.components.json" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,3 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2020"], | ||
"module": "ES2020", | ||
"target": "ES2020", | ||
"moduleResolution": "node", | ||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||
"composite": true, | ||
"outDir": "dist", | ||
"allowSyntheticDefaultImports": true, | ||
}, | ||
"allowJs": true, | ||
"include": [ | ||
"app", | ||
"sources", | ||
"common" | ||
], | ||
"exclude": [ | ||
"dist", | ||
] | ||
} | ||
"extends": "../../tsconfig.components.json" | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,22 +1,3 @@ | ||||||||||||||||||
{ | ||||||||||||||||||
"compilerOptions": { | ||||||||||||||||||
"lib": ["es2020"], | ||||||||||||||||||
"module": "ES2020", | ||||||||||||||||||
"target": "ES2020", | ||||||||||||||||||
"moduleResolution": "node", | ||||||||||||||||||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||||||||||||||||||
"composite": true, | ||||||||||||||||||
"outDir": "dist", | ||||||||||||||||||
"allowSyntheticDefaultImports": true, | ||||||||||||||||||
}, | ||||||||||||||||||
"allowJs": true, | ||||||||||||||||||
"include": [ | ||||||||||||||||||
"app", | ||||||||||||||||||
"actions", | ||||||||||||||||||
"sources", | ||||||||||||||||||
"common" | ||||||||||||||||||
], | ||||||||||||||||||
"exclude": [ | ||||||||||||||||||
"dist", | ||||||||||||||||||
] | ||||||||||||||||||
} | ||||||||||||||||||
"extends": "../../tsconfig.components.json" | ||||||||||||||||||
} | ||||||||||||||||||
Comment on lines
+2
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep shared compilerOptions in the base, but define include/exclude/outDir locally. "../../tsconfig.components.json" path looks right, but per-component paths must remain here to avoid empty builds or a shared root/dist. Patch: {
- "extends": "../../tsconfig.components.json"
+ "extends": "../../tsconfig.components.json",
+ "compilerOptions": { "outDir": "./dist" },
+ "include": ["app", "actions", "sources", "common"],
+ "exclude": ["dist"]
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,3 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": [ | ||
"es2020" | ||
], | ||
"module": "ES2020", | ||
"target": "ES2020", | ||
"moduleResolution": "node", | ||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||
"composite": true, | ||
"outDir": "dist", | ||
"allowSyntheticDefaultImports": true, | ||
}, | ||
"allowJs": true, | ||
"include": [ | ||
"app", | ||
"actions", | ||
"sources" | ||
], | ||
"exclude": [ | ||
"dist", | ||
] | ||
"extends": "../../tsconfig.components.json" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,3 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2020"], | ||
"module": "ES2020", | ||
"target": "ES2020", | ||
"moduleResolution": "node", | ||
"listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script | ||
"composite": true, | ||
"outDir": "dist", | ||
"allowSyntheticDefaultImports": true, | ||
"skipLibCheck": true, | ||
}, | ||
"allowJs": true, | ||
"include": [ | ||
"app", | ||
"actions", | ||
"sources", | ||
"common" | ||
], | ||
"exclude": [ | ||
"dist", | ||
] | ||
} | ||
"extends": "../../tsconfig.components.json" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Centralizing include/exclude in the base tsconfig breaks per-component boundaries
In TypeScript, include/exclude and other path-based options are resolved relative to the config file that defines them. If the root tsconfig.components.json defines include/exclude (and/or outDir), those paths are resolved relative to the root, not this component directory. This typically results in compiling the wrong files, compiling nothing, or emitting to an unexpected output directory.
Action:
Example patch (adjust folders to what actually exists in this component):
Also, if the base config uses placeholders like ${configDir}, note that native tsconfig doesn't support variable interpolation—those paths will not resolve as intended.
Run this script to verify the base config and identify component tsconfigs missing local include/exclude:
🏁 Script executed:
Length of output: 65729
Require per-component include/exclude and outDir in tsconfig.json
The base
tsconfig.components.json
currently declaresbut:
${…}
variables intsconfig.json
.include
/exclude
paths are always resolved relative to the file that defines them, so putting them in the root config means every component will try to compile against the monorepo root—not its own./app
,./actions
, etc.Our audit shows every component under
components/
(e.g.beehiiv
,expensify
,mailbluster
, etc.) is missing localinclude
/exclude
keys and anoutDir
override.Action items:
compilerOptions
intsconfig.components.json
, but remove or ignore itsinclude
/exclude
(they won’t work).components/<name>/tsconfig.json
, add component-scoped entries. For example:Apply this pattern across all component directories so each package builds only its own source.
🤖 Prompt for AI Agents