Okay, thanks for the tips. And yeah, I already updated the "node_repositories" list in the WORKSPACE.
I am now currently porting onos to rules_nodejs 2.3.1 on x64 (because i thought it would be easier to patch on x64 and then port to arm64). Currently I am using bazel 4.0.0.rc6 and onos 2.5.0, but from my experience bazel 3.0.0 and rules_nodejs 2.0.0 showed the same behaviour here.
It seems like my changes are working mostly, I just got some small problems left where I don't know how to solve them (this is the first time for me working with bazel / angular). It would be nice if you could help me with those, I appended patches below so you can try it yourself. Also it seems like the build would work if I could build without the GUI. Is it possible to build without it? My target systen is an embedded system, so i dont need a GUI.
These were my steps:
I changed the WORKSPACE, web/gui2/package.json, .bazelversion and .bazelrc for the new versions.
Changes as decribed here:
https://github.com/bazelbuild/rules_nodejs/wiki#migrating-load-statements-from-npm_bazel_-to-npmbazelhttps://github.com/bazelbuild/rules_nodejs/wiki#ivyThe latter failed on the web/gui2/src/main/webapp/BUILD.bazel file due to a missing asset parameter in the ng_module node, I fixed this manually. Also I changed the tools/build/bazel/angular_workspace.bzl because the ts_setup_workspace target is not defined anymore in the new version.
The last step was to change multiple load statements because those would not find the files, e.g. from "@npm_angular_bazel//:" to "@npm//@angular/bazel:". This can be done with "find . -type f -exec sed -i 's,@npm_\(.*\)_\(.*\)//:,@npm//@\1/\2:,g' {} +".
You can recreate these steps by applying onos.patch to the onos root. I also appended a zip file with a Dockerfile if you want to try it out instead of directly patching.
When I build this, i get two errors in the cache:
- ERROR: /home/user/onos/web/gui2/src/main/webapp/BUILD.bazel:66:16: every rule of type terser_minified implicitly depends upon the target '@npm//@bazel/terser:terser_config.default.json', but this target could not be found because of: no such target '@npm//@bazel/terser:terser_config.default.json': target 'terser_config.default.json' not declared in package '@bazel/terser'; however, a source file of this name exists. (Perhaps add 'exports_files(["terser_config.default.json"])' to @bazel/terser/BUILD?) defined by /home/user/.cache/bazel/_bazel_user/c42cbfd2cdf6b9981f69ddf5581a02a8/external/npm/@bazel/terser/BUILD.bazel
- ERROR: /home/user/onos/web/gui2/src/main/webapp/app/BUILD.bazel:27:1: error loading package 'web/gui2-fw-lib': in /home/user/.cache/bazel/_bazel_user/c42cbfd2cdf6b9981f69ddf5581a02a8/external/npm/@angular/bazel/index.bzl: Label '@npm//src:ng_module.bzl' is invalid because 'src' is not a package; perhaps you meant to put the colon here: '@npm//:src/ng_module.bzl'? and referenced by '//web/gui2/src/main/webapp/app:app'
The first one is easily solvable by adding the suggestion. The second error (and multiple others with the same underlying problem) are also solvable by changing the load statements. You can apply both fixes by applying cache.patch to the cache. But it seems like those errors would vanish if bazel would use a new version of those packages, but i don't know how to do this. After patching i get another error:
- ERROR: /home/user/onos/web/gui2-fw-lib/BUILD.bazel:31:11: //web/gui2-fw-lib:gui2-fw-lib: no such attribute 'entry_point' in 'ts_library' rule
This is due to migrating from angulars ng_module to the equivalent ts_library (because ng_module is deprecated, as mentioned in one of the links above). I guess ts_library does not have the entrypoint used here.
So, to summarize: Can you either help me with those problems or tell me how to build without the GUI?
Thank you and have a nice weekend,
Dominik