question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript 3.6 Incremental and Build API Support

See original GitHub issue

Feature 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

  1. 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.
  2. 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’s node_modules (via Lerna or Yarn Workspaces).
  3. Worst case scenario is to run tsc --build --watch and next 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 in node_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:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
jeremy-colemancommented, Jan 2, 2020

im fairly certain they dont intend to properly support typescript. your 2 best options are to:

  1. precompile, for example, src transpile to-> app -> ‘(cli) next app’
  2. move your ts files to a workspace package and import the transpiled stuff as single components into pages (so your next project is mostly empty). - this is best imo, but can cause links to become unclickable in your terminal, which is a terrible dev experience
0reactions
balazsorban44commented, Jan 29, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript 3.6 Incremental and Build API Support · Issue #8708
Worst case scenario is to run tsc --build --watch and next in parallel, but this will build Next.js project twice and cause other...
Read more >
Documentation - TypeScript 3.6
APIs to Support --build and --incremental​​ TypeScript 3.0 introduced support for referencing other and building them incrementally using the --build flag. ...
Read more >
Announcing TypeScript 3.6 - Microsoft Developer Blogs
APIs to Support --build and --incremental​​ TypeScript 3.0 introduced support for referencing other projects and building them incrementally ...
Read more >
TypeScript 3.6 Introduces Stricter Generators & Better Promise ...
TypeScript 3.6 now provides two sets of APIs to operate on project references and incremental program building. As detailed by Rosenwasser:.
Read more >
How can I use --incremental from TypeScript compiler API?
It seems the decision on which program to use is made at a high level based on the compiler options. Sometimes people may...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found