Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts_project does not pick up referenced project's parent tsconfig #1754

Closed
kwonoj opened this issue Mar 29, 2020 · 4 comments · Fixed by #1756
Closed

ts_project does not pick up referenced project's parent tsconfig #1754

kwonoj opened this issue Mar 29, 2020 · 4 comments · Fixed by #1756
Labels

Comments

@kwonoj
Copy link
Contributor

kwonoj commented Mar 29, 2020

🐞 bug report

Affected Rule

The issue is caused by the rule: `ts_project`

Is this a regression?

Yes, the previous version in which this bug was not present was: ....

Description

A clear and concise description of the problem...

let's assume project layout like below

- tsconfig.json
\ src
   - tsconfig.esm.json
   \ common
     - BUILD
 	 - tsconfig.json  
     - tsconfig.bzl.json 
   \ preload
     - BUILD
     - tsconfig,json
     - tsconfig.bzl.json

tsconfig.json under each package extends \\:tsconfig.json, \\src:tsconfig.esm.json. tsconfig.bzl.json is the actual config being used in ts_project, extends each :tsconfig.json.

when \\src\preload:tsconfig.bzl have reference to \\src:common, ts_project deps will pick up direct reference, \\src\common:tsconfig.bzl.json and does not pick up its extend \\src\common:tsconfig.json, in result compilation error occurs by missing some of config flags specified in parent config only.

🔬 Minimal Reproduction

🔥 Exception or Error





##[error]src/preload/tsconfig.bzl.json(4,5): error TS6306: Referenced project '/home/runner/.cache/bazel/_bazel_runner/effb5996f4ecc130424f20eff3118d8b/sandbox/linux-sandbox/4/execroot/test/src/common/tsconfig.bzl.json' must have setting "composite": true.

🌍 Your Environment

Operating System:

  

  

Output of bazel version:

  

  

Rules_nodejs version:

(Please check that you have matching versions between WORKSPACE file and @bazel/* npm packages.)

  

  

Anything else relevant?

@kwonoj
Copy link
Contributor Author

kwonoj commented Mar 29, 2020

I think this is more for the question how to configure ts_project to pick up all configs correctly rather than bug report.

@alexeagle
Copy link
Collaborator

  1. (not directly related) it's too bad you need a tsconfig.bzl.json next to each tsconfig.json. I see this is for the outDir workaround to make non-sandboxed execution work. Do you really need .tmp/out to be the default (non-bazel) outDir? If you just choose the same outDir all the time then maybe you can eliminate the need for tsconfig.bzl.json which will simplify the config and less likely to have it misconfigured

  2. To diagnose the problem let's see what are the inputs to src/preload:tsconfig.bzl target

bazel aquery src/preload:tsconfig.bzl

Okay that has a lot of output, let's just find the *.json inputs

$ bazel aquery src/preload:tsconfig.bzl | grep Inputs | tr ',' '\n' | grep .json | grep -v node_modules
 bazel-out/darwin-fastbuild/bin/src/preload/_tsconfig.bzl.module_mappings.json
 src/common/tsconfig.bzl.json
 src/preload/tsconfig.bzl.json
 src/preload/tsconfig.json
 src/tsconfig.esm.json
 tsconfig.json

This is missing src/common/tsconfig.json which is needed here to fully resolve the configuration of the src/common dependency so I think this actually is a bug.

@alexeagle
Copy link
Collaborator

Yup, trivial fix to include the extended tsconfigs in the set we pass down to dependencies in the _TsConfigInfo provider: https://github.com/kwonoj/ts_project_composite_test/pull/2

Will fix in rules_nodejs for next patch release.

alexeagle added a commit to alexeagle/rules_nodejs that referenced this issue Mar 29, 2020
Allows ts_project to work with extra tsconfig indirections

Fixes bazel-contrib#1754
alexeagle added a commit that referenced this issue Mar 29, 2020
Allows ts_project to work with extra tsconfig indirections

Fixes #1754
@kwonoj
Copy link
Contributor Author

kwonoj commented Mar 29, 2020

Do you really need .tmp/out to be the default (non-bazel) outDir? If you just choose the same outDir all the time then maybe you can eliminate the need for tsconfig.bzl.json which will simplify the config and less likely to have it misconfigured

though in actual repo it have same outdir layout, this repo's tsconfig is simplified omits some of differences between 2 configs.

This is missing src/common/tsconfig.json which is needed here to fully resolve the configuration of the src/common dependency so I think this actually is a bug.

yes, that's how I could make this repro, I think I should've include aquery output in issue.

Thanks for help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants