Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples provided do not work out of the box (config files missing) #2359

Closed
tomasdev opened this issue Dec 22, 2020 · 4 comments
Closed

Examples provided do not work out of the box (config files missing) #2359

tomasdev opened this issue Dec 22, 2020 · 4 comments

Comments

@tomasdev
Copy link

🔬 Minimal Reproduction

Run the following:

git clone [email protected]:bazelbuild/rules_nodejs.git
cd rules_nodejs/examples/app
npm install
npm install --save-dev @bazel/bazel # only required if you don't have bazel globally
npx bazel build :prodserver # or `bazel build :prodserver` if you have it globally

🔥 Exception or Error


ERROR: /Users/tomas/WORK/rules_nodejs/examples/app/BUILD.bazel:22:1: every rule of type rollup_bundle implicitly depends upon the target '@npm//@bazel/rollup:rollup.config.js', but this target could not be found because of: no such target '@npm//@bazel/rollup:rollup.config.js': target 'rollup.config.js' not declared in package '@bazel/rollup'; however, a source file of this name exists.  (Perhaps add 'exports_files(["rollup.config.js"])' to @bazel/rollup/BUILD?) defined by /private/var/tmp/_bazel_tomas/9cd5c7a033e236bbd0e2adab9e32ef7a/external/npm/@bazel/rollup/BUILD.bazel
Documentation for implicit attribute config_file of rules of type rollup_bundle:
A `rollup.config.js` file

Passed to the `--config` option, see [the config doc](https://rollupjs.org/guide/en/#configuration-files)

If not set, a default basic Rollup config is used.
ERROR: /Users/tomas/WORK/rules_nodejs/examples/app/BUILD.bazel:28:1: 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 /private/var/tmp/_bazel_tomas/9cd5c7a033e236bbd0e2adab9e32ef7a/external/npm/@bazel/terser/BUILD.bazel
Documentation for implicit attribute config_file of rules of type terser_minified:
A JSON file containing Terser minify() options.

This is the file you would pass to the --config-file argument in terser's CLI.
https://github.com/terser-js/terser#minify-options documents the content of the file.

Bazel will make a copy of your config file, treating it as a template.

Run bazel with `--subcommands` to see the path to the copied file.

If you use the magic strings `"bazel_debug"` or `"bazel_no_debug"`, these will be
replaced with `true` and `false` respecting the value of the `debug` attribute
or the `--compilation_mode=dbg` bazel flag.

For example

```
{
    "compress": {
        "arrows": "bazel_no_debug"
    }
}
```

Will disable the `arrows` compression setting when debugging.

If `config_file` isn't supplied, Bazel will use a default config file.
ERROR: Analysis of target '//:prodserver' failed; build aborted: Analysis failed

🌍 Your Environment

Operating System:

  
Mac OS X Big Sur 11.0.1 (20B29)
  

Output of bazel version:

  
Build label: 2.1.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Feb 7 13:04:00 2020 (1581080640)
Build timestamp: 1581080640
Build timestamp as int: 1581080640
  

Rules_nodejs version:

  
http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "b3521b29c7cb0c47a1a735cce7e7e811a4f80d8e3720cf3a1b624533e4bb7cb6",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/2.3.2/rules_nodejs-2.3.2.tar.gz"],
)
  

Anything else relevant?

Am I doing something wrong perhaps?

@tomasdev
Copy link
Author

Perhaps related to bazelbuild/bazel#2835 ?

@tomasdev
Copy link
Author

May have been introduced by #2193 ?

@tomasdev
Copy link
Author

tomasdev commented Dec 22, 2020

Trying out v3.0.0 rc-1 throws

ERROR: error loading package '': in /private/var/tmp/_bazel_tomas/3532d3aa619a717cd847371d067034d5/external/npm/@bazel/concatjs/index.bzl: in /private/var/tmp/_bazel_tomas/3532d3aa619a717cd847371d067034d5/external/npm/@bazel/concatjs/web_test/karma_web_test.bzl: Unable to find package for @io_bazel_rules_webtesting//web:web.bzl: The repository '@io_bazel_rules_webtesting' could not be resolved.

Edit: The error above is fixed by adding to WORKSPACE:

http_archive(
    name = "io_bazel_rules_webtesting",
    sha256 = "9bb461d5ef08e850025480bab185fd269242d4e533bca75bfb748001ceb343c3",
    urls = ["https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.3/rules_webtesting.tar.gz"],
)

But then that gets you this error:

ERROR: error loading package '': in /private/var/tmp/_bazel_tomas/3532d3aa619a717cd847371d067034d5/external/npm/@bazel/concatjs/index.bzl: in /private/var/tmp/_bazel_tomas/3532d3aa619a717cd847371d067034d5/external/npm/@bazel/concatjs/web_test/karma_web_test.bzl: in /private/var/tmp/_bazel_tomas/3532d3aa619a717cd847371d067034d5/external/io_bazel_rules_webtesting/web/web.bzl: in /private/var/tmp/_bazel_tomas/3532d3aa619a717cd847371d067034d5/external/io_bazel_rules_webtesting/web/internal/custom_browser.bzl: Unable to find package for @bazel_skylib//lib:dicts.bzl: The repository '@bazel_skylib' could not be resolved.

Edit 2: which was fixed by also adding to WORKSPACE:

load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
web_test_repositories()

Then tsconfig blew up and had to add the following to my main BUILD.bazel

exports_files(
  ["tsconfig.json"],
  visibility = ["//visibility:public"],
)

@tomasdev
Copy link
Author

The issue does simply not happen on v3.0.0-rc.1, so closing.

I was able to run the example with these:

git clone [email protected]:bazelbuild/rules_nodejs.git
git checkout 3.x
yarn add -D @bazel/bazelisk @bazel/ibazel                         
node_modules/@bazel/ibazel/bin/darwin_amd64/ibazel run :prodserver # didnt find a better way to execute the local ibazel lol but it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant