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

[Bug]: .ts source file labels produce invalid predeclared outputs unless they are bare #584

Closed
jbedard opened this issue Apr 11, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@jbedard
Copy link
Member

jbedard commented Apr 11, 2024

What happened?

If labels such as
srcs = ["@//path/to:a.ts", "//path/to:b.ts", ":c.ts", "d.ts"]
are specified in ts_project(srcs) then the pre-declared outputs are invalid, and fail with an error like

invalid label 'generated/:a.js' in element 0 of attribute 'js_outs' in 'ts_project' rule: invalid package name 'generated/': package names may not end with '/'

Version

Development (host) and target OS/architectures:

Output of bazel --version:

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved:

How to reproduce

write_file(
    name = "gen-a.ts",
    out = "a.ts",
    content = [
        "export const a = 42",
    ],
)


ts_project(
    name = "target-refs",
    srcs = [
        ":gen-a.ts",
    ],
    declaration = True,
    out_dir = "target-refs",
    source_map = True,
)

ts_project(
    name = "out-target-refs",
    srcs = [
        ":a.ts",
        ":b.ts",
    ],
    declaration = True,
    out_dir = "out-target-refs",
    source_map = True,
)
@jbedard jbedard added the bug Something isn't working label Apr 11, 2024
@github-actions github-actions bot added the untriaged Requires traige label Apr 11, 2024
@jbedard jbedard removed the untriaged Requires traige label Apr 11, 2024
@jbedard jbedard self-assigned this Apr 11, 2024
jbedard added a commit to jbedard/rules_ts that referenced this issue Apr 11, 2024
@jbedard jbedard changed the title [Bug]: targets specified as ts_project(srcs) cause errors [Bug]: targets with .ts extensions specified as ts_project(srcs) cause errors Apr 11, 2024
@alexeagle alexeagle changed the title [Bug]: targets with .ts extensions specified as ts_project(srcs) cause errors [Bug]: .ts source file labels produce invalid predeclared outputs unless they are bare Apr 11, 2024
@alexeagle
Copy link
Member

The correct answer here has to be to preserve what users understand as Label semantics, which is that

path/to/BUILD.bazel:

srcs = ["@//path/to:a.ts", "//path/to:b.ts", ":c.ts", "d.ts"]
# is the same as
srcs = ["a.ts", "b.ts", "c.ts", "d.ts"]

So we should simply normalize the syntax before computing the out_path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants