I am trying to add path aliases through .swcrc by specifying paths
Here is my .swcrc
{
"jsc": {
"parser": {
"syntax": "typescript"
},
"target": "es2021",
"baseUrl": ".",
"paths": {
"@connectors/*": ["./src/connectors/*"],
"@operations/*": ["./src/operations/*"]
}
},
"module": {
"type": "commonjs"
}
}
When paths are specified and I attempt to use the path-alias for an import, the build is successful but I get the following runtime error
Error: Cannot find module '../../../../../../../../../../.cache/bazel/_bazel_victor/b76e982e01c6243367a3fb2de72a73de/execroot/[redacted]/bazel-out/k8-fastbuild/bin/backend/packages/grpc-error/index'
grpc-error is one of our other packages built with the bazel js-library rule.
It seems like "paths" is actually working, because it allows me to use the path-aliases, the build doesn't crash. However the resulting import path isn't valid, the file doesn't exist, and I am guessing there is some bazel magic I don't understand going on in the background. The resulting import path when paths is not specified and I don't attempt to use the path-alias looks like this @[package-name]/grpc-error, which is the name of the library.
To summarize
//.swcrc
{
...
"paths": {
"@connectors/*": ["./src/connectors/*"],
"@operations/*": ["./src/operations/*"]
}
...
}
results in
var _grpcError = require("../../../../../../../../../../.cache/bazel/_bazel_victor/b76e982e01c6243367a3fb2de72a73de/execroot/energy_services/bazel-out/k8-fastbuild/bin/backend/packages/grpc-error/index");
and a run-time error
and
// .swcrc
{
...
// "paths": {
// "@connectors/*": ["./src/connectors/*"],
// "@operations/*": ["./src/operations/*"]
// }
...
}
results in
var _grpcError = require("@ingka/grpc-error");
I am trying to add path aliases through .swcrc by specifying paths
Here is my .swcrc
When paths are specified and I attempt to use the path-alias for an import, the build is successful but I get the following runtime error
grpc-erroris one of our other packages built with the bazel js-library rule.It seems like "paths" is actually working, because it allows me to use the path-aliases, the build doesn't crash. However the resulting import path isn't valid, the file doesn't exist, and I am guessing there is some bazel magic I don't understand going on in the background. The resulting import path when
pathsis not specified and I don't attempt to use the path-alias looks like this@[package-name]/grpc-error, which is the name of the library.To summarize
results in
and a run-time error
and
results in