# WORKSPACE
yarn_install(
# Name this npm so that Bazel Label references look like @npm//package
name = "npm_shared",
package_json = "//shared:package.json",
yarn_lock = "//shared:yarn.lock",
)
# customize yarn_install names for each package
yarn_install(
# Name this npm so that Bazel Label references look like @npm//package
name = "npm_server_api",
package_json = "//server/api:package.json",
yarn_lock = "//server/api:yarn.lock",
)
-
There might be a way using
ts_project
, but it seems that it needspackage.json
containing all dependencies of packages in root directory (See https://github.com/dataform-co/dataform). -
So this example used
ts_library
as imported package. -
IMPORTANT You should write
package_name
attribute with the same package name inpackage.json
, aspackage_name = "shared"
in this example.
Importing package should add imported package as {workspace_name}/{package_name}
in package.json
dependency
In this example, server/api
package imported shared
as below in package.json
"dependency": {
...,
"bazel_nestjs_with_shared/shared": "file:../../shared",
...
}
See server/api/src/BUILD.bazel.
You can import in both ways as //shared
or //shared:shared
.
Should use ts_config
function in BUILD.bazel
to use NestJS's tsconfig extending feature - tsconfig.build.json
-> tsconfig.json
- See ts_config and import as :tsconfig