docs/react-v9/contributing/rfcs/shared/build-system/02-solution-style-ts-configs.md
List contributors to the proposal here: @hotell
💡 NOTE:
This is proposed changed only for vNext and packages that use new DX ( via ts config path aliases)
We successfully migrated vNext packages to new DX (1 stage), which leverages TS path aliases for improved DX and other benefits...
To continue with our journey to improved DX we need to address leaking global types and other related issues (caused by our current tsconfig.json config) for vNext packages.
see Open Issues
target and lib)Using TS solution style config / per environment configuration, for vNext/packages that use new DX.
<package-name>/tsconfig.json - solution config filenx run <project-name>:type-check (already happening for /test), which will type check properly everything in your package.
tsc --buildExample:
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
// by default we gonna use tsc for type checking only
"noEmit": true
//...
},
"include": [],
"files": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
},
{
"path": "./storybook/tsconfig.json"
}
]
}
<package-name>/tsconfig.lib.jsonExample:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"target": "ES2015",
"outDir": "./dist",
// properly scoped globals and environment
"types": [],
// enable transpilation and declaration files generation only for implementation files
"noEmit": false,
"declaration": true
},
"exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.stories.tsx"],
"include": ["**/*.ts", "**/*.tsx"]
}
<package-name>/tsconfig.spec.jsonExample:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"module": "commonjs",
// properly scoped globals and environment - note that extra 'jest'
"types": ["jest", "node"]
},
"include": ["**/*.spec.ts", "**/*.spec.tsx", "**/*.spec.js", "**/*.spec.jsx", "**/*.d.ts"]
}
<package-name>/.storybook/tsconfig.jsonExample:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "",
"checkJs": true
},
"exclude": ["../**/*.spec.ts", "../**/*.spec.js", "../**/*.spec.tsx", "../**/*.spec.jsx"],
"include": [
"../src/**/*",
// this is only to type check SB config files
"./*.js"
]
}
<package-name>/.eslintrc.json{
"extends": ["@fluentui/eslint-plugin/react"],
"parserOptions": {
// this will speed up linting up to 40%
"tsconfigRootDir": "path/to/<package-name>",
// we need to specify our environment configs (will be removed once typescript-eslint properly supports project references)
// tsc program will be created accordingly per environment/scope
"project": [
// includes tsconfig.lib.json and tsconfig.spec.json
"path/to/<package-name>/tsconfig.*?.json",
// includes storybook config
"path/to/<package-name>/.storybook/tsconfig.json"
]
},
"rules": {
// ...
}
}
just-scripts doesn't support TypeScript build mode, so we'll need to provide another solution.
Possible Solutions:
run-command nx executor that will contain all required commandsbuild modebuild task execution with less abstraction