Skip to content

Commit

Permalink
upgrading to newest nodejs_rules (#4057)
Browse files Browse the repository at this point in the history
* upgrading to newest nodejs_rules

CHANGELOG_BEGIN
CHANGELOG_END

* addressing andreas comments
  • Loading branch information
Robin Krom authored Jan 16, 2020
1 parent b96e54f commit 0a26591
Show file tree
Hide file tree
Showing 12 changed files with 367 additions and 133 deletions.
2 changes: 1 addition & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ alias(

alias(
name = "yarn",
actual = "@nodejs//:bin/yarn.cmd" if is_windows else "@nodejs//:bin/yarn",
actual = "@nodejs//:yarn",
)

alias(
Expand Down
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ dev_env_tool(
)

# Setup the Node.js toolchain
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")
load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")

node_repositories(
package_json = ["//:package.json"],
Expand All @@ -654,7 +654,7 @@ load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")

install_bazel_dependencies()

load("@npm_bazel_typescript//:defs.bzl", "ts_setup_workspace")
load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")

ts_setup_workspace()

Expand Down
30 changes: 0 additions & 30 deletions bazel_tools/rules_nodejs_posix_path.patch

This file was deleted.

1 change: 1 addition & 0 deletions compiler/daml-extension/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ genrule(
# rm -rf can fail with "directory not empty" on Windows.
# As a workaround we add `|| return`.
cmd = """
export HOME=/does-not-exist
set -euo pipefail
TMP_DIR=$$(mktemp -d)
cleanup () { rm -rf $$TMP_DIR || return; }
Expand Down
15 changes: 8 additions & 7 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,20 @@ def daml_deps():
if "io_bazel_rules_sass" not in native.existing_rules():
http_archive(
name = "io_bazel_rules_sass",
sha256 = "7f0d64061e5bac749275349a7a7918b6f5759365f289192ff791f3c1495afcf1",
strip_prefix = "rules_sass-1.22.3",
urls = ["https://github.com/bazelbuild/rules_sass/archive/1.22.3.tar.gz"],
sha256 = "7b9c9a88099d00dbb16be359c3b1946309d99673220c6b39c7e8bda8ecc692f8",
strip_prefix = "rules_sass-1.24.4",
urls = [
"https://github.com/bazelbuild/rules_sass/archive/1.24.4.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_sass/archive/1.24.4.zip",
],
)

# Fetch rules_nodejs so we can install our npm dependencies
if "build_bazel_rules_nodejs" not in native.existing_rules():
http_archive(
name = "build_bazel_rules_nodejs",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.32.2/rules_nodejs-0.32.2.tar.gz"],
sha256 = "6d4edbf28ff6720aedf5f97f9b9a7679401bf7fca9d14a0fff80f644a99992b4",
patches = ["@com_github_digital_asset_daml//bazel_tools:rules_nodejs_posix_path.patch"],
patch_args = ["-p1"],
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.1.0/rules_nodejs-1.1.0.tar.gz"],
sha256 = "c97bf38546c220fa250ff2cc052c1a9eac977c662c1fc23eda797b0ce8e70a43",
)

if "com_github_grpc_grpc" not in native.existing_rules():
Expand Down
178 changes: 177 additions & 1 deletion docs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2020 The DAML Authors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
load("@os_info//:os_info.bzl", "is_linux", "is_windows")
load("//rules_daml:daml.bzl", "daml_compile", "daml_test")
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
Expand All @@ -25,7 +25,84 @@ genrule(
"theme/da_theme/**",
],
) + [
# we need to list all the transitive dependencies here because of https://github.com/bazelbuild/rules_nodejs/issues/1553
"@npm//acorn",
"@npm//acorn-dynamic-import",
"@npm//acorn-node",
"@npm//acorn-walk",
"@npm//ansi-regex",
"@npm//ansi-styles",
"@npm//anymatch",
"@npm//assert",
"@npm//async",
"@npm//async-each",
"@npm//balanced-match",
"@npm//basic-auth",
"@npm//batch",
"@npm//binary-extensions",
"@npm//body",
"@npm//brace-expansion",
"@npm//browserify",
"@npm//browserify-cache-api",
"@npm//browserify-incremental",
"@npm//browserify-zlib",
"@npm//browser-pack",
"@npm//browser-resolve",
"@npm//buffer",
"@npm//buffer-from",
"@npm//cached-path-relative",
"@npm//chalk",
"@npm//chokidar",
"@npm//coffeescript",
"@npm//color-convert",
"@npm//colors",
"@npm//combine-source-map",
"@npm//concat-map",
"@npm//concat-stream",
"@npm//connect",
"@npm//connect-livereload",
"@npm//console-browserify",
"@npm//constants-browserify",
"@npm//continuable-cache",
"@npm//convert-source-map",
"@npm//core-util-is",
"@npm//cross-spawn",
"@npm//crypto-browserify",
"@npm//dargs",
"@npm//dash-ast",
"@npm//dateformat",
"@npm//defined",
"@npm//depd",
"@npm//deps-sort",
"@npm//destroy",
"@npm//detective",
"@npm//domain-browser",
"@npm//duplexer",
"@npm//duplexer2",
"@npm//ee-first",
"@npm//encodeurl",
"@npm//error",
"@npm//escape-html",
"@npm//escape-string-regexp",
"@npm//etag",
"@npm//eventemitter2",
"@npm//events",
"@npm//exit",
"@npm//faye-websocket",
"@npm//figures",
"@npm//file-sync-cmp",
"@npm//findup-sync",
"@npm//fresh",
"@npm//fs.realpath",
"@npm//function-bind",
"@npm//gaze",
"@npm//get-assigned-identifiers",
"@npm//getobject",
"@npm//glob",
"@npm//glob-parent",
"@npm//globule",
"@npm//graceful-fs",
"@npm//grunt",
"@npm//grunt-banner",
"@npm//grunt-browserify",
"@npm//grunt-contrib-clean",
Expand All @@ -35,8 +112,107 @@ genrule(
"@npm//grunt-contrib-uglify",
"@npm//grunt-contrib-watch",
"@npm//grunt-exec",
"@npm//grunt-legacy-log",
"@npm//grunt-legacy-log-utils",
"@npm//grunt-legacy-util",
"@npm//grunt-open",
"@npm//gzip-size",
"@npm//has",
"@npm//has-ansi",
"@npm//has-flag",
"@npm//hooker",
"@npm//htmlescape",
"@npm//http-parser-js",
"@npm//https-browserify",
"@npm//iconv-lite",
"@npm//inflight",
"@npm//inherits",
"@npm//inline-source-map",
"@npm//insert-module-globals",
"@npm//is-binary-path",
"@npm//is-number-like",
"@npm//is-wsl",
"@npm//jsonparse",
"@npm//json-stable-stringify",
"@npm//JSONStream",
"@npm//js-yaml",
"@npm//labeled-stream-splicer",
"@npm//lodash",
"@npm//lodash.isfinite",
"@npm//lodash.memoize",
"@npm//lru-cache",
"@npm//matchdep",
"@npm//maxmin",
"@npm//mime-db",
"@npm//mime-types",
"@npm//minimatch",
"@npm//mkdirp",
"@npm//module-deps",
"@npm//morgan",
"@npm//node-http2",
"@npm//nopt",
"@npm//normalize-path",
"@npm//number-is-nan",
"@npm//object-assign",
"@npm//once",
"@npm//on-finished",
"@npm//on-headers",
"@npm//opn",
"@npm//os-browserify",
"@npm//parents",
"@npm//parseurl",
"@npm//path-browserify",
"@npm//path-dirname",
"@npm//path-is-absolute",
"@npm//path-platform",
"@npm//portscanner",
"@npm//pretty-bytes",
"@npm//process",
"@npm//process-nextick-args",
"@npm//querystring-es3",
"@npm//readable-stream",
"@npm//readdirp",
"@npm//read-only-stream",
"@npm//remove-trailing-separator",
"@npm//rimraf",
"@npm//safe-buffer",
"@npm//safe-json-parse",
"@npm//safer-buffer",
"@npm//serve-index",
"@npm//shasum",
"@npm//sprintf-js",
"@npm//statuses",
"@npm//stream-browserify",
"@npm//stream-combiner2",
"@npm//stream-http",
"@npm//stream-splicer",
"@npm//string_decoder",
"@npm//string-template",
"@npm//strip-ansi",
"@npm//supports-color",
"@npm//syntax-error",
"@npm//through",
"@npm//through2",
"@npm//timers-browserify",
"@npm//tiny-lr",
"@npm//tty-browserify",
"@npm//uglify-js",
"@npm//umd",
"@npm//undeclared-identifiers",
"@npm//underscore.string",
"@npm//unpipe",
"@npm//upath",
"@npm//uri-path",
"@npm//url",
"@npm//util",
"@npm//util-deprecate",
"@npm//utils-merge",
"@npm//vm-browserify",
"@npm//watchify",
"@npm//websocket-driver",
"@npm//websocket-extensions",
"@npm//wrappy",
"@npm//xtend",
],
outs = ["da_theme.tar.gz"],
cmd = """
Expand Down
18 changes: 16 additions & 2 deletions navigator/frontend/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Copyright (c) 2020 The DAML Authors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
load("@os_info//:os_info.bzl", "is_windows")
# load ("@npm_bazel_typescript//:index.bzl", "ts_library")

filegroup(
name = "src",
Expand Down Expand Up @@ -48,8 +49,21 @@ nodejs_binary(
# ],
)

# TODO (drsk) We should switch the frontend rule to use the bazel typescript rules instead of
# webpack. Something like the following:
# ts_library(
# name = "frontend",
# tsconfig = ":tsconfig.json",
# srcs = glob(["**/*.ts"]),
# data = [":package.json", ":tslint.json"],
# node_modules = "@navigator_frontend_deps//:node_modules",
# visibility = [
# "//navigator:__subpackages__",
# ],
# )

# Builds the frontend single page application and bundles all output files
# (HTML + JavaScript + CSS + images) in a .tgz or .jar archive.
#  (HTML + JavaScript + CSS + images) in a .tgz or .jar archive.
genrule(
name = "frontend",
srcs = [
Expand Down
2 changes: 1 addition & 1 deletion navigator/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"lint": "tslint --project tslint.json"
},
"devDependencies": {
"@bazel/hide-bazel-files": "0.32.0",
"@bazel/hide-bazel-files": "1.1.0",
"@types/async": "2.0.39",
"@types/babel-core": "^6.25.3",
"@types/classnames": "0.0.32",
Expand Down
10 changes: 8 additions & 2 deletions navigator/frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ const APP_NAME = 'Navigator';
*/
module.exports = (env) => {
const paths_case_check = env && env.paths_case_check || 'true';
const in_dir = env && env.bazel_in_dir || __dirname;
const out_dir = env && env.bazel_out_dir || path.join(__dirname, 'dist');
// const in_dir = env && env.bazel_in_dir || __dirname;
// const out_dir = env && env.bazel_out_dir || path.join(__dirname, 'dist');
// TODO (drsk) there seems to be a bug in the code producing the `env.bazel_in_dir,
// env.bazel_out_dir` that just concats directory components. We should switch back to rely on
// bazel_in_dir/bazel_out_dir once it's fixed.
// The issue is reported and tracked here: https://github.com/bazelbuild/rules_nodejs/issues/1554
const in_dir = __dirname;
const out_dir = path.join(__dirname, 'dist');
const build_version = env && env.bazel_version_file ? fs.readFileSync(env.bazel_version_file, 'utf8').trim() : 'HEAD';
const build_commit = env && env.bazel_commit_file ? fs.readFileSync(env.bazel_commit_file, 'utf8').trim() : 'HEAD';
const isProduction = env ? (!!env.prod || !!env.production) : false;
Expand Down
8 changes: 4 additions & 4 deletions navigator/frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@
lodash "^4.17.11"
to-fast-properties "^2.0.0"

"@bazel/hide-bazel-files@0.32.0":
version "0.32.0"
resolved "https://registry.yarnpkg.com/@bazel/hide-bazel-files/-/hide-bazel-files-0.32.0.tgz#642becc6ac9c27a4486b3f671a078090f93371cb"
integrity sha512-eraORpt2iBiHal4FRV2c/3enH2nttWp4myOcHZvEVd8v7P/tt9FWv04MrxDIKHCqZIVt51D/2sXmOJKuKsKqvA==
"@bazel/hide-bazel-files@1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@bazel/hide-bazel-files/-/hide-bazel-files-1.1.0.tgz#a7d46a4aa3717150b54fde05b2f8b6bab733f493"
integrity sha512-JJ9eMKPBodWugC4Wu0QLe0saDZ971RcP2kjZbG1vJfQHn/gnxvw+4nXDRwei5EzxBsGGuLxY1MkNDtRFIfZr5w==

"@endemolshinegroup/cosmiconfig-typescript-loader@^1.0.0":
version "1.0.0"
Expand Down
Loading

0 comments on commit 0a26591

Please sign in to comment.