Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 0 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ startup --host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1
import %workspace%/tools/file/files.bazelrc
import %workspace%/tools/test/tests.bazelrc

# Bzlmod
common --enable_workspace

# Cache
build --disk_cache=~/.cache/bazel-disk
clean --disk_cache ~/.cache/bazel-disk
Expand Down
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.lock linguist-generated

browsers.json linguist-generated
npm.json linguist-generated
8 changes: 5 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ jobs:
- name: Configure bazel
run: .github/configure-bazel
- name: Test
run:
bazel test tools/bazel:bazelrc.diff tools/lint:format_test
tools/lint:lint_test
run: |
set -e
bazel test tools/lint:format_test tools/lint:lint_test
bazel run @files//packages:bazelrc.diff
bazel run tools/test:bazelrc.diff
# needs bazel_util to work with generate directories tools/javascript:js_diff
test:
name: Test
Expand Down
21 changes: 8 additions & 13 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,31 @@ alias(
)

alias(
name = "bazelrc_gen",
actual = "//tools/bazel:bazelrc",
)

alias(
name = "js_gen",
actual = "//tools/javascript:js",
name = "lint",
actual = "//tools/lint",
)

alias(
name = "lint",
actual = "//tools/lint",
name = "npm_resolve",
actual = "//tools/npm:resolve",
)

js_library(
name = "prettier_config",
srcs = ["prettierrc.yml"],
srcs = ["prettierrc.yaml"],
root = ":root",
visibility = [":__subpackages__"],
deps = ["@npm//prettier-plugin-organize-imports:lib"],
)

alias(
name = "nodejs_resolve",
actual = "//nodejs:nodejs_resolve",
name = "refresh",
actual = "//tools:refresh",
)

cjs_root(
name = "root",
package_name = "@better-rules-javascript/root",
package_name = "@rules-javascript/root",
descriptors = ["package.json"],
visibility = [":__subpackages__"],
)
Expand Down
23 changes: 6 additions & 17 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,14 @@ To generate documentation:
bazel run :doc
```

## Node.js

To resolve additional Node.js versions, run `bazel run :nodejs_resolve`.

## NPM

After updating `package.json`, run `bazel run tools/npm:resolve` to resolve the
packages.

## Bazel Pacakges

After creating or deleting Bazel packages, run `bazel run :bazelrc_gen` to
update `--deleted_packages`, necessary for formatting and integration testing.
After updating `package.json` or `test/package.json`, run
`bazel run :npm_resolve` to resolve the packages.

## Bootstrapped JS
## Refresh

Some JS build products need to be boostrapped. They are checking into version
control.
After some changes, `bazel run :refresh` is required.

To refresh these, run `bazel run :js_gen`, which re-builds and copies them to
source tree. If that breaks, you'll have to rollback to the last good state of
the generated files.
This will update the list of `--deleted_packages` (for linting and tests) and
the bootstrapped JS products.
17 changes: 14 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module(name = "better_rules_javascript")
module(name = "rules_javascript")

# Bazel Util

Expand All @@ -17,17 +17,28 @@ archive_override(

include("//tools/file:file.MODULE.bazel")

# JavaScript

include("//nodejs:nodejs.MODULE.bazel")
include("//playwright:playwright.MODULE.bazel")
include("//test:test.MODULE.bazel")
include("//tools/npm:npm.MODULE.bazel")

# Pkg

bazel_dep(name = "rules_pkg", version = "1.2.0")

# Platform

bazel_dep(name = "platforms", version = "1.0.0")

# Protobuf

bazel_dep(name = "rules_proto", version = "7.1.0")

# Shell

bazel_dep(name = "rules_shell_extra")
bazel_dep(name = "rules_shell_extra", dev_dependency = True)

RULES_SHELL_EXTRA_VERSION = "93090b47f81577ba4890c770effd889f61ce5d19"

Expand All @@ -44,4 +55,4 @@ bazel_dep(name = "bazel_skylib", version = "1.9.0")

# Stardoc

bazel_dep(name = "stardoc", version = "0.8.0")
bazel_dep(name = "stardoc", version = "0.8.0", dev_dependency = True)
16 changes: 16 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,18 @@ See [documentation](docs/index.md).

## Install

**WORKSPACE.bazel**
**MODULE.bazel**

```bzl
# better_rules_javascript

