rules_nodejs icon indicating copy to clipboard operation
rules_nodejs copied to clipboard

Fixed ts_project json file outpath with root_dir

Open twheys opened this issue 4 years ago • 2 comments

When using the root_dir attr, the paths to json files are not modified from the input file paths in the same fashion that ts files are. I updated the definition of json_outs to use the same logic to produce an out file path that is used with ts files.

PR Checklist

Please check if your PR fulfills the following requirements:

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

PR Type

What kind of change does this PR introduce?

  • [x] Bugfix
  • [ ] Feature (please, look at the "Scope of the project" section in the README.md file)
  • [ ] Code style update (formatting, local variables)
  • [ ] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [ ] CI related changes
  • [ ] Documentation content changes
  • [ ] Other... Please describe:

What is the current behavior?

Currently, when setting the root_dir attr with a ts_project that includes a .json file in the srcs, the output file path is not generated relative to the root dir, as it is for ts and other files.

Issue Number: N/A

What is the new behavior?

This PR fixes the generation of json output file paths to be relative to the root dir using the same logic as used with other file types.

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

Other information

twheys avatar Sep 03 '21 08:09 twheys

To add some clarity as to what exactly this patch fixes:

If I have a ts_project rule like this that uses root_dir, I expect that the output files are written with paths relative to ./server in the local package directory. This is the case with the transpiled js files, but the json output files are being declared as ./server/.../file.json, which results in the build rule failing because the json is output in the local directory. I fixed the declared output file path to match what is actually produced by the rule by using the same path logic that is applied to the transpiled js files.

ts_project(
    name = "server",
    srcs = glob([
            "server/**/*.ts",
            "server/**/*.tsx",
            "server/**/*.json",
    ]),
    tsconfig = ":server/tsconfig.json",
    root_dir = "server",
    ...
)

twheys avatar Sep 03 '21 08:09 twheys

This Pull Request has been automatically marked as stale because it has not had any activity for 6 months. It will be closed if no further activity occurs in 30 days. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

github-actions[bot] avatar Aug 05 '22 03:08 github-actions[bot]

This PR was automatically closed because it went 30 days without any activity since it was labeled "Can Close?"

github-actions[bot] avatar Sep 04 '22 03:09 github-actions[bot]