Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
slamdev committed Oct 29, 2021
0 parents commit 0b6be3d
Show file tree
Hide file tree
Showing 15 changed files with 575 additions and 0 deletions.
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.2.1
29 changes: 29 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: build
on:
push:
branches:
- main
pull_request:
branches: [main]

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
bazel: [ "4.2.1", "5.0.0-pre.20210929.1" ]
java: [ 11, 17 ]
runs-on: ${{ matrix.os }}
name: OS ${{ matrix.os }} bazel ${{ matrix.bazel }} java ${{ matrix.java }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Set Bazelisk Version ${{ matrix.bazel }}
run: |
echo ${{ matrix.bazel }} > .bazelversion
- name: Build
run: |
./baseliskw build //...
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.idea/
/bazel-*
/.ijwb
/.DS_Store
/node_modules
41 changes: 41 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "nodejs_binary")
load("@npm//typescript:index.bzl", "tsc")

genrule(
name = "gen",
outs = ["index.ts"],
cmd = """
cat >$@ <<EOL
import some from "lib_a";
some();
""",
)

tsc(
name = "tsc",
outs = ["index.js"],
args = [
"-p",
"$(execpath //:tsconfig.json)",
"--outDir",
"$(RULEDIR)",
],
data = [
":gen",
"//:tsconfig.json",
"//lib_a:lib",
"@npm//@types/node",
],
)

js_library(
name = "lib",
srcs = [":tsc"],
)

nodejs_binary(
name = "bin",
data = [":lib"],
entry_point = ":index.js",
visibility = ["//visibility:public"],
)
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# bazel-js-showcase

Update package-lock.json:
```shell
bazel run @nodejs//:npm -- install
```
23 changes: 23 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
workspace(name = "bazel-js-showcase")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

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

load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "npm_install")

node_repositories(
node_version = "16.0.0",
)

npm_install(
name = "npm",
exports_directories_only = True,
package_json = "//:package.json",
package_lock_json = "//:package-lock.json",
symlink_node_modules = False,
)
65 changes: 65 additions & 0 deletions baseliskw
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env sh

##############################################################################
##
## Bazel start up script for UN*X (based on gradlew script from gradle wrapper project)
##
##
##############################################################################

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="bazelisk"
APP_BASE_NAME=`basename "$0"`

warn () {
echo "$*"
}

die () {
echo
echo "$*"
echo
exit 1
}

## Determine OS.
darwin=false
linux=false

case "`uname`" in
Darwin* )
darwin=true
;;
Linux* )
linux=true
;;
esac

BINARY_PATH=""
if $darwin; then
BINARY_PATH=bazelisk-darwin-amd64
elif $linux; then
BINARY_PATH=bazelisk-linux-amd64
else
die "UNSUPPORTED OS! Command 'uname' says: `uname`. 'darwin' = $darwin and 'linux' = $linux"
fi


exec "$APP_HOME/bazelisk/$BINARY_PATH" "$@"
8 changes: 8 additions & 0 deletions bazel.bazelproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
directories:
.

derive_targets_from_directories: true

additional_languages:
typescript
javascript
Binary file added bazelisk/bazelisk-darwin-amd64
Binary file not shown.
Binary file added bazelisk/bazelisk-linux-amd64
Binary file not shown.
7 changes: 7 additions & 0 deletions lib_a/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")

js_library(
name = "lib",
srcs = ["index.js"],
visibility = ["//visibility:public"],
)
5 changes: 5 additions & 0 deletions lib_a/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const some = () => {
console.log('some');
};

exports.some = some;
Loading

0 comments on commit 0b6be3d

Please sign in to comment.