JAVACRIPT_VERSION = "..."
http_archive(
name = "better_rules_javascript",
strip_prefix = "rules_javascript-%s" % JAVASCRIPT_VERSION,
urls = ["https://github.com/rivethealth/rules_javascript/archive/%s.tar.gz" % JAVACRIPT_VERSION],
RULES_JAVACRIPT_VERSION = "<commit>"

bazel_dep(name = "rules_javascript")
archive_override(
module_name = "rules_javascript",
sha256 = "<sha256>",
strip_prefix = "rules_javascript-%s" % RULES_JAVACRIPT_VERSION,
url = "https://github.com/redoapp/rules_javascript/archive/%s.tar.gz" % RULES_JAVACRIPT_VERSION,
)

load("@better_rules_javascript//rules:workspace.bzl", javascript_repositories = "respositories")
javascript_respositories()
```

## Example
Expand All @@ -61,10 +59,10 @@ console.log("Hello world");
**BUILD.bazel**

```bzl
load("@better_rules_javascript//commonjs:rules.bzl", "cjs_root")
load("@better_rules_javascript//javascript:rules.bzl", "js_library")
load("@better_rules_javascript//typescript:rules.bzl", "tsconfig", "ts_library")
load("@better_rules_javascript//nodejs:rules.bzl", "nodejs_binary")
load("@rules_javascript//commonjs:rules.bzl", "cjs_root")
load("@rules_javascript//javascript:rules.bzl", "js_library")
load("@rules_javascript//typescript:rules.bzl", "tsconfig", "ts_library")
load("@rules_javascript//nodejs:rules.bzl", "nodejs_binary")

nodejs_binary(
name = "bin",
Expand Down
11 changes: 0 additions & 11 deletions WORKSPACE.bazel

This file was deleted.

8 changes: 4 additions & 4 deletions angular/js-compiler/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ ts_library(
"//commonjs/package:lib",
"//nodejs/fs-linker:lib",
"//util/json:lib",
"@better_rules_javascript_npm//@types/argparse:lib",
"@better_rules_javascript_npm//@types/node:lib",
"@better_rules_javascript_npm//argparse:lib",
"@npm//@types/argparse:lib",
"@npm//@types/node:lib",
"@npm//argparse:lib",
],
)

cjs_root(
name = "root",
package_name = "@better-rules-javascript/angular-js-compiler",
package_name = "@rules-javascript/angular-js-compiler",
descriptors = ["package.json"],
visibility = ["//visibility:public"],
)
Expand Down
8 changes: 4 additions & 4 deletions angular/js-compiler/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { workerMain } from "@better-rules-javascript/bazel-worker";
import { patchFs } from "@better-rules-javascript/nodejs-fs-linker/fs";
import { patchFsPromises } from "@better-rules-javascript/nodejs-fs-linker/fs-promises";
import { WrapperVfs } from "@better-rules-javascript/nodejs-fs-linker/vfs";
import { workerMain } from "@rules-javascript/bazel-worker";
import { patchFs } from "@rules-javascript/nodejs-fs-linker/fs";
import { patchFsPromises } from "@rules-javascript/nodejs-fs-linker/fs-promises";
import { WrapperVfs } from "@rules-javascript/nodejs-fs-linker/vfs";

workerMain(async () => {
const vfs = new WrapperVfs();
Expand Down
8 changes: 4 additions & 4 deletions angular/js-compiler/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PackageTree } from "@better-rules-javascript/commonjs-package";
import { createVfs } from "@better-rules-javascript/nodejs-fs-linker/package";
import { WrapperVfs } from "@better-rules-javascript/nodejs-fs-linker/vfs";
import { JsonFormat } from "@better-rules-javascript/util-json";
import { PackageTree } from "@rules-javascript/commonjs-package";
import { createVfs } from "@rules-javascript/nodejs-fs-linker/package";
import { WrapperVfs } from "@rules-javascript/nodejs-fs-linker/vfs";
import { JsonFormat } from "@rules-javascript/util-json";
import { ArgumentParser } from "argparse";
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { dirname, resolve } from "node:path";
Expand Down
2 changes: 1 addition & 1 deletion angular/js-compiler/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"module": "commonjs",
"moduleResolution": "node"
},
"extends": "@better-rules-javascript/tools-typescript/tsconfig.common.json"
"extends": "@rules-javascript/tools-typescript/tsconfig.common.json"
}
6 changes: 3 additions & 3 deletions angular/resource-compiler/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load("//typescript:rules.bzl", "ts_library")

