docs/react-v9/contributing/rfcs/shared/build-system/01_convergence_devstack.md
TS Path aliases, collocated storybook
List contributors to the proposal: @hotell, @craig12345, @ling1726, @JustSlone, @dzearing, @layershifter
based on high level repo issues notes,
Current state of development that we wanna improve:
yarn start magically boots server with demos, but dev has no idea where that comes from (devs that worked within this repo for some time may not have such a problem ofc)💡 NOTE: all proposed solutions will be applied only for convergence packages
Current state:
Solution proposal:
path aliases for convergence
Rather then leveraging solutions that might feel appealing (like TS Project refs etc, lerna/yarn workspace symlinks), we can leverage battle tested solution that has been in place for quite some time, thus makes its adoption compatibility with 3rd party tooling straightforward.
Example:
Visualization
Code
// @file /tsconfig.base.json
//
// "root tsconfig" (intentionally not named as tsconfig.json, so editor/IDE will pick only tsconfig.json per package)
{
"extends": "@fluentui/ts-config-common",
"compilerOptions": {
"lib": ["dom", "es2017", "dom.iterable"],
"rootDir": ".",
"baseUrl": ".",
"paths": {
"@fluentui/react-button": ["packages/react-button/src/index.ts"],
"@fluentui/react-hooks": ["packages/react-hooks/src/index.ts"]
// other aliases...
}
}
}
// @file /packages/react-button/tsconfig.json
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"types": ["node", "jest"]
},
"include": ["src"]
}
tsconfig.base.json in place, we can leverage common oss tooling like tsconfig-paths package to leverage path aliases config within all other tools that we (may) use (jest,webpack,rollup,storybook...).Current state:
react-examples packageSolution proposal:
*.stories.* per package/yarn start spins local storybook instance for inner loopPros:
Cons:
devDependencies within its package.json for other packages used within story implementation. This dependency is not needed as it provides no value to consumer. Also TS path aliases will handle this behavior as main source of truth for resolving dep tree in Dev Mode.NONE
<!-- As you enumerate possible solutions, try to keep track of the discarded ones. This should include why we discarded the solution. -->NONE
<!-- Optional section, but useful for first drafts. Use this section to track open issues on unanswered questions regarding the design or proposal. -->