Giter Club home page Giter Club logo

bazel-examples's People

Contributors

alexeagle avatar beyondevil avatar bivens-dev avatar dependabot[bot] avatar f0rmiga avatar flolu avatar gregmagolan avatar gzm0 avatar jackvincentnz avatar jarreds avatar jbedard avatar jdcole avatar jessetatasciore avatar jialipassion avatar kormide avatar kourtni avatar kriswuollett avatar pattrickrice avatar renovate[bot] avatar sessfeld avatar sovietaced avatar thesayyn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bazel-examples's Issues

[Help]: following cra example, ibazel does not symlink pnpm store

What happened?

I am trying to reproduce the cra example and having trouble getting the devserver target to work. Wondering if I am maybe missing something.

I get the following error:

Starting js_run_devserver //bullseye/ui:start
Syncing...
38473 files synced in 4483 ms
Running 'node_modules/.bin/react-scripts start' in /var/folders/v3/w2s47mkx50zd7882v0yxqxc40000gq/T/js_run_devserver-Lz1I9J/r9/bullseye/ui


node:internal/modules/cjs/loader:1078
  throw err;
  ^

Error: Cannot find module 'react-dev-utils/crossSpawn'
Require stack:
- /private/var/folders/v3/w2s47mkx50zd7882v0yxqxc40000gq/T/js_run_devserver-Lz1I9J/r9/bullseye/ui/node_modules/react-scripts/bin/react-scripts.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/private/var/folders/v3/w2s47mkx50zd7882v0yxqxc40000gq/T/js_run_devserver-Lz1I9J/r9/bullseye/ui/node_modules/react-scripts/bin/react-scripts.js:18:15)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/private/var/folders/v3/w2s47mkx50zd7882v0yxqxc40000gq/T/js_run_devserver-Lz1I9J/r9/bullseye/ui/node_modules/react-scripts/bin/react-scripts.js'
  ]
}

If I check the /private/var/folders/v3/w2s47mkx50zd7882v0yxqxc40000gq/T/js_run_devserver-SRkmHu/r9/bullseye/ui/node_modules directory, only my direct dependencies are hard-copied in there. They are not symlinks to a pnpm store and there is no pnpm store created in the js_run_devserver directory.

Is there some configuration to get ibazel to create the pnpm store with a node_modules directory that symlinks to it? I've tried this with the same version as in the example (0.16.2) as well as the latest (0.23.7) but get the same result.

Any help would be appreciated!

Version

Development (host) and target OS/architectures:

Output of bazel --version: 6.3.0

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:
rules_js 1.30.0
rules_ts 1.4.5

Language(s) and/or frameworks involved:

How to reproduce

No response

Any other information?

No response

Question: How to add CSS from third party package?

I am currently working on integrating a large Angular project into a Bazel monorepo. The project uses Clarity as a UI framework but I guess my question also applies to other frameworks such as Material. Normally you add the CSS from package @clr/ui to the corresponding angular.json file.

How is it possible to add a CSS file from a thiry party package?

I checked the example of rules_nodejs and they are adding the CSS file by referencing it directly. My current approach is adding the CSS in defs.bzl:

APPLICATION_HTML_ASSETS = ["styles.css", "favicon.ico", "//:node_modules/@clr/ui/clr-ui.min.css"]

But I get the following error:

no such target '//:node_modules/@clr/ui/clr-ui.min.css'

I checked the documentation but I cannot figure out what targets are defined for each dependency declared in package.json

I would be grateful for help and hope it is the right place for this kind of question.

Incorrect @angular/compiler resolution in angular-ngc example

Angular tests run with JIT, not AOT for tests. While writing my own Bazel build for my Angular application, I was using the angular-ngc as an example to setup Karma tests. While the rudimentary tests are passing, the test environment is not correct and the compiler is failing during the execution of the tests.

To be able to reproduce the issue, I have a fork of the repo:
https://github.com/arobinson/bazel-examples-bugs/tree/ngIf_resolution_issue

  1. Just clone that repo (branch is ngIf_resolution_issue)
  2. Run bazel test //packages/lib-a:test

Despite CommonModule being imported in the TestBed.configureTestingModule, it does not resolve the *ngIf in the component template.

The test.log shows the issue:

[32m14 10 2022 15:35:28.298:INFO [Chrome Headless 106.0.5249.119 (Mac OS 10.15.7)]: �[39mConnected on socket RNcGCFV8Uv9h_eg3AAAB with id 45874384
Chrome Headless 106.0.5249.119 (Mac OS 10.15.7): Executed 0 of 2 SUCCESS (0 secs / 0 secs)
�[1A�[2KERROR: 'NG0303: Can't bind to 'ngIf' since it isn't a known property of 'span' (used in the 'LibBComponent' component template).
If the 'ngIf' is an Angular control flow directive, please make sure that either the 'NgIf' directive or the 'CommonModule' is a part of an @NgModule where this component is declared.'
Chrome Headless 106.0.5249.119 (Mac OS 10.15.7): Executed 0 of 2 SUCCESS (0 secs / 0 secs)
ERROR: 'NG0303: Can't bind to 'ngIf' since it isn't a known property of 'span' (used in the 'LibBComponent' component template).
If the 'ngIf' is an Angular control flow directive, please make sure that either the 'NgIf' directive or the 'CommonModule' is a part of an @NgModule where this component is declared.'
�[1A�[2KChrome Headless 106.0.5249.119 (Mac OS 10.15.7): Executed 1 of 2 SUCCESS (0 secs / 0.01 secs)
�[1A�[2KChrome Headless 106.0.5249.119 (Mac OS 10.15.7) LibBComponent should create FAILED
	Should have rendered 1 span: Expected 0 to equal 1.
	    at <Jasmine>
	    at UserContext.<anonymous> (_test_bundle/src/lib/lib-b.component.spec.js:94:73)
	    at _ZoneDelegate.invoke (test_bootstrap.js:290:160)
	    at ProxyZoneSpec.onInvoke (test_bootstrap.js:2467:35)
	    at _ZoneDelegate.invoke (test_bootstrap.js:290:48)
Chrome Headless 106.0.5249.119 (Mac OS 10.15.7): Executed 2 of 2 (1 FAILED) (0 secs / 0.015 secs)
Chrome Headless 106.0.5249.119 (Mac OS 10.15.7) LibBComponent should create FAILED
	Should have rendered 1 span: Expected 0 to equal 1.
	    at <Jasmine>
	    at UserContext.<anonymous> (_test_bundle/src/lib/lib-b.component.spec.js:94:73)
	    at _ZoneDelegate.invoke (test_bootstrap.js:290:160)
	    at ProxyZoneSpec.onInvoke (test_bootstrap.js:2467:35)
	    at _ZoneDelegate.invoke (test_bootstrap.js:290:48)
�[1A�[2KChrome Headless 106.0.5249.119 (Mac OS 10.15.7): Executed 2 of 2 (1 FAILED) (0.001 secs / 0.015 secs)
TOTAL: 1 FAILED, 1 SUCCESS
TOTAL: 1 FAILED, 1 SUCCESS

FYI, if I don't use the Angular linker in the esbuild configuration, the ngIf issue is fixed, but all 3rd party components will blow up in the browser with an error that the JIT compiler is not available.

This is the error if the linker is not run and non-ivy components are loaded within the test:

Error during loading: Uncaught Error: The injectable 'PlatformLocation' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available. The injectable is part of a library that has been partially compiled. However, the Angular Linker has not processed the library such that JIT compilation is used as fallback. Ideally, the library is processed using the Angular Linker to become fully AOT compiled. Alternatively, the JIT compiler should be loaded by bootstrapping using '@angular/platform-browser-dynamic' or '@angular/platform-server', or manually provide the compiler with 'import "@angular/compiler";' before bootstrapping. in http://localhost:9876/base/scripts/chunk-6GLSZBQD.js line 9815

Trying to run ngcc from the esbuild configuration instead of using the linker does not work due to Bazel restrictions on modifying the files in the sandbox:

Error: EPERM: operation not permitted, open '/Users/andrew/.cache/bazel/9c9edec3c6a7af13c9b81813edf110db/execroot/nw-client/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@[email protected]_gehfjlhzwtarjkj6fayghlncvu/node_modules/.ngcc_lock_file'
    at Object.openSync (node:fs:585:3)
    at writeFileSync (node:fs:2170:35)
    at NodeJSFileSystem.writeFile (file:///Users/andrew/.cache/bazel/9c9edec3c6a7af13c9b81813edf110db/execroot/nw-client/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@[email protected]_gehfjlhzwtarjkj6fayghlncvu/node_modules/@angular/compiler-cli/bundles/chunk-TI3THPMZ.js:378:5)
    at LockFileWithChildProcess.write (file:///Users/andrew/.cache/bazel/9c9edec3c6a7af13c9b81813edf110db/execroot/nw-client/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@[email protected]_gehfjlhzwtarjkj6fayghlncvu/node_modules/@angular/compiler-cli/bundles/chunk-DJRTTRF3.js:1721:13)
    at AsyncLocker.create (file:///Users/andrew/.cache/bazel/9c9edec3c6a7af13c9b81813edf110db/execroot/nw-client/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@[email protected]_gehfjlhzwtarjkj6fayghlncvu/node_modules/@angular/compiler-cli/bundles/chunk-DJRTTRF3.js:1673:30)
    at AsyncLocker.lock (file:///Users/andrew/.cache/bazel/9c9edec3c6a7af13c9b81813edf110db/execroot/nw-client/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@[email protected]_gehfjlhzwtarjkj6fayghlncvu/node_modules/@angular/compiler-cli/bundles/chunk-DJRTTRF3.js:1662:16)
    at ClusterExecutor.execute (file:///Users/andrew/.cache/bazel/9c9edec3c6a7af13c9b81813edf110db/execroot/nw-client/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@[email protected]_gehfjlhzwtarjkj6fayghlncvu/node_modules/@angular/compiler-cli/bundles/chunk-DJRTTRF3.js:1557:26)
    at mainNgcc (file:///Users/andrew/.cache/bazel/9c9edec3c6a7af13c9b81813edf110db/execroot/nw-client/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@[email protected]_gehfjlhzwtarjkj6fayghlncvu/node_modules/@angular/compiler-cli/bundles/chunk-DJRTTRF3.js:2105:19)
    at file:///Users/andrew/.cache/bazel/9c9edec3c6a7af13c9b81813edf110db/execroot/nw-client/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@[email protected]_gehfjlhzwtarjkj6fayghlncvu/node_modules/@angular/compiler-cli/bundles/ngcc/main-ngcc.js:31:11
    at file:///Users/andrew/.cache/bazel/9c9edec3c6a7af13c9b81813edf110db/execroot/nw-client/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@[email protected]_gehfjlhzwtarjkj6fayghlncvu/node_modules/@angular/compiler-cli/bundles/ngcc/main-ngcc.js:41:3

Vue example production build is broken

Building the :build target of the vue example creates a broken bundle. The RouterView does not show up, and clicking on the About link throws this error:

Uncaught (in promise) TypeError: instance is null
    unmountComponent http://localhost:3000/assets/index.5eeda642.js:4425
    unmount http://localhost:3000/assets/index.5eeda642.js:4350
    unmountChildren http://localhost:3000/assets/index.5eeda642.js:4455
    unmount http://localhost:3000/assets/index.5eeda642.js:4362
    unmountComponent http://localhost:3000/assets/index.5eeda642.js:4435
    unmount http://localhost:3000/assets/index.5eeda642.js:4350
    unmountChildren http://localhost:3000/assets/index.5eeda642.js:4455
    unmount http://localhost:3000/assets/index.5eeda642.js:4362
    unmountComponent http://localhost:3000/assets/index.5eeda642.js:4435
    unmount http://localhost:3000/assets/index.5eeda642.js:4350
    patch http://localhost:3000/assets/index.5eeda642.js:3583
    componentUpdateFn http://localhost:3000/assets/index.5eeda642.js:4063
    run http://localhost:3000/assets/index.5eeda642.js:317
    update http://localhost:3000/assets/index.5eeda642.js:4098
    callWithErrorHandling$1 http://localhost:3000/assets/index.5eeda642.js:1217
    flushJobs$1 http://localhost:3000/assets/index.5eeda642.js:1408

My static server is routing "Not Found" pages to index so its not the server configuration breaking Vue Router.

If I build the bundle with --mode development the browser will print several warnings like this:

[Vue warn]: Invalid VNode type: Symbol("Text") (symbol) 
  at <HelloWorld msg="Built with Bazel!" > 
  at <App>

which seem to mean that Vue is getting loaded twice somehow.

The warning will show up as long as I am using a sub component.

If I use the dev server via bazel run :vite, everything works, and if I build the bundle with npx vite build outside of bazel it also works.

How do I get Vue and vite building a bundle in bazel?

NextJs monorepo: Error: > Couldn't find a `pages` directory. Please create one under the project root

Newbie here, was trying to find a nextjs bazel example and found this. Kudos to your team!

I'm currently playing around with the NextJs example. However I want to set my project up as a monorepo, so that I can have multiple Nextjs applications.

My project dir is set up as such

node_modules/
.npmrc
.swcrc
BUILD.bazel
WORKSPACE.bazel
pnpm-lock.yaml
tsconfig.json
web/
  ecommerce/
    pages/
    public/
    styles/
    BUILD.bazel
    next-env.d.ts
    next.config.js

In my root BAZEL.build:

load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")

npm_link_all_packages(name = "node_modules")

copy_to_bin(
    name = "swcrc",
    srcs = [".swcrc"],
    visibility = ["//visibility:public"],
)

ts_config(
    name = "tsconfig",
    src = "tsconfig.json",
    visibility = ["//visibility:public"],
)

In my ecommerce BAZEL.build:

load("@npm//:next/package_json.bzl", next_bin = "bin")
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_run_binary", "js_test")

# Source files passed to Next.js targets
filegroup(
    name = "srcs",
    srcs = [
        "//web/ecommerce/pages",
        "//web/ecommerce/public",
        "//web/ecommerce/styles",
    ],
)

# Config files passed to Next.js targets
filegroup(
    name = "config",
    srcs = [
        "next.config.js",
    ],
    visibility = ["//visibility:public"],
)

# `next dev` runs the application in development mode
# https://nextjs.org/docs/api-reference/cli#development
next_bin.next_binary(
    name = "dev",
    args = ["dev"],
    data = [
        ":config",
        "//:node_modules",
        ":srcs",
    ],
    # TODO: Next.js isn't able to detect when to pick update changes
    # when watching the runfiles. This prevents it from rebuilding & refreshing
    # when running under ibazel with `ibazel_notify_changes`
    # tags = ["ibazel_notify_changes"],
)

When I run bazel run //web/ecommerce:dev, it outputs this error:

❯ bazel run //web/ecommerce:dev
INFO: Analyzed target //web/ecommerce:dev (1 packages loaded, 5 targets configured).
INFO: Found 1 target...
Target //web/ecommerce:dev up-to-date:
  bazel-bin/web/ecommerce/dev.sh
INFO: Elapsed time: 0.248s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
Error: > Couldn't find a `pages` directory. Please create one under the project root
    at Object.findPagesDir (/home/jaskerv/.cache/bazel/_bazel_jaskerv/bd4b097237f91e06ed79cb1df45916f2/execroot/monorepo/bazel-out/k8-fastbuild/bin/web/ecommerce/dev.sh.runfiles/monorepo/node_modules/.aspect_rules_js/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/lib/find-pages-dir.js:42:19)
    at new DevServer (/home/jaskerv/.cache/bazel/_bazel_jaskerv/bd4b097237f91e06ed79cb1df45916f2/execroot/monorepo/bazel-out/k8-fastbuild/bin/web/ecommerce/dev.sh.runfiles/monorepo/node_modules/.aspect_rules_js/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/dev/next-dev-server.js:107:66)
    at NextServer.createServer (/home/jaskerv/.cache/bazel/_bazel_jaskerv/bd4b097237f91e06ed79cb1df45916f2/execroot/monorepo/bazel-out/k8-fastbuild/bin/web/ecommerce/dev.sh.runfiles/monorepo/node_modules/.aspect_rules_js/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/next.js:137:20)
    at /home/jaskerv/.cache/bazel/_bazel_jaskerv/bd4b097237f91e06ed79cb1df45916f2/execroot/monorepo/bazel-out/k8-fastbuild/bin/web/ecommerce/dev.sh.runfiles/monorepo/node_modules/.aspect_rules_js/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/next.js:149:42
    at async NextServer.prepare (/home/jaskerv/.cache/bazel/_bazel_jaskerv/bd4b097237f91e06ed79cb1df45916f2/execroot/monorepo/bazel-out/k8-fastbuild/bin/web/ecommerce/dev.sh.runfiles/monorepo/node_modules/.aspect_rules_js/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/next.js:127:24)
    at async /home/jaskerv/.cache/bazel/_bazel_jaskerv/bd4b097237f91e06ed79cb1df45916f2/execroot/monorepo/bazel-out/k8-fastbuild/bin/web/ecommerce/dev.sh.runfiles/monorepo/node_modules/.aspect_rules_js/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/cli/next-dev.js:142:9

I have a few questions around the nextjs example:

  • How would I get around this error? 🙏
  • What is the next_entry.js? Is this something manually defined?
  • How does the copy_to_bin swcrc work? I see it defined but not sure how its used.

Why do you make lib-a and common the way you do?

In angular and angular-ngc, why are lib-a and common made so they can be package dependencies and not created the traditional way in angular I.E. just making a new component and linking it up the the app.module.ts

Sort of a "why make imports instead of declarations" question I guess. I just want to understand why or when I would do something like this and if it's a bazel specific reason or just an angular specific feature I've never bothered to use.

bazelrc: `common --keep_going` breaks `bazel shutdown`

$ bazel shutdown
ERROR: --keep_going :: Unrecognized option: --keep_going

I've expanded it into separate lines for build, fetch, and query like to the --noexperimental_check_output_files, but maybe it applies to other commands as well.

As an aside, the UX around common is really aggravating.

[FR]: vscode cannot find module

What is the current behavior?

I am using vscode for developing a web project based on angular-ngc and getting the following error:
Screenshot_2023-07-21_08-42-37
This affects only first-party packages. Actually the following should make it work:

"paths": {
"@ngc-example/*": ["packages/*"]
}

I am using the same tsc version in the editor as required by package.json.

What I already did:

  • Found this issue and read the referenced documentation
  • Used pnpm install to install all dependencies

I guess this is maybe a pnpm related issue, but I didn't find anything useful. So sorry if it's not directly related to this example.

Describe the feature

Possibly provide documentation about editor support.

[FR]: Example of Angular project with gRPC-web

What is the current behavior?

It's possible to write the app, but I'm not quite sure how.

Describe the feature

An example of an Angular application that communicates with a backend using gRPC-web would be pretty helpful. A teammate of mine or I will probably get to this at some point, but I want to put out the desire for this in advance. Here is what I'm thinking:

I built something like this with rules_nodejs, which I copied from the rules_nodejs examples. I consider the Angular app way more complicated than it needs to be. https://github.com/gonzojive/example-ts-go-grpc-bazel/tree/master/viz/src/app


We are currently using rules_nodejs for an Angular app with gRPC-web. It works but is brittle, and I often run into trouble getting protos to work properly. The tsconfig.json file contains a mess of rootDirs specifying bazel-bin dirs. When tsc fails to resolve an import dependency, its error message doesn't give debug info about what paths were searched to try to satisfy the import. I am hoping rules_js/rules_ts will be better.

I'll look into sponsoring a bounty when I have a chance.

Fund our work

protobufjs example: incompatibility with rules_docker

In the workspace file of the protobufjs example I just added at the bottom:

http_archive(
    name = "io_bazel_rules_docker",
    sha256 = "b1e80761a8a8243d03ebca8845e9cc1ba6c82ce7c5179ce2b295cd36f7e394bf",
    urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.25.0/rules_docker-v0.25.0.tar.gz"],
)

load(
    "@io_bazel_rules_docker//repositories:repositories.bzl",
    container_repositories = "repositories",
)
container_repositories()

load("@io_bazel_rules_docker//repositories:deps.bzl", container_deps = "deps")

container_deps()

load(
    "@io_bazel_rules_docker//container:container.bzl",
    "container_pull",
)

container_pull(
    name = "ubuntu_focal",
    tag = "ubuntu:20.04",
    digest = "sha256:b2339eee806d44d6a8adc0a790f824fb71f03366dd754d400316ae5a7e3ece3e",
    registry = "index.docker.io",
    repository = "library/ubuntu",
)

when I run bazel build @ubuntu_focal//image I get the following love letter:

INFO: Repository bazel_gazelle_go_repository_config instantiated at:
  /home/milan/dev/aspect_bazel_examples/protobufjs/WORKSPACE.bazel:81:15: in <toplevel>
  /home/milan/.cache/bazel/_bazel_milan/b93d749a5afa9d6a20cfa8ddf92dbbb1/external/io_bazel_rules_docker/repositories/deps.bzl:38:12: in deps
  /home/milan/.cache/bazel/_bazel_milan/b93d749a5afa9d6a20cfa8ddf92dbbb1/external/io_bazel_rules_docker/repositories/go_repositories.bzl:41:25: in go_deps
  /home/milan/.cache/bazel/_bazel_milan/b93d749a5afa9d6a20cfa8ddf92dbbb1/external/bazel_gazelle/deps.bzl:77:25: in gazelle_dependencies
Repository rule go_repository_config defined at:
  /home/milan/.cache/bazel/_bazel_milan/b93d749a5afa9d6a20cfa8ddf92dbbb1/external/bazel_gazelle/internal/go_repository_config.bzl:57:39: in <toplevel>
ERROR: An error occurred during the fetch of repository 'bazel_gazelle_go_repository_config':
   Traceback (most recent call last):
	File "/home/milan/.cache/bazel/_bazel_milan/b93d749a5afa9d6a20cfa8ddf92dbbb1/external/bazel_gazelle/internal/go_repository_config.bzl", line 25, column 31, in _go_repository_config_impl
		config_path = ctx.path(ctx.attr.config)
Error in path: Not a regular file: /home/milan/dev/aspect_bazel_examples/protobufjs/WORKSPACE
ERROR: /home/milan/dev/aspect_bazel_examples/protobufjs/WORKSPACE.bazel:81:15: fetching go_repository_config rule //external:bazel_gazelle_go_repository_config: Traceback (most recent call last):
	File "/home/milan/.cache/bazel/_bazel_milan/b93d749a5afa9d6a20cfa8ddf92dbbb1/external/bazel_gazelle/internal/go_repository_config.bzl", line 25, column 31, in _go_repository_config_impl
		config_path = ctx.path(ctx.attr.config)
Error in path: Not a regular file: /home/milan/dev/aspect_bazel_examples/protobufjs/WORKSPACE
ERROR: /home/milan/.cache/bazel/_bazel_milan/b93d749a5afa9d6a20cfa8ddf92dbbb1/external/io_bazel_rules_docker/container/go/cmd/extract_config/BUILD:19:11: no such package '@com_github_google_go_containerregistry//pkg/v1/tarball': no such package '@bazel_gazelle_go_repository_config//': Not a regular file: /home/milan/dev/aspect_bazel_examples/protobufjs/WORKSPACE and referenced by '@io_bazel_rules_docker//container/go/cmd/extract_config:go_default_library'
ERROR: Analysis of target '@ubuntu_focal//image:image' failed; build aborted: 
INFO: Elapsed time: 11.866s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (49 packages loaded, 471 targets configured)
    Fetching @com_github_google_go_containerregistry; Restarting.
    Fetching @com_github_pkg_errors; Restarting.

It may be that gazelle defs inside rules_nodejs and rules_docker clash.

bazel-examples: daf995d
bazel: 5.2.0
os: Ubuntu 20.04

[Bug]: build fail when test file name contains capital letter

What happened?

The build fails when adding a test file with capital letter in the file name. E.g. I added a test file named Other.test.ts under next.js/apps/alpha/pages. The file just contain some dummy test case as below.

// Other.test.ts
import { render, screen } from '@testing-library/react';
import Home from './index';

describe('Other', () => {
    it('should fail', () => {
      expect(true).toBe(true);
    });
  });

When run the bazel build on specs, it runs into the following error.

➜  next.js git:(main) ✗ bazel build //apps/alpha/pages:specs    
INFO: Analyzed target //apps/alpha/pages:specs (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /Users/xzdev/Sandbox/bazel-examples/next.js/apps/alpha/pages/BUILD.bazel:32:11: output 'apps/alpha/pages/Other.test.js' was not created
ERROR: /Users/xzdev/Sandbox/bazel-examples/next.js/apps/alpha/pages/BUILD.bazel:32:11: output 'apps/alpha/pages/Other.test.d.ts' was not created
ERROR: /Users/xzdev/Sandbox/bazel-examples/next.js/apps/alpha/pages/BUILD.bazel:32:11: Transpiling & type-checking TypeScript project @//apps/alpha/pages:specs [tsc -p tsconfig.json] failed: not all outputs were created or valid
Target //apps/alpha/pages:specs failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 2.112s, Critical Path: 1.14s
INFO: 2 processes: 1 internal, 1 worker.
FAILED: Build did NOT complete successfully

Version

Development (host) and target OS/architectures:

Output of bazel --version: aspect 5.3.4

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

http_archive(
    name = "aspect_rules_js",
    sha256 = "dcd1567d4a93a8634ec0b888b371a60b93c18d980f77dace02eb176531a71fcf",
    strip_prefix = "rules_js-1.26.0",
    url = "https://github.com/aspect-build/rules_js/releases/download/v1.26.0/rules_js-v1.26.0.tar.gz",
)

http_archive(
    name = "aspect_rules_ts",
    sha256 = "ace5b609603d9b5b875d56c9c07182357c4ee495030f40dcefb10d443ba8c208",
    strip_prefix = "rules_ts-1.4.0",
    url = "https://github.com/aspect-build/rules_ts/releases/download/v1.4.0/rules_ts-v1.4.0.tar.gz",
)

http_archive(
    name = "aspect_rules_jest",
    sha256 = "52dc08fd252add240124ef7ccc46df3a505121758dfb96578a3d5f2ebb4c2b40",
    strip_prefix = "rules_jest-0.18.1",
    url = "https://github.com/aspect-build/rules_jest/releases/download/v0.18.1/rules_jest-v0.18.1.tar.gz",
)

Language(s) and/or frameworks involved: TypeScript

How to reproduce

Add a dummy test file with capital letter. Make sure the file is also added to the BUILD file `specs` src. Run the bazel build on the specs and the error shows.

Any other information?

No response

[Bug]: oci_python_image broken

What happened?

https://github.com/aspect-build/bazel-examples/tree/main/oci_python_image cannot be built anymore:

bazel build ...
<...>
WARNING: Download from http://security.ubuntu.com/ubuntu/pool/main/libx/libxml2/libxml2_2.9.10+dfsg-5ubuntu0.20.04.6_amd64.deb failed: class java.io.FileNotFoundException GET returned 404 Not Found
<...>

Version

Development (host) and target OS/architectures: Ubuntu 20.04

Output of bazel --version:

cat .bazelversion 
6.2.0

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file: N/A, check the repo

How to reproduce

git clone [email protected]:aspect-build/bazel-examples.git
cd bazel-examples/oci_python_image
bazel buid ...

Any other information?

No response

How do we configure eslint binary for TypeScript projects

I see there are three examples that define eslint_bin.eslint_test targets in this repo, but it is not trivial for me how to define eslint_bin.eslint_binary so that users can run the binary for TypeScript projects, using tsconfig.json and eslint config files that specify the tsconfig.json file in the parserOptions.project. It would be nice to have an example how to set up the eslint binary target.

I've been trying to figure it out by modifying the react-cra example. Below is local changes I have in my machine:

diff --git a/react-cra/.eslintrc.js b/react-cra/.eslintrc.js
new file mode 100644
index 0000000..2ab94f0
--- /dev/null
+++ b/react-cra/.eslintrc.js
@@ -0,0 +1,12 @@
+module.exports = {
+  extends: [
+    "react-app",
+    //"plugin:@typescript-eslint/recommended",
+  ],
+  parser: '@typescript-eslint/parser',
+  parserOptions: {
+    tsconfigRootDir: __dirname,
+    project: ['tsconfig.json'],
+  },
+  root: true,
+};
diff --git a/react-cra/BUILD.bazel b/react-cra/BUILD.bazel
index bd181cc..c6817ac 100644
--- a/react-cra/BUILD.bazel
+++ b/react-cra/BUILD.bazel
@@ -57,3 +57,9 @@ js_library(
     srcs = ["jest.config.js"],
     visibility = ["//visibility:public"],
 )
+
+js_library(
+    name = "eslintrc",
+    srcs = [".eslintrc.js"],
+    visibility = ["//visibility:public"],
+)
diff --git a/react-cra/src/BUILD.bazel b/react-cra/src/BUILD.bazel
index dd1705a..a4a86c9 100644
--- a/react-cra/src/BUILD.bazel
+++ b/react-cra/src/BUILD.bazel
@@ -83,3 +83,20 @@ eslint_bin.eslint_test(
         "//:node_modules/eslint-config-react-app",
     ] + glob(SRC_PATTERNS),
 )
+
+eslint_bin.eslint_binary(
+    name = "eslint_bin",
+    args = [
+        "--config $(location //:eslintrc)",
+        "--no-eslintrc",
+        "--ext .ts,.tsx",
+    ],
+    data = [
+        "//:eslintrc",
+        "//:node_modules/@typescript-eslint/eslint-plugin",
+        "//:node_modules/@typescript-eslint/parser",
+        "//:node_modules/eslint-config-react-app",
+        "//:package_json",
+        "//:tsconfig",
+    ],
+)

Below is the errors when I run the target src:eslint_bin

$ cd react-cra
$ bazel run src:eslint_bin -- $PWD/src
INFO: Analyzed target //src:eslint_bin (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //src:eslint_bin up-to-date:
  bazel-bin/src/eslint_bin.sh
INFO: Elapsed time: 0.111s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Running command line: bazel-bin/src/eslint_bin.sh --config ./.eslintrc.js --no-eslintrc --ext .ts,.tsx /Volumes/work/github/bazel-examples/react-cra/src
INFO: Build completed successfully, 1 total action

/Volumes/work/github/bazel-examples/react-cra/src/App.test.tsx
  0:0  error  Parsing error: ESLint was configured to run on `<tsconfigRootDir>/../../../../../../../../../../../../../Volumes/work/github/bazel-examples/react-cra/src/App.test.tsx` using `parserOptions.project`: <tsconfigRootDir>/tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the TypeScript ESLint docs for more info: https://typescript-eslint.io/docs/linting/troubleshooting##i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file

/Volumes/work/github/bazel-examples/react-cra/src/App.tsx
  0:0  error  Parsing error: ESLint was configured to run on `<tsconfigRootDir>/../../../../../../../../../../../../../Volumes/work/github/bazel-examples/react-cra/src/App.tsx` using `parserOptions.project`: <tsconfigRootDir>/tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the TypeScript ESLint docs for more info: https://typescript-eslint.io/docs/linting/troubleshooting##i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file

/Volumes/work/github/bazel-examples/react-cra/src/custom.d.ts
  0:0  error  Parsing error: ESLint was configured to run on `<tsconfigRootDir>/../../../../../../../../../../../../../Volumes/work/github/bazel-examples/react-cra/src/custom.d.ts` using `parserOptions.project`: <tsconfigRootDir>/tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the TypeScript ESLint docs for more info: https://typescript-eslint.io/docs/linting/troubleshooting##i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file

/Volumes/work/github/bazel-examples/react-cra/src/index.tsx
  0:0  error  Parsing error: ESLint was configured to run on `<tsconfigRootDir>/../../../../../../../../../../../../../Volumes/work/github/bazel-examples/react-cra/src/index.tsx` using `parserOptions.project`: <tsconfigRootDir>/tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the TypeScript ESLint docs for more info: https://typescript-eslint.io/docs/linting/troubleshooting##i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file

/Volumes/work/github/bazel-examples/react-cra/src/reportWebVitals.ts
  0:0  error  Parsing error: ESLint was configured to run on `<tsconfigRootDir>/../../../../../../../../../../../../../Volumes/work/github/bazel-examples/react-cra/src/reportWebVitals.ts` using `parserOptions.project`: <tsconfigRootDir>/tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the TypeScript ESLint docs for more info: https://typescript-eslint.io/docs/linting/troubleshooting##i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file

✖ 5 problems (5 errors, 0 warnings)

[FR]: React Native monorepo

What is the current behavior?

Create a React Native monorepo with two packages:

  • components package
  • application using components package

Describe the feature

Mobile development every year is more important and React Native is the top framework (along with Flutter).

It's different from web, because there's Android and iOS configurations.

Get inspiration from

Fund our work

[Bug]: react-cra example uses version of aspect_rules_ts that doesn't properly support JavaScript

What happened?

This issue was discussed in this thread in the bazel slack.

What happened:
I added a JavaScript file (MyModule.js) to the src folder of the react-cra project. But when I tried to run the dev server I got the following error:
Module not found: Error: Can't resolve './MyModule' in '/tmp/js_run_devserver-TQkUmw/__main__/src'

This was because the JavaScript file was never copied over to the output directory.

What I expected:
The JavaScript file would have been included in the output directory.

Note:
Updating the aspect_rules_ts in the WORKSPACE file to version 1.4.5. Allowed the project to build correctly with JavaScript files in the src folder.

Version

Development (host) and target OS/architectures: WSL2

Output of bazel --version: bazel 6.1.2

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:
aspect_rules_ts version 1.4.0

Language(s) and/or frameworks involved:
JavaScript & TypeScript

How to reproduce

I have tested this by simply cloning and running the example at https://github.com/aspect-build/bazel-examples/tree/main/react-cra.
Then I:
1. added a JavaScript file (MyModule.js) to the src directory
2. referenced it from App.tsx
3. updated SRC_PATTERNS to include *.js and .jsx
4. updated the ts_project rule with allow_js = True
5. updated compilerOptions of  the tsconfig.json file to add "allowJs": true
6. ran yarn start

Any other information?

No response

[Bug]: Windows 10 Angular ngc problem

What happened?

I was looking at this repo https://github.com/jbedard/bazel-examples/tree/angular-ngc (forked from aspect-build/bazel-examples) and decided to try out the angular-ngc example.

After cloning the repo and using the angular-ngc branch, I ran:
bazel build //... -enable_runfiles

and got the following output:
INFO: Build option --enable_runfiles has changed, discarding analysis cache. INFO: Analyzed 66 targets (31 packages loaded, 2387 targets configured). INFO: Found 66 targets... ERROR: C:/users/kayla/documents/angular/bazel-examples/angular-ngc/tools/BUILD.bazel:12:11: TsValidateOptions tools/_validate_ngc.esbuild_options.optionsvalid.d.ts failed: (Exit 1): validator.bat failed: error executing command bazel-out\x64_windows-opt-exec-2B5CBBC6\bin\external\npm_typescript\validator.bat tsconfig.node.json tools/_validate_ngc.esbuild_options.optionsvalid.d.ts //tools:ngc.esbuild ... (remaining 1 argument skipped) FATAL: aspect_rules_js[js_binary]: node wrapper '/c/Users/Kayla/AppData/Roaming/SPB_Data/_bazel_Kayla/t5plpeen/execroot/__main__/bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/npm_typescript/validator.bat.runfiles/__main__/../npm_typescript/validator_node_wrapper/node.bat' is not executable INFO: Elapsed time: 25.804s, Critical Path: 6.93s INFO: 276 processes: 199 internal, 77 local. FAILED: Build did NOT complete successfully

When using MacOS, bazel build //... runs with no issues and the Build is successful. On the other hand, when I try it out on Windows 10 with the 'enable_runfiles' flag, it outputs the above error (the 'enable_runfiles' flag is needed on Windows machines to provide support for rules_js). I'm thinking the error is Windows specific then?

Version

Development (host) and target OS/architectures: Windows 10

Output of bazel --version: bazel 5.3.0

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file: NA

Language(s) and/or frameworks involved: NA

How to reproduce

git clone https://github.com/jbedard/bazel-examples.git

Under angular-ngc branch do the following:
cd bazel-examples/angular-ngc
bazel build //... --enable_runfiles

Any other information?

No response

Fund our work

  • Sponsor our open source work by donating a bug bounty

Add sass example in next.js

What is the current behavior?

The next.js example project demonstrate how to setup a project with a lib and some typescript but styling is only done with css while next.js allows to work easily with Sass.

Describe the feature

Add a .scss file in the styles directory and show how to build it. Would be nice to have support for sass dependencies.

Fund our work

[Bug]: next.js example does not build with `output: "standalone"` next config

What happened?

Add output: "standalone" to next.config.js and the example fails to build:

$ bazel build --verbose_failures //apps/alpha:next
INFO: Analyzed target //apps/alpha:next (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /home/kris/code/aspect-build/bazel-examples/next.js/apps/alpha/BUILD.bazel:18:5: Error while validating output TreeArtifact File:[[<execution_root>]bazel-out/k8-fastbuild/bin]apps/alpha/.next : Failed to resolve relative path standalone/node_modules/is-even inside TreeArtifact /home/kris/.cache/bazel/_bazel_kris/60e9427b29ba5979b62f0f83ca479b34/execroot/__main__/bazel-out/k8-fastbuild/bin/apps/alpha/.next. The associated file is either missing or is an invalid symlink.
ERROR: /home/kris/code/aspect-build/bazel-examples/next.js/apps/alpha/BUILD.bazel:18:5: JsRunBinary apps/alpha/.next failed: not all outputs were created or valid
Target //apps/alpha:next failed to build
INFO: Elapsed time: 14.605s, Critical Path: 14.42s
INFO: 2 processes: 1 internal, 1 linux-sandbox.
FAILED: Build did NOT complete successfully

Version

Development (host) and target OS/architectures:

Output of bazel --version: aspect 5.2.1

Language(s) and/or frameworks involved:

How to reproduce

git clone https://github.com/aspect-build/bazel-examples.git
cd bazel-examples
git checkout f2eb047cfe2a15898a3ade2e0d9b64c26b43efa4
patch -p1 << 'EOF'
diff --git a/next.js/apps/alpha/next.config.js b/next.js/apps/alpha/next.config.js
index b5a1626..9d3da5b 100644
--- a/next.js/apps/alpha/next.config.js
+++ b/next.js/apps/alpha/next.config.js
@@ -1,5 +1,6 @@
 /** @type {import('next').NextConfig} */
 const nextConfig = {
+  output: "standalone",
   reactStrictMode: true,
   swcMinify: true,
   // https://nextjs.org/docs/messages/export-image-api
EOF
cd next.js
pnpm install
bazel build --verbose_failures //apps/alpha:next

Any other information?

Context is trying to make the output shape match up so I could reproduce the NextJS with-docker example through container_image using tar files from genrules like:

genrule(
    name = "next_static",
    srcs = [
        ":next",
    ],
    outs = [
        "static.tar",
    ],
    cmd = "tar -C $(location :next) --transform 's#^./static#app/.next/static#' -chf $@ ./static",
)

Fund our work

  • Sponsor our open source work by donating a bug bounty

[FR]: Add an example that skips `node-gyp` installs

What is the current behavior?

Post install hooks can fail with pnpm. One that I ran into was

❯ bazel test //bazel/release/internal/pusher:test
INFO: Invocation ID: f430ce78-99c5-461c-84f5-b135bd3fc6e5
INFO: Analyzed target //bazel/release/internal/pusher:test (2296 packages loaded, 35938 targets configured).
INFO: Found 1 test target...
ERROR: /Users/davidaghassi/robinhood/rh_other_alt/bazel/release/internal/pusher/BUILD.bazel:9:22: Running lifecycle hooks on npm package [email protected] failed: (Exit 1): lifecycle-hooks.sh failed: error executing command (from target //bazel/release/internal/pusher:.aspect_rules_js/node_modules/[email protected]/lc) bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh cpu-features ../../../external/pusher_pnpm_deps__cpu-features__0.0.4/package ... (remaining 1 argument skipped)
/private/var/tmp/_bazel_davidaghassi/299af5c32fa95b8ba15b1237ac8646db/execroot/rh/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/node-gyp-bin/node-gyp: line 5: 1211: command not found

> [email protected] install /private/var/tmp/_bazel_davidaghassi/299af5c32fa95b8ba15b1237ac8646db/execroot/rh/bazel-out/darwin_arm64-fastbuild/bin/bazel/release/internal/pusher/node_modules/.aspect_rules_js/[email protected]/node_modules/cpu-features
> node buildcheck.js > buildcheck.gypi && node-gyp rebuild

===============================================================
Failure while running lifecycle hook for package '[email protected]':

  Script:  'install'
  Command: `node buildcheck.js > buildcheck.gypi && node-gyp rebuild`

Stack trace:

spawn ENOENT
    at ChildProcess.<anonymous> (/private/var/tmp/_bazel_davidaghassi/299af5c32fa95b8ba15b1237ac8646db/execroot/rh/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/index.min.js:1:91930)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
===============================================================

having docs/example/suggestion on how to solve this would make error handling better.

Describe the feature

Adding this fix pnpm/pnpm#4347 (comment) to my package.json resolved my issue and let me continue building/testing.

The reason this is hard to troubleshoot is because outside of bazel, running pnpm i works fine.

Fund our work

[Bug]: py_layers.bzl's interpreter layer also fetches dependencies

What happened?

While adopting rules_oci for python using the macro py_oci_image, I noticed non-interpreter files in the interpreter layer. Some of the site-packages have compiled modules for cpython-*, which pass the regex for interpreter (screenshot attached).

.../bazel-bin/services/services_image.interpreter_tar_manifest.spec:

services/service_name/service.runfiles/pip_parse_name_sqlalchemy/site-packages/sqlalchemy/cimmutabledict.cpython-39-x86_64-linux-gnu.so uid=0 gid=0 time=1672560000 mode=0755 type=file content=external/pip_parse_name_sqlalchemy/site-packages/sqlalchemy/cimmutabledict.cpython-39-x86_64-linux-gnu.so

image

Should be a simple fix:

cmd = "grep '{}' $< | grep -v '{}' >$@".format(PY_INTERPRETER_REGEX, SITE_PACKAGES_REGEX),

Happy to open a PR!

Version

Development (host) and target OS/architectures:

Output of bazel --version:

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved:

How to reproduce

No response

Any other information?

No response

Unrecognized options in example .bazelrc file

Just ran into an issue where copy / pasting the content of the existing .bazelrc file with the recommended settings gave me the following error on Bazel 5.3.1

'build' options: --experimental_remote_merkle_tree_cache --noexperimental_check_output_files --noexperimental_check_external_repository_files --incompatible_remote_results_ignore_disk --experimental_reuse_sandbox_directories --bes_upload_mode=fully_async --sandbox_default_allow_network=false --incompatible_strict_action_env --nolegacy_external_runfiles --incompatible_remote_results_ignore_disk --incompatible_default_to_explicit_init_py --incompatible_allow_tags_propagation --remote_local_fallback --heap_dump_on_oom --keep_going --incompatible_remote_build_event_upload_respect_no_cache
ERROR: --noexperimental_check_external_repository_files :: Unrecognized option: --noexperimental_check_external_repository_files

add example with ideal pnpm workspace configuration

... which aligns best with rules_js for the best/easiest/gazelle-friendly BUILDs.

Should demonstrate...

  • dependencies between pnpm workspace packages
  • dependencies on third-party npm packages
  • smallest setup + BUILDs possible
  • a subset of packages using typescript (allow readers to avoid looking at typescript unless they want to)

Example showing how to use rules_js in multiproject monorepo

Hey Aspect folks! Our team has been using some of the Bazel rules you've maintained in our projects (currently in the process of migrating to using rules_js), and we are super grateful for the work that you do.

One example that we'd like to see in this repo is for a single workspace that supports multiple different Node.js packages to demonstrate how one could use Bazel + rules_js to create a setup with:

  • Separate, isolated npm/pnpm dependencies between packages (i.e. no single shared package.json for the workspace). Could use https://pnpm.io/workspaces here.
  • Code sharing across packages (i.e. for a component library used by multiple web app packages).
  • Bazel targets for running the standard Next.js commands dev/build/serve/lint, with hot reload enabled for dev server. Follow up: Acknowledging that a dev and lint might be out of scope for this issue.
  • Examples of Jest tests in each package, including snapshot tests. Already captured in aspect-build/rules_jest#17

Let's say there are two packages in this workspace:

  • ts-library : a library exporting React components and TypeScript modules
  • next-app : a generic Next.js app following the next.js example, which makes use of components from ts-library

The example workspace structure could look like this:

README.md
WORKSPACE
packages/
  next-app/
    BUILD.bazel
    package.json
    ... other files for Next.js app
  ts-library/
    BUILD.bazel
    package.json
    ... other files for a TypeScript package
  ... any other packages that might be useful to show

[Bug]: Double react loading w/Next.JS in Ubuntu 20.04 (WSL)

What happened?

Hello,

I'm learning Bazel and I'm using a layout that is basically the Next.js example project with the apps and bazel folders inside a js folder since it's a multi-language project. I also have a rust folder at the root which is building a WASM module I'm including as a //:node_module.

Anyway, on to the actual problem. I can't seem to attach pictures, but there are two instances of react being pulled in to the webpack-internal:// sources when I run the app via next_dev. This means that, among other things, React hooks don't work. The two separate paths are from bazel-out/*/bin:

  • js/apps/play/next_dev.sh.runfiles/tao/node_modules.aspect_rules_js
  • node_modules/.aspect_rules_js

So what I'm trying to figure out is why [email protected] is packed into both of those separately, and why one is being imported by Next.js and its generated pages and the other is being imported by my index.tsx page. The ts_project for the pages don't even reference the react package, just its types (just like the example project).

Of note is that the next_start target works, I can build and run the page in production mode just fine.

Version

Development (host) and target OS/architectures:

Output of bazel --version:

bazel 6.0.0rc1

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

skylib 1.3.0
rules_rust 0.12.0
aspect_rules_js 1.6.7
aspect_rules_ts 1.0.0-rc5

Language(s) and/or frameworks involved:

Rust, JS/TS.

How to reproduce

I have no idea what is causing this, I can try to create a minimal repro if there is no obvious answer.

Any other information?

No response

Fund our work

  • Sponsor our open source work by donating a bug bounty

[Bug]: Running Nextjs example in Docker fails with `/app/apps/alpha/bin.runfiles/__main__/apps/alpha/bin.sh: line 379: cd: apps/alpha/dist: No such file or directory`

What happened?

I have been working on setting up the nextjs example in this repository to work on docker.

I have combined the image example js_image with the nextjs docker example implementation to successfully create a docker image.

I get the error below when I try to run the docker image:

/app/apps/alpha/bin.runfiles/__main__/apps/alpha/bin.sh: line 379: cd: apps/alpha/dist: No such file or directory

I have a fork of the repository with the changes required to build the image here.

Side Note:
Inspecting the directories in the generated image apps/alpha/dist directory exist inside the/app/apps/alpha/bin.runfiles/__main__ (I believe the issue may be related to BAZEL_BINDIR).

Running the docker image in https://github.com/aspect-build/rules_js/tree/main/e2e/js_image_oci here works fine. So I'm unsure where the error comes from.

Version

Development (host) and target OS/architectures: MacBook Pro Monterey (M1)

Output of bazel --version: bazel 6.0.0-homebrew

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

  1. rules_js-1.20.1
  2. rules_ts-1.3.1
  3. rules_python-0.14.0
  4. rules_pkg-0.8.0
  5. rules_oci-0.3.1

Language(s) and/or frameworks involved:

  1. next.js
  2. typescript

How to reproduce

1. Clone https://github.com/noelenwenede/bazel-examples/tree/main/next.js
2.  cd next.js
3. bazel build //apps/alpha:next_tarball
4. docker load --input $(bazel cquery --output=files //apps/alpha:next_tarball)
5. docker run -t -i nextjs/js:latest

Any other information?

No response

Fund our work

  • Sponsor our open source work by donating a bug bounty

[Bug]: Runfiles resolution is broken for oci_python_image example

What happened?

Runfiles resolution described in rules_python/python/runfiles does not work with bazel-examples/oci_python_image example.

This is caused by the fact that _repo_mapping file is NOT in runfiles object and so it is invisible to the custom Starlark rule 17941. The bugfix implemented in 4e60992432a49dda255eb005544ae8c03b30e243 will not help us to resolve this problem, since it only fixes zip file generating with --build_python_zip.

Version

Development (host) and target OS/architectures:

NAME="Fedora Linux"
VERSION="38 (Container Image)"
ID=fedora
VERSION_ID=38
VERSION_CODENAME=""
PLATFORM_ID="platform:f38"
PRETTY_NAME="Fedora Linux 38 (Container Image)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:38"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f38/system-administrators-guide/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=38
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=38
SUPPORT_END=2024-05-14
VARIANT="Container Image"
VARIANT_ID=container

Output of bazel --version:

bazel 6.3.1

Docker version:

Docker version 24.0.6, build ed223bc

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

bazel_dep(name = "aspect_bazel_lib", version = "1.32.0")
bazel_dep(name = "rules_python", version = "0.26.0")
bazel_dep(name = "rules_oci", version = "1.4.0")

Language(s) and/or frameworks involved:

  • Python
  • Starlark
  • OCI

How to reproduce

Check out branch bug/oci_python_image/runfiles from my fork uhlajs/bazel-examples.

Run:

cd oci_python_image
bazel run hello_world
bazel run hello_world:tarball && docker run --rm gcr.io/oci_python_hello_world:latest

Any other information?

In logs bellow the output of these two command SHOULD be identical. However, the runfiles resolution does not work correctly when running in OCI Container. The problem is with missing _repo_mapping file, so the runfiles._Runfiles._repo_mapping is NOT filled with correct data. This results in fact that runfiles resolution ends up with path /opt/hello_world/hello_world.runfiles/my_workspace/hello_world/data/config.json (note the my_workspace directory in path), where is the real location of the file is in /opt/hello_world/hello_world.runfiles/_main/hello_world/data/config.json (note _main directory in path). See also this comment.

$ bazel run hello_world

INFO: Analyzed target //hello_world:hello_world (77 packages loaded, 2621 targets configured).
INFO: Found 1 target...
Target //hello_world:hello_world up-to-date:
  bazel-bin/hello_world/hello_world
INFO: Elapsed time: 5.033s, Critical Path: 0.02s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/hello_world/hello_world
  _____________________
| hello py_image_layer! |
  =====================
                     \
                      \
                        ^__^
                        (oo)\_______
                        (__)\       )\/\
                            ||----w |
                            ||     ||
Runtime Environments
{'RUNFILES_DIR': '/var/home/honza/.cache/bazel/_bazel_honza/b78b5595904abfab5c46be08ce597b7c/execroot/_main/bazel-out/k8-fastbuild/bin/hello_world/hello_world.runfiles',
 'RUNFILES_MANIFEST_FILE': '/var/home/honza/.cache/bazel/_bazel_honza/b78b5595904abfab5c46be08ce597b7c/execroot/_main/bazel-out/k8-fastbuild/bin/hello_world/hello_world.runfiles_manifest',
 'RUNFILES_REPO_MAPPING': '/var/home/honza/.cache/bazel/_bazel_honza/b78b5595904abfab5c46be08ce597b7c/execroot/_main/bazel-out/k8-fastbuild/bin/hello_world/hello_world.repo_mapping'}

Runfiles resolution
/var/home/honza/git/github/bazel-examples/oci_python_image/hello_world/data/config.json
True
File content
['{\n', '    "version": 5\n', '}\n']

Runfiles resolution with addtional mapping
/var/home/honza/git/github/bazel-examples/oci_python_image/hello_world/data/config.json
True
File content
['{\n', '    "version": 5\n', '}\n']

$ bazel run hello_world:tarball && docker run --rm gcr.io/oci_python_hello_world:latest
INFO: Analyzed target //hello_world:tarball (25 packages loaded, 746 targets configured).
INFO: Found 1 target...
Target //hello_world:tarball up-to-date:
  bazel-bin/hello_world/tarball/tarball.tar
INFO: Elapsed time: 7.945s, Critical Path: 7.05s
INFO: 4 processes: 1 internal, 3 linux-sandbox.
INFO: Build completed successfully, 4 total actions
INFO: Running command line: bazel-bin/hello_world/tarball.sh
02e6b283ae9d: Loading layer  16.31kB/16.31kB
The image gcr.io/oci_python_hello_world:latest already exists, renaming the old one with ID sha256:59dbc2de9c53128f114c823717931629a52e6796c1f5621da095e665a8db8032 to empty string
Loaded image: gcr.io/oci_python_hello_world:latest
  _____________________
| hello py_image_layer! |
  =====================
                     \
                      \
                        ^__^
                        (oo)\_______
                        (__)\       )\/\
                            ||----w |
                            ||     ||
Runtime Environments
{'RUNFILES_DIR': '/opt/hello_world/hello_world.runfiles',
 'RUNFILES_MANIFEST_FILE': '',
 'RUNFILES_REPO_MAPPING': ''}

Runfiles resolution
/opt/hello_world/hello_world.runfiles/my_workspace/hello_world/data/config.json
False

Runfiles resolution with addtional mapping
Applying repo mapping
/opt/hello_world/hello_world.runfiles/_main/hello_world/data/config.json
True
File content
['{\n', '    "version": 5\n', '}\n']

Vue problems

(1) Cannot find base config file "@vue/tsconfig/tsconfig.web.json" [tsconfig.json]

bazel run :vite
INFO: Analyzed target //:vite (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:vite up-to-date:
  bazel-bin/vite.sh
INFO: Elapsed time: 0,134s, Critical Path: 0,00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
▲ [WARNING] Cannot find base config file "@vue/tsconfig/tsconfig.web.json" [tsconfig.json]

    ../../../../../tsconfig.json:2:13:
      2 │   "extends": "@vue/tsconfig/tsconfig.web.json",
        ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  VITE v3.0.9  ready in 1165 ms

  ➜  Local:   http://127.0.0.1:5173/
  ➜  Network: use --host to expose

(2) package.json - scripts - build-only

Looks like bazel build :dist should be bazel build :build right?

(3) Could not find a declaration file

bazel run :type-check
INFO: Analyzed target //:type-check (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:type-check up-to-date:
  bazel-bin/type-check.sh
INFO: Elapsed time: 0,145s, Critical Path: 0,01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //:type-check
-----------------------------------------------------------------------------
src/main.ts(4,20): error TS7016: Could not find a declaration file for module '@yourname/yourlibrary'. '/private/var/tmp/_bazel_loeffel/3dd7251c9a20c29dd24b6b3965605fba/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/type-check.sh.runfiles/__main__/node_modules/.aspect_rules_js/@[email protected]/node_modules/@yourname/yourlibrary/dist/library.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/yourname__yourlibrary` if it exists or add a new declaration (.d.ts) file containing `declare module '@yourname/yourlibrary';`

(4)

vue git:(main) ✗ bazel clean
INFO: Starting clean.
➜  vue git:(main) ✗ rm -rf /Users/loeffel/Library/pnpm/store/v3 
➜  vue git:(main) ✗ bazel build //:build                        
INFO: Analyzed target //:build (185 packages loaded, 1134 targets configured).
INFO: Found 1 target...
INFO: From Rollup libraries/simple/esm_bundle.js:

libraries/simple/src/index.js → libraries/simple/esm_bundle.js...
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
vue (imported by libraries/simple/src/InputText.vue?vue&type=template&id=2c159833&lang.js, libraries/simple/src/InputTextarea.vue?vue&type=template&id=3d2c14c0&lang.js)
created libraries/simple/esm_bundle.js in 34ms
INFO: From Rollup libraries/simple/cjs_bundle.js:

libraries/simple/src/index.js → libraries/simple/cjs_bundle.js...
(!) Entry module "libraries/simple/src/index.js" is implicitly using "default" export mode, which means for CommonJS output that its default export is assigned to "module.exports". For many tools, such CommonJS output will not be interchangeable with the original ES module. If this is intended, explicitly set "output.exports" to either "auto" or "default", otherwise you might want to consider changing the signature of "libraries/simple/src/index.js" to use named exports only.
https://rollupjs.org/guide/en/#outputexports
libraries/simple/src/index.js
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
vue (imported by libraries/simple/src/InputText.vue?vue&type=template&id=2c159833&lang.js, libraries/simple/src/InputTextarea.vue?vue&type=template&id=3d2c14c0&lang.js)
created libraries/simple/cjs_bundle.js in 34ms
Target //:build up-to-date:
  bazel-bin/dist
INFO: Elapsed time: 5,462s, Critical Path: 3,80s
INFO: 508 processes: 294 internal, 5 darwin-sandbox, 209 local.
INFO: Build completed successfully, 508 total actions

[Bug]: Next.js and rules_ts are incompatible for custom tsconfig.json options

What happened?

Next.js is currently trying to overwrite the tsconfig.json at runtime with its "suggested" values. Some options are unfortunately incompatible with rules_ts, specifically the configuration noEmit must be false or undefined for the rules to work but Next.js attempts to overwrite it with the value true enabling it.

In the js_run_devserver the attribute grant_sandbox_write_permissions can be enabled as a workaround to let Next.js do its magic. Unfortunately, this is not possible in js_run_binary rule.

The options are therefore the following:

  • Embed in the srcs the tsconfig.json with noEmit disabled. This will fail as Next.js attempts to overwrite the read-only file.
  • Embed in the srcs the tsconfig.json with noEmit enabled. This will fail as rules_ts require output files to be generated (noEmit must be disabled).
  • Do not embed in the srcs the tsconfig.json and let Next.js generate a default one during runtime. This is a suboptimal option as no custom configuration can be defined (this is the current approach in the Next.js example in this repository).
  • Embed in the srcs a runtime tsconfig.json with noEmit enabled, other compile options must be compatible with Next.js enforced options. Reference a second, different tsconfig.build.json during build time (i.e. in the ts_project definitions under the tsconfig attribute) which is as close as possible to the runtime configuration. This is suboptimal but the best solution found so far.

NOTE: Next.js does not allow disabling overwriting the tsconfig.json.
NOTE: Next.js does not allow to specify a different tsconfig.json, it must be in the root of the project being compiled.

Keywords:

  • Error: EROFS: read-only file system, open
  • cannot be built because the 'noEmit' option is specified in the tsconfig

Example

BUILD.bazel

load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@aspect_rules_js//js:defs.bzl", "js_run_binary", "js_run_devserver")
load("@internal_npm//:next/package_json.bzl", next_bin = "bin")

# See the following pages for examples, issues, and documentation:
#
# - https://github.com/aspect-build/bazel-examples/blob/main/next.js/apps/alpha/BUILD.bazel
# - https://github.com/aspect-build/bazel-examples/blob/main/next.js/bazel/next.bzl
# - https://github.com/aspect-build/bazel-examples/issues/226

next_bin.next_binary(
    name = "next_js_binary",
    visibility = ["//visibility:public"],
)

ts_config(
    name = "tsconfig",
    src = "tsconfig.build.json",
    visibility = ["//applications/crossrefs-website:__subpackages__"],
)

ts_config(
    name = "tsconfig-runtime",
    src = "tsconfig.json",
    visibility = ["//applications/crossrefs-website:__subpackages__"],
)

srcs = [
    # ...
]

data = [
    ":next.config.js",
    ":next-env.d.ts",
    ":tsconfig-runtime",
    "//:node_modules",
]

# `next build` creates an optimized bundle of the application
# https://nextjs.org/docs/api-reference/cli#build
js_run_binary(
    name = "build",
    srcs = srcs + data,
    args = ["build"],
    chdir = package_name(),
    out_dirs = [".next"],
    tool = ":next_js_binary",
)

# `next dev` runs the application in development mode
# https://nextjs.org/docs/api-reference/cli#development
js_run_devserver(
    name = "dev",
    args = ["dev"],
    chdir = package_name(),
    command = "../../node_modules/.bin/next",
    data = srcs + data,
)

# `next start` runs the application in production mode
# https://nextjs.org/docs/api-reference/cli#production
js_run_devserver(
    name = "start",
    args = ["start"],
    chdir = package_name(),
    command = "../../node_modules/.bin/next",
    data = data + [":build"],
)

tsconfig.build.json

    "compilerOptions": {
        "noEmit": false,
        "paths": {
           // paths...
        },
       // compilerOptions...
    },
    // exclude, include, ...
}

tsconfig.json

    "compilerOptions": {
        "noEmit": true,
        "paths": {
           // paths...
        },
       // compilerOptions...
    },
    // exclude, include, ...
}

pages/BUILD.bazel

load("@aspect_rules_ts//ts:defs.bzl", "ts_project")

ts_project(
    name = "pages",
    tsconfig = "//:tsconfig",
    # options, data, srcs, deps, ...
)

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update angular monorepo to v14.2.5 (@angular/animations, @angular/common, @angular/compiler, @angular/compiler-cli, @angular/core, @angular/forms, @angular/platform-browser, @angular/platform-browser-dynamic, @angular/router)
  • Update angular-cli monorepo (@angular-devkit/architect-cli, @angular-devkit/build-angular, @angular/cli)
  • Update dependency aspect_bazel_lib to v1.12.1
  • Update dependency aspect_rules_swc to v0.17.1
  • Update dependency aspect_rules_ts to v1.0.0-rc3
  • Update dependency rules_proto to v4.0.0
  • Update dependency rxjs to v7.5.7
  • Update babel monorepo to v7.19.3 (@babel/cli, @babel/core)
  • Update dependency aspect_rules_js to v1.4.0
  • Update dependency build_bazel_rules_nodejs to v5.6.0
  • Update dependency rules_python to v0.13.0
  • Update actions/setup-python action to v4
  • Update dependency @testing-library/user-event to v14
  • Update dependency web-vitals to v3
  • Update nest monorepo to v9 (major) (@nestjs/common, @nestjs/core, @nestjs/platform-express)
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

bazel
angular-ngc/WORKSPACE.bazel
  • aspect_rules_js v1.3.1
  • aspect_rules_esbuild v0.12.0
  • aspect_rules_ts v1.0.0-rc2
angular/WORKSPACE.bazel
  • aspect_rules_js v1.3.1
check-npm-determinism/WORKSPACE
  • build_bazel_rules_nodejs 5.5.4
eager-fetch/WORKSPACE
  • rules_python 0.8.0
go_workspaces/WORKSPACE
  • io_bazel_rules_go v0.35.0
  • bazel_gazelle v0.27.0
nestjs/WORKSPACE
  • aspect_rules_js v1.3.1
  • aspect_rules_swc v0.17.0
  • aspect_rules_ts v1.0.0-rc2
next.js/WORKSPACE.bazel
  • aspect_rules_js v1.3.1
  • aspect_rules_swc v0.17.0
  • aspect_rules_ts v1.0.0-rc3
protobufjs/WORKSPACE.bazel
  • aspect_rules_js v1.3.1
  • rules_proto 4.0.0-3.20.0
  • aspect_rules_ts v1.0.0-rc2
react-cra/WORKSPACE
  • aspect_rules_js v1.3.1
ts_project_transpiler/WORKSPACE
  • aspect_rules_js v1.3.1
  • aspect_rules_swc v0.17.0
  • aspect_rules_ts v1.0.0-rc2
vue/WORKSPACE.bazel
  • aspect_rules_js v1.3.1
  • aspect_rules_rollup v0.11.0
write_source_files/WORKSPACE
  • com_google_protobuf v3.21.5
  • bazel_skylib 1.2.1
  • io_bazel_rules_go v0.34.0
  • aspect_bazel_lib v1.12.0
bazelisk
angular-ngc/.bazelversion
  • bazel 5.3.1
angular/.bazelversion
  • bazel 5.3.1
bzlmod/.bazelversion
  • bazel 5.3.1
check-npm-determinism/.bazelversion
  • bazel 6.0.0-pre.20220818.1
eager-fetch/.bazelversion
  • bazel 5.3.1
go_workspaces/.bazelversion
  • bazel 5.3.1
nestjs/.bazelversion
  • bazel 5.3.1
next.js/.bazelversion
  • bazel 5.3.1
protobufjs/.bazelversion
  • bazel 5.3.1
react-cra/.bazelversion
  • bazel 5.3.1
ts_project_transpiler/.bazelversion
  • bazel 5.3.1
vue/.bazelversion
  • bazel 5.3.1
write_source_files/.bazelversion
  • bazel 5.3.1
github-actions
.github/workflows/ci.yaml
  • actions/checkout v3
  • actions/cache v3
  • andstor/file-existence-action v1
.github/workflows/pre-commit.yml
  • actions/checkout v3
  • actions/setup-python v3
  • pre-commit/action v3.0.0
gomod
go_workspaces/module1/go.mod
  • go 1.19
  • github.com/nathan-osman/go-sunrise v1.1.0
  • github.com/spf13/cobra v1.5.0
  • github.com/stretchr/testify v1.8.0
go_workspaces/module2/go.mod
  • go 1.19
  • github.com/nathan-osman/go-sunrise v1.1.0
  • github.com/stretchr/testify v1.8.0
npm
angular-ngc/applications/demo/package.json
angular-ngc/package.json
  • @angular/animations 14.2.3
  • @angular/common 14.2.3
  • @angular/core 14.2.3
  • @angular/forms 14.2.3
  • @angular/platform-browser 14.2.3
  • @angular/platform-browser-dynamic 14.2.3
  • @angular/router 14.2.3
  • rxjs 7.5.6
  • tslib 2.4.0
  • zone.js 0.11.8
  • @angular/compiler 14.2.3
  • @angular/compiler-cli 14.2.3
  • @babel/core 7.19.1
  • @types/babel__core 7.1.19
  • @types/jasmine 4.3.0
  • @types/node 16.11.59
  • history-server 1.3.1
  • html-insert-assets 0.14.3
  • jasmine-core 4.4.0
  • karma 6.4.1
  • karma-chrome-launcher 3.1.1
  • karma-coverage 2.2.0
  • karma-jasmine 5.1.0
  • karma-jasmine-html-reporter 1.7.0
  • typescript 4.7.4
angular-ngc/packages/common/package.json
angular-ngc/packages/lib-a/package.json
angular/package.json
  • @angular/animations 14.2.3
  • @angular/common 14.2.3
  • @angular/compiler 14.2.3
  • @angular/core 14.2.3
  • @angular/forms 14.2.3
  • @angular/platform-browser 14.2.3
  • @angular/platform-browser-dynamic 14.2.3
  • @angular/router 14.2.3
  • rxjs 7.5.6
  • tslib 2.4.0
  • zone.js 0.11.8
  • @angular-devkit/architect-cli 0.1402.3
  • @angular-devkit/build-angular 14.2.3
  • @angular/cli 14.2.3
  • @angular/compiler-cli 14.2.3
  • @types/jasmine 4.3.0
  • jasmine-core 4.4.0
  • karma 6.4.1
  • karma-chrome-launcher 3.1.1
  • karma-coverage 2.2.0
  • karma-jasmine 5.1.0
  • karma-jasmine-html-reporter 2.0.0
  • ng-packagr 14.2.1
  • typescript 4.7.4
angular/projects/common/package.json
  • tslib 2.4.0
  • @angular/common ^14.0.0
  • @angular/core ^14.0.0
angular/projects/lib-a/package.json
  • tslib 2.4.0
  • @angular/common ^14.0.0
  • @angular/core ^14.0.0
check-npm-determinism/package.json
  • ssh2 1.11.0
nestjs/package.json
  • @nestjs/common 8.4.7
  • @nestjs/core 8.4.7
  • @nestjs/platform-express 8.4.7
  • reflect-metadata 0.1.13
  • regenerator-runtime 0.13.9
  • rxjs 7.5.6
  • @types/node 16.0.0
  • typescript 4.3.5
next.js/package.json
  • next 12.2.5
  • react 18.2.0
  • react-dom 18.2.0
  • @bazel/ibazel 0.16.2
  • @types/node 18.7.15
  • @types/react 18.0.21
  • @types/react-dom 18.0.6
  • eslint 8.23.0
  • eslint-config-next 12.2.5
  • typescript 4.8.2
protobufjs/package.json
  • protobufjs 6.11.3
  • long 5.2.0
  • @grpc/grpc-js 1.7.1
  • @types/node 18.7.18
  • @types/long 4.0.2
  • @types/protobufjs 6.0.0
react-cra/package.json
  • @testing-library/jest-dom 5.16.5
  • @testing-library/react 13.4.0
  • @testing-library/user-event 13.5.0
  • react 18.2.0
  • react-dom 18.2.0
  • react-scripts 5.0.1
  • web-vitals 2.1.4
  • @bazel/ibazel 0.16.2
  • typescript 4.7.3
ts_project_transpiler/package.json
  • @babel/cli 7.18.10
  • @babel/core 7.19.1
  • @babel/preset-typescript 7.18.6
  • typescript 4.7.4
vue/libraries/simple/package.json
  • @vue/compiler-sfc 3.2.37
  • rollup 2.79.1
  • rollup-plugin-vue 6.0.0
  • rollup-plugin-peer-deps-external 2.2.4
  • vue ^3.2.21
vue/package.json
  • vue 3.2.39
  • vue-router 4.1.5
  • @bazel/ibazel 0.16.2
  • @types/node 16.11.59
  • npm-run-all 4.1.5
  • typescript 4.7.4

  • Check this box to trigger a request for Renovate to run again on this repository

[FR]: Example of how to setup multiple `package.json` with `WORKSPACE` macros

What is the current behavior?

Right now you have to define an npm_translate_lock for each package.json file in your repo. If you aren't in the space where you can do a pnpm workspace, or you don't want to for some reason, you will end up needing to define an npm_translate_lock for every package.json in the WORKSPACE. This is repetitive and needs three calls per lockfile (which is a pain). It would be nice to have it either:

  1. automatically discover all lockfiles and dynamically register them (or have an example of how to do this)
  2. Have an example that has two macros in WORKSPACE. 1 that defines the npm_translate_locks dynamically based off all pnpm-lock.yaml in the repo (with an attribute to exclude any, include should be default) and then another macro for loading what is defined and calling the function (this file could be generated maybe?).

Basically we have:

# First add the package in this file
load("//bazel/js/pnpm:deps.bzl", "translate_pnpm_lockfiles")

translate_pnpm_lockfiles()

# Then load it in this file and call the fetch logic
load("//bazel/js/pnpm:fetch_pnpm_js_deps.bzl", "fetch_pnpm_js_deps")

fetch_pnpm_js_deps()

This would make it much cleaner if there were an example of this. These are order dependent too because fetch can only happen after translate lock

Describe the feature

See above

Fund our work

[Bug]: Module @typescript-eslint/eslint-plugin not found for react-cra

What happened?

I checked bazel-examples out, then went to react-cra and ran

bazelisk run //:start

I got following output:

Failed to compile.

[eslint] Failed to load plugin '@typescript-eslint' declared in '../../../../../.eslintrc.json': Cannot find module '@typescript-eslint/eslint-plugin'
Require stack:
- /private/var/tmp/_bazel_tfr/6292325368335b9676478ec234af8bd0/execroot/__main__/.eslintrc.json
Referenced from: /private/var/tmp/_bazel_tfr/6292325368335b9676478ec234af8bd0/execroot/__main__/.eslintrc.json
ERROR in [eslint] Failed to load plugin '@typescript-eslint' declared in '../../../../../.eslintrc.json': Cannot find module '@typescript-eslint/eslint-plugin'
Require stack:
- /private/var/tmp/_bazel_tfr/6292325368335b9676478ec234af8bd0/execroot/__main__/.eslintrc.json
Referenced from: /private/var/tmp/_bazel_tfr/6292325368335b9676478ec234af8bd0/execroot/__main__/.eslintrc.json

webpack compiled with 1 error
No issues found.

The webserver was accessible and otherwise worked the way I would have expected. That is, this error showed nicely up in the browser.

Version

Development (host) and target OS/architectures:

% uname -a
Darwin mac86.local 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 x86_64
commit e526c12155c309a18c5484216896c1b74fce8fca (HEAD -> main, origin/main, origin/HEAD)
Author: Jason Bedard <[email protected]>
Date:   Mon Nov 7 13:37:55 2022 -0800

    fix: enable ngc JIT mode for angular-ngc unit tests (#134)

    Fixes #111

I used bazelisk and tried with both 5.2.0 and 6.0.0-rc1

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved:

How to reproduce

git clone https://github.com/aspect-build/bazel-examples.git
cd bazel-examples/react-cra
bazelisk run //:start

Any other information?

No response

Fund our work

  • Sponsor our open source work by donating a bug bounty

[Bug]: Add npm dependency to bzlmod fails with "no such target"

What happened?

I seem to be running into an issue where adding npm dependencies to the bzlmod example fails with a no such target error when I try to run the result:

pward@pwards-mac rules_js_test % git rev-parse HEAD
ec19825e711ef2d1db68352ed8b152cad65cd257
pward@pwards-mac rules_js_test % git diff
diff --git a/bzlmod/package.json b/bzlmod/package.json
index c927f9a..cd28cd8 100644
--- a/bzlmod/package.json
+++ b/bzlmod/package.json
@@ -1,6 +1,7 @@
 {
   "private": true,
   "dependencies": {
-    "@types/node": "18.11.9"
+    "@types/node": "18.11.9",
+    "js-yaml": "4.1.0"
   }
 }
diff --git a/bzlmod/src/BUILD.bazel b/bzlmod/src/BUILD.bazel
index 375275e..0690dd5 100644
--- a/bzlmod/src/BUILD.bazel
+++ b/bzlmod/src/BUILD.bazel
@@ -7,6 +7,7 @@ ts_project(
     tsconfig = {},
     deps = [
         "//:node_modules/@types/node",
+        "//:node_modules/js-yaml",
     ],
 )
pward@pwards-mac rules_js_test % (cd bzlmod && bazel run //src:test)
ERROR: /Users/pward/Development/rules_js_test/bzlmod/src/BUILD.bazel:4:11: no such target '//:node_modules/js-yaml': target 'node_modules/js-yaml' not declared in package '' defined by /Users/pward/Development/rules_js_test/bzlmod/BUILD.bazel (Tip: use `query "//:*"` to see all the targets in that package) and referenced by '//src:_validate_ts_options'
ERROR: /Users/pward/Development/rules_js_test/bzlmod/src/BUILD.bazel:4:11: no such target '//:node_modules/js-yaml': target 'node_modules/js-yaml' not declared in package '' defined by /Users/pward/Development/rules_js_test/bzlmod/BUILD.bazel (Tip: use `query "//:*"` to see all the targets in that package) and referenced by '//src:ts'
WARNING: errors encountered while analyzing target '//src:test': it will not be built
INFO: Analyzed target //src:test (0 packages loaded, 0 targets configured).
INFO: Found 0 targets...
ERROR: command succeeded, but there were loading phase errors
INFO: Elapsed time: 0.293s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
ERROR: Build failed. Not running target
FAILED: Build did NOT complete successfully

The recommended query does not include the npm package

pward@pwards-mac rules_js_test % bazel query "//:*"
WARNING: Invoking Bazel in batch mode since it is not invoked from within a workspace (below a directory having a WORKSPACE file).
ERROR: The 'query' command is only supported from within a workspace (below a directory having a WORKSPACE file).
See documentation at https://bazel.build/concepts/build-ref#workspace
pward@Pauls-MacBook-Pro-2 rules_js_test % (cd bzlmod && bazel query "//:*")
//:.aspect_rules_js/node_modules/@[email protected]
//:.aspect_rules_js/node_modules/@[email protected]/dir
//:.aspect_rules_js/node_modules/@[email protected]/pkg
//:.aspect_rules_js/node_modules/@[email protected]/ref
//:BUILD.bazel
//:node_modules
//:node_modules/@types
//:node_modules/@types/node
//:node_modules/@types/node/dir
Loading: 0 packages loaded

Removing the npm module eliminates the failure

pward@pwards-mac rules_js_test % git restore .
pward@pwards-mac rules_js_test % git diff
pward@pwards-mac rules_js_test % (cd bzlmod && bazel run //src:test)
INFO: Analyzed target //src:test (1 packages loaded, 7 targets configured).
INFO: Found 1 target...
Target //src:test up-to-date:
  bazel-bin/src/test.sh
INFO: Elapsed time: 0.691s, Critical Path: 0.03s
INFO: 1 process: 1 internal.
INFO: Running command line: external/bazel_tools/tools/test/test-setup.sh src/test.sh
INFO: Build completed successfully, 1 total action
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //src:test
-----------------------------------------------------------------------------
/hello

I've also tried updating to bazel 6.0.0 with no difference

pward@pwards-mac rules_js_test % git diff
diff --git a/bazelrc/.bazeliskrc b/bazelrc/.bazeliskrc
index b9ec926..56d8926 100644
--- a/bazelrc/.bazeliskrc
+++ b/bazelrc/.bazeliskrc
@@ -1,2 +1 @@
-BAZELISK_BASE_URL=https://static.aspect.build/aspect
-USE_BAZEL_VERSION=aspect/5.0.2
+USE_BAZEL_VERSION=6.0.0

Version

Development (host) and target OS/architectures:

pward@pwards-mac rules_js_test % sw_vers
ProductName:	macOS
ProductVersion:	12.5.1
BuildVersion:	21G83

Output of bazel --version:

pward@pwards-mac rules_js_test % (cd bzlmod && bazel --version)
aspect pro 5.0.2

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved:

How to reproduce

No response

Any other information?

No response

Fund our work

  • Sponsor our open source work by donating a bug bounty

[Bug]: react-cra example isn't building

What happened?

When I try to build the build target in the react-cra example project I get an error saying:

ERROR: Skipping 'react-cra:build': error loading package 'react-cra': cannot load '@npm//:react-scripts/package_json.bzl': no such file

As a note, I've tried on both Bazel 6.2.1 and Bazel 6.1.2 (which is the version your repository is pinned to).

Version

Development (host) and target OS/architectures: WSL/2

Output of bazel --version:

Bazelisk version: development
Build label: 6.2.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Jun 2 16:59:58 2023 (1685725198)
Build timestamp: 1685725198
Build timestamp as int: 1685725198

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

http_archive(
    name = "aspect_rules_js",
    sha256 = "e3e6c3d42491e2938f4239a3d04259a58adc83e21e352346ad4ef62f87e76125",
    strip_prefix = "rules_js-1.30.0",
    url = "https://github.com/aspect-build/rules_js/releases/download/v1.30.0/rules_js-v1.30.0.tar.gz",
)

Language(s) and/or frameworks involved:
JavaScript
NodeJs

How to reproduce

1. Copy the `react-cra` directory into the root of an existing repo with an existing WORKSPACE file
2. move/delete top-level files & folders from the `react-cra` as needed
3. add `react-cra` to `pnpm-workspace.yaml`
4. run `pnpm i`
3. run `blaze build react-cra:build`

Any other information?

No response

[Question] How do I optimise for build speed with ng_lib?

Hey,

Before I attempt switching from rules_nodejs to rules_js I would like to understand the recommended granularity of ng_lib for rebuilding my app.

The provided angular-ngc example splits out a common component and a common lib, but I'm currently only building one app. I would still like to optimise for build speed, for the sake of quick iterations.

So I think I'm asking if it would make sense to have one ng_lib per component in my project?

Thanks!

[Bug]: vue example doesn't work

What happened?

I get the following error when trying to run the vue example from the bazel-examples directory after a fresh clone:

dev:/tmp/bazel-examples/vue> npm run dev

> [email protected] dev
> ibazel run :vite

iBazel [6:42PM]: Querying for files to watch...
Loading: 0 packages loaded
Loading: 153 packages loaded

Loading: 0 packages loaded
Loading: 0 packages loaded

iBazel [6:42PM]: Running :vite
Loading:
Loading: 0 packages loaded
Analyzing: target //:vite (0 packages loaded, 0 targets configured)
INFO: Analyzed target //:vite (36 packages loaded, 3658 targets configured).
 checking cached actions
INFO: Found 1 target...

INFO: Elapsed time: 1.312s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 0 total actions
Loading:
Loading: 0 packages loaded
Analyzing: target //:vite (0 packages loaded, 0 targets configured)
INFO: Analyzed target //:vite (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
[0 / 2] [Prepa] BazelWorkspaceStatusAction stable-status.txt
[709 / 739] [Prepa] Running lifecycle hooks on npm package [email protected] ... (23 actions, 5 running)
INFO: From Rollup libraries/simple/cjs_bundle.js:

libraries/simple/src/index.js → libraries/simple/cjs_bundle.js...
(!) Entry module "libraries/simple/src/index.js" is implicitly using "default" export mode, which means for CommonJS output that its default export is assigned to "module.exports". For many tools, such CommonJS output will not be interchangeable with the original ES module. If this is intended, explicitly set "output.exports" to either "auto" or "default", otherwise you might want to consider changing the signature of "libraries/simple/src/index.js" to use named exports only.
https://rollupjs.org/guide/en/#outputexports
libraries/simple/src/index.js
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
vue (imported by libraries/simple/src/InputText.vue?vue&type=template&id=2c159833&lang.js, libraries/simple/src/InputTextarea.vue?vue&type=template&id=3d2c14c0&lang.js)
created libraries/simple/cjs_bundle.js in 155ms
[733 / 739] Rollup libraries/simple/esm_bundle.js; 0s linux-sandbox ... (3 actions, 2 running)
INFO: From Rollup libraries/simple/esm_bundle.js:

libraries/simple/src/index.js → libraries/simple/esm_bundle.js...
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
vue (imported by libraries/simple/src/InputText.vue?vue&type=template&id=2c159833&lang.js, libraries/simple/src/InputTextarea.vue?vue&type=template&id=3d2c14c0&lang.js)
created libraries/simple/esm_bundle.js in 158ms
Target //:vite up-to-date:
  bazel-bin/vite.sh
INFO: Elapsed time: 2.660s, Critical Path: 1.89s
INFO: 466 processes: 280 internal, 2 linux-sandbox, 184 local.
INFO: Build completed successfully, 466 total actions
INFO: Build completed successfully, 466 total actions
iBazel [6:42PM]: Starting...

################################################################################
# Did you know iBazel can invoke programs like Gazelle, buildozer, and         #
# other BUILD file generators for you automatically based on bazel output?     #
# Documentation at: https://github.com/bazelbuild/bazel-watcher#output-runner  #
################################################################################

/home/jmmv/.cache/bazel/_bazel_jmmv/5086ec9d95f5cba6669306fcf5db83b9/external/aspect_rules_js/js/private/node-patches/fs.js:797
                throw err;
                ^

Error: ENOENT: no such file or directory, readlink '/home/jmmv/.cache/bazel/_bazel_jmmv/5086ec9d95f5cba6669306fcf5db83b9/execroot/__main__/.aspect/bazelrc/common.bazelrc'
    at enoent (/home/jmmv/.cache/bazel/_bazel_jmmv/5086ec9d95f5cba6669306fcf5db83b9/external/aspect_rules_js/js/private/node-patches/fs.js:816:15)
    at /home/jmmv/.cache/bazel/_bazel_jmmv/5086ec9d95f5cba6669306fcf5db83b9/external/aspect_rules_js/js/private/node-patches/fs.js:221:39
    at /home/jmmv/.cache/bazel/_bazel_jmmv/5086ec9d95f5cba6669306fcf5db83b9/external/aspect_rules_js/js/private/node-patches/fs.js:477:32
    at FSReqCallback.oncomplete (node:fs:192:23) {
  errno: -2,
  syscall: 'readlink',
  code: 'ENOENT',
  path: '/home/jmmv/.cache/bazel/_bazel_jmmv/5086ec9d95f5cba6669306fcf5db83b9/execroot/__main__/.aspect/bazelrc/common.bazelrc'
}

Version

This is running exactly as configured by bazel-examples/vue in revision 5c785b8 (so you can get the Bazel version from there, which apparently uses some custom binaries?).

This is on a Debian testing machine:

dev:/tmp/bazel-examples/vue> uname -a
Linux dev 6.1.0-1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.4-1 (2023-01-07) x86_64 GNU/Linux

dev:/tmp/bazel-examples/vue> cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux bookworm/sid"
NAME="Debian GNU/Linux"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

dev:/tmp/bazel-examples/vue> npm --version
9.2.0

How to reproduce

Clone the `bazel-examples` repository, run the `npm run dev` command inside `vue` as the instructions say, and get a failure.

Any other information?

No response

Fund our work

  • Sponsor our open source work by donating a bug bounty

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.