Closed fortuna closed 5 years ago
The next bit of debugging would be to find out what is in there?
$ bazel query --output=build @npm//ShadowsocksConfig
# /home/alexeagle/.cache/bazel/_bazel_alexeagle/06fc29ac6c20b1d31292d0b1d355ba07/external/npm/ShadowsocksConfig/BUILD.bazel:86:1
node_module_library(
name = "ShadowsocksConfig",
srcs = ["@npm//ShadowsocksConfig:ShadowsocksConfig__files"],
deps = ["@npm//ShadowsocksConfig:ShadowsocksConfig__contents", "@npm//base-64:base-64__contents", "@npm//punycode:punycode__contents"],
)
$ bazel query 'deps(@npm//ShadowsocksConfig:ShadowsocksConfig)' | grep \\\.ts
Loading: 0 packages loaded
@npm//:node_modules/ShadowsocksConfig/shadowsocks_config.ts
@npm//:node_modules/ShadowsocksConfig/shadowsocks_config.spec.ts
@npm//:node_modules/ShadowsocksConfig/punycode.d.ts
I think the issue is that ts_library
filters .d.ts
files from the deps to be the dependencies, but this package is "published" with .ts
sources instead. It's atypical for npm packages to publish typescript sources.
I made a little repro with a ts_library named foo. Building with bazel build -s
prints the subcommands including the call to tsc. Looking in dist/bin/foo_es5_tsconfig.json we see
"allowedStrictDeps": [
"external/npm/node_modules/ShadowsocksConfig/punycode.d.ts",
"foo.ts"
],
doesn't think that shadowsocks_config.ts is a valid allowed dependency.
Here is where it's calculated: https://github.com/bazelbuild/rules_typescript/blob/78af714217bd2b844d2f75961263be4a9e39773e/internal/common/compilation.bzl#L299
I think you are right: ShadowsocksConfig was badly configured. I switched to the #master version, which has an main field in package.json and it works.
Thanks for taking a look!
π bug report
Affected Rule
The issue is caused by the rule: ts_library
Is this a regression?
I don't know. I'm just converting my code to Bazel and this error is blocking me from making progress.
Description
I'm getting the error:
However, my rule is already depending on ShadowsocksConfig:
There's no way to depend on
ShadowsocksConfig/shadowsocks_config.ts
directly because it's an external package and there's no rule for it.Notice that ShadowsocksConfig is not an NPM package, but a Github repository. This is how the entry on
package.json
looks like:π¬ Minimal Reproduction
π₯ Exception or Error
π Your Environment
Operating System:
Output of
bazel version
:Rules version (SHA):
Anything else relevant?