microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.92k stars 595 forks source link

[heft] [rig] project field in typescript.json not working. #2908

Open ApolloTang opened 3 years ago

ApolloTang commented 3 years ago

Summary

According to https://github.com/microsoft/rushstack/issues/2258#issuecomment-895595035

Added "project" option in typescript.json with identical semantics to the tsc --project parameter

However, when a heft project is rigged, in rig's configuration, it is unclear which tscconfig.json the configuration is read from, and the result is in effect that the typescript task being disabled as described in https://github.com/microsoft/rushstack/issues/2258#issuecomment-895595035:

Using the "project" option in typescript.json introduced in #2844, you can set it to a non-existent file and that will disable the plugin execution.

Repro steps

Set up a rigged heft project and specify a custom tsconfig.json in the project field. See example repo:

https://github.com/ApolloTang/study--rush--node-app/blob/main/02b-node-apps-w-rig--typescript-json-project/tools/heft-node-rig/profiles/default/config/typescript.json#L15

Expected result:

Expect the specified tsconfig.json to be adopted and the typescript task run.

Actual result:

Typescript task is disabled

Details

Detailed discussion in zulip:

https://rushstack.zulipchat.com/#narrow/stream/262522-heft/topic/.E2.9C.94.20.5Brig.5D.20file.20path.20for.20project.20field.20in.20typescript.2Ejson

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@rushstack/heft version? 0.37.0
Operating system? Mac
Would you consider contributing a PR? Not right now
Node.js version (node -v)? v14.17.3
ApolloTang commented 3 years ago

https://github.com/ApolloTang/study--rush--node-app/blob/main/02d-node-apps-w-rig--turn-on-buildProjectReferences/tools/heft-node-rig/profiles/default/config/typescript.json#L20

Above is my attempt setting the flag:

"buildProjectReferences": true,

as seen in: https://github.com/microsoft/rushstack/blob/master/build-tests/heft-typescript-composite-test/config/typescript.json#L15

But to no avail :(

iclanton commented 3 years ago

There may be an option missing here. By default, this should resolve relative to the root of the project being built (see here).

I'll mess around with your repro.

iclanton commented 3 years ago

So what's happening is the "project" field in typescript.json resolves relative to the project root, so it's looking for a file under /apps/app--node-1/tsconfig.heft.json. If you change the "project" field's value to "node_modules/@myscope/heft-node-rig/profiles/default/config/tsconfig.heft.json", you'll get your expected behavior.

I guess this begs the question: what is the expected behavior here? Would a different resolution be more intuitive? @octogonz @dmichon-msft, thoughts on this?