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

docs(typescript): add host configuration to rootDirs #2401

Merged
merged 1 commit into from
Jan 18, 2021

Conversation

dgp1130
Copy link
Contributor

@dgp1130 dgp1130 commented Jan 14, 2021

A host root directory is necessary for TypeScript to resolve imports for a tool executed at build time with cfg = "host".

This is necessary for:

some_rule = rule(
    implementation = _some_rule_impl,
    attrs = {
        "_binary": attr.label({
            default: "//some/nodejs_binary/tool/built/with/ts_project",
            executable: True,
            cfg = "host",
        }),
    },
)

Because Bazel will build the tool in the host configuration, meaning generated *.js files will be dropped into bazel-out/host/bin/..., and tsc needs to know to look for dependent ts_project() outputs in that directory.

Arguably a similar change is also necessary for cfg = "exec", however files would be in bazel-out/k8-opt-exec-*/bin, which can't be easily hard-coded in a tsconfig, so that's a problem to be tackled separately.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Documentation content changes

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

While not a breaking change, many users are likely to have copy-pasted this content from the docs and will not easily discover this information or update their tsconfig.json file. This could add additional confusion due to a difference between new projects which copy-paste this content, and old projects which already did.

A `host` root directory is necessary for TypeScript to resolve imports for a tool executed at build time with `cfg = "host"`.

Arguably a similar change is also necessary for `cfg = "exec"`, however files would be in `bazel-out/k8-opt-exec-*/bin`, which can't be easily hard-coded in a tsconfig, so that's a problem to be tackled separately.
@mattem
Copy link
Collaborator

mattem commented Jan 18, 2021

Thanks, I think it's okay to point users to updated docs as an issue is discovered

@mattem mattem merged commit 1dda0af into bazel-contrib:stable Jan 18, 2021
@dgp1130 dgp1130 deleted the patch-1 branch May 7, 2022 05:38
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 this pull request may close these issues.

2 participants