TypeScript 3.6 Incremental and Build API Support
See original GitHub issueFeature request
TS 3.6 officially supports Incremental and Build (aka Project References) APIs: https://devblogs.microsoft.com/typescript/announcing-typescript-3-6/#apis-to-support-build-and-incremental
Is your feature request related to a problem? Please describe.
Support following syntax in tsconfig.json
:
{
"compilerOptions": {
// The usual
rootDir: './src',
paths": {
"my-core-lib": ["../core"]
}
},
"references": [
{"path": "../core"}
]
}
By design the composite
project that resides in ../core
directory will be built before project in cwd
.
Using the above setup user can refer to my-core-lib
by name (instead of relative paths) from main Next.js project.
Describe the solution you’d like
- Ideally, since Next.js now offers first-class support of TS, it can use TSC instead of Babel, but as I see, it can have performance problems as well as backward compatibility issues. And obviously it will require effort.
- Alternatively, as a limited support MVP, we can use new TS APIs to build references only (and watch them too), not the main Next.js project, which still will be built using Bebel. This implies that
my-core-lib
is somehow linked to Next.js project’snode_modules
(via Lerna or Yarn Workspaces). - Worst case scenario is to run
tsc --build --watch
andnext
in parallel, but this will build Next.js project twice and cause other nasty race conditions like failed Next.js build at first when referenced lib is being built (possible solution:tsc --build && (tsc --build --watch & next)
). This also needs links innode_modules
.
Describe alternatives you’ve considered
No clear alternatives since TS Babel preset just removes types and does not do any actual compilation. I only see several workarounds how we can tell Babel to compile things outside of the main project, this config may be auto-generated based on references
.
There’s an issue https://github.com/Microsoft/TypeScript-Babel-Starter/issues/35.
Additional context
None.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (6 by maintainers)
im fairly certain they dont intend to properly support typescript. your 2 best options are to:
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.