Closed AnatoleLucet closed 5 years ago
whars the exception?
You need to reference the @npm//package-name
somewhere in your build (the deps
of your ts_library?) or else the dependencies will never be installed (Bazel only does work required to build the output you request)
@Toxicable edited
Yeah so since you havn't referenced any deps in @npm
bazel dosen't go and resolve it.
If you did declare one, such as @npm//tslib
(you'll need this eventually) in your deps then bazel will go and fetch those deps before running the target
Alright, and how could I declare a dependency ? I need to do something in my "root BUILD
", right ?
ts_library(
name = "app1",
srcs = glob(["index.ts"]),
deps = [
"@npm//tslib"
]
)
@Toxicable oh ok, I was asking because I've already done that and it still doesn't work
I've also added tslib
in my package.json
I have the same list of errors except tslib
has added himself to it :
missing input file '@npm//:node_modules/tslib/tslib.d.ts'
I'll make a repo, it will be easier
Ok well now it works after doing the same in a new folder.
I guess this is because I've manually deleted my node_modules
folder for cleaning it.
Is there a good way to clean node_modules
?
@AnatoleLucet You shouldn't really ever have to clean your node_modules if you change your package.json bazel will reinstall the modules itself.
But as a last resort bazel clean --expunge
will remove the node_modules that are sitting in bazels working dir
@Toxicable That is true. Well thanks you for your really fast answer (@alexeagle included) !
🐞 bug report
Affected Rule
The issue is caused by the rule:
yarn_install
ts_library
Description
A
bazel build //myApp
does not install my npm's dependencies whenmyApp
contain ats_library
rule.This part of the doc advise to install deps with
bazel run @nodejs//:yarn
. But is there a way to automatically install deps when trying to build the app ?I gess there is a way (or I am probably missing something) because dataform's config automatically do it (acording to their doc).
🔬 Minimal Reproduction
WORKSPACE
:BUILD
:package.json
:myApp/BUILD
:myApp/index.ts
:But it works (it install my deps) when
myApp
simply has anodejs_binary
rule and ajs
file.myApp/build
:🔥 Exception or Error
Just a bunch of
missing input file '@npm//:node_modules/typescript/lib/x'
for basically every files that he need in thetypescript
module.🌍 Your Environment
Operating System:
Linux Mint 19.2
Output of
bazel version
:Rules version (SHA):