cjs_root(
name = "root",
package_name = "@better-rules-javascript/angular-resource-compiler",
package_name = "@rules-javascript/angular-resource-compiler",
descriptors = ["package.json"],
visibility = ["//:__subpackages__"],
)
Expand All @@ -26,8 +26,8 @@ ts_library(
root = ":root",
deps = [
"//bazel/worker:lib",
"@better_rules_javascript_npm//@types/argparse:lib",
"@better_rules_javascript_npm//argparse:lib",
"@npm//@types/argparse:lib",
"@npm//argparse:lib",
],
)

Expand Down
2 changes: 1 addition & 1 deletion angular/resource-compiler/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { workerMain } from "@better-rules-javascript/bazel-worker";
import { workerMain } from "@rules-javascript/bazel-worker";

workerMain(async () => {
const { ResourceWorker, ResourceWorkerError } = await import("./worker");
Expand Down
2 changes: 1 addition & 1 deletion angular/resource-compiler/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"module": "commonjs",
"moduleResolution": "node"
},
"extends": "@better-rules-javascript/tools-typescript/tsconfig.common.json"
"extends": "@rules-javascript/tools-typescript/tsconfig.common.json"
}
2 changes: 1 addition & 1 deletion angular/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ js_library(

cjs_root(
name = "root",
package_name = "@better-rules-javascript/angular-test",
package_name = "@rules-javascript/angular-test",
)

jest_test(
Expand Down
4 changes: 2 additions & 2 deletions angular/test/bazel/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@better_rules_javascript//angular:rules.bzl", "configure_angular_compiler")
load("@better_rules_javascript//typescript:rules.bzl", "configure_ts_compiler")
load("@rules_javascript//angular:rules.bzl", "configure_angular_compiler")
load("@rules_javascript//typescript:rules.bzl", "configure_ts_compiler")

package(default_visibility = ["//visibility:public"])

Expand Down
22 changes: 21 additions & 1 deletion angular/test/bazel/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module(name = "better_rules_javascript_test")
module(name = "rules_javascript_test")

# Bazel Util

Expand All @@ -13,6 +13,26 @@ archive_override(
url = "https://github.com/redoapp/bazel-util/archive/%s.tar.gz" % BAZEL_UTIL_VERSION,
)

# JavaScript

bazel_dep(name = "rules_javascript")
local_path_override(
module_name = "rules_javascript",
path = "../../../../bazel_util++file+files/files",
)

yarn = use_extension("@rules_javascript//npm:extensions.bzl", "yarn", dev_dependency = True)
yarn.workspace(
name = "rules_javascript_test_npm",
data = "@rules_javascript//test:npm.json",
path = "/",
plugins = [
"@rules_javascript//commonjs:npm_plugin.bzl",
"@rules_javascript//typescript:npm_plugin.bzl",
],
)
use_repo(yarn, npm = "rules_javascript_test_npm")

# Pkg

bazel_dep(name = "rules_pkg", version = "1.2.0")
Expand Down
12 changes: 0 additions & 12 deletions angular/test/bazel/WORKSPACE.bazel

This file was deleted.

8 changes: 4 additions & 4 deletions angular/test/bazel/basic/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
load("@better_rules_javascript//angular:rules.bzl", "angular_library")
load("@better_rules_javascript//commonjs:rules.bzl", "cjs_root")
load("@better_rules_javascript//javascript:rules.bzl", "js_library")
load("@rules_javascript//angular:rules.bzl", "angular_library")
load("@rules_javascript//commonjs:rules.bzl", "cjs_root")
load("@rules_javascript//javascript:rules.bzl", "js_library")

cjs_root(
name = "root",
package_name = "@better-rules-javascript-test/angular-replace",
package_name = "@rules-javascript-test/angular-replace",
)

js_library(
Expand Down
Loading