Add rules_nodejs and npm managed directories
Switching from bower to npm packages requires to use JavaScript rules for Bazel (rules_nodejs). This change adds rules_nodejs to gerrit and also adds empty package.json files for future usage. Change-Id: I09ee3e0ffbf1d185669c54cdb0db86760bfd35c8
This commit is contained in:
parent
6ed766f886
commit
3f49f9103f
57
WORKSPACE
57
WORKSPACE
@ -1,4 +1,27 @@
|
||||
workspace(name = "gerrit")
|
||||
# npm packages are split into different node_modules directories based on their usage.
|
||||
# 1. /node_modules (referenced as @npm) - contains packages to run tests, check code, etc...
|
||||
# It is expected that @npm is used ONLY to run tools. No packages from @npm are used by
|
||||
# other code in gerrit.
|
||||
# 2. @tools_npm (tools/node_tools/node_modules) - the tools/node_tools folder contains self-written tools
|
||||
# which are run for building and/or testing. The @tools_npm directory contains all the packages needed to
|
||||
# run this tools.
|
||||
# 3. @ui_npm (polygerrit-ui/app/node_modules) - packages with source code which are necessary to run polygerrit
|
||||
# and to bundle it. Only code from these packages can be included in the final bundle for polygerrit.
|
||||
# @ui_npm folder must not have devDependencies. All dev dependencies must be placed in @ui_dev_npm
|
||||
# 4. @ui_dev_npm (polygerrit-ui/node_modules) - devDependencies for polygerrit. The packages from these
|
||||
# folder can be used for testing, but must not be included in the final bundle.
|
||||
# Note: separation between @ui_npm and @ui_dev_npm is necessary because with bazel we can't generate
|
||||
# two managed directories from the same package.json. At the same time we want to avoid accidental
|
||||
# usages of code from devDependencies in polygerrit bundle.
|
||||
workspace(
|
||||
name = "gerrit",
|
||||
managed_directories = {
|
||||
"@npm": ["node_modules"],
|
||||
"@ui_npm": ["polygerrit-ui/app/node_modules"],
|
||||
"@ui_dev_npm": ["polygerrit-ui/node_modules"],
|
||||
"@tools_npm": ["tools/node_tools/node_modules"],
|
||||
},
|
||||
)
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
|
||||
@ -30,6 +53,12 @@ http_archive(
|
||||
urls = ["https://github.com/bazelbuild/rules_closure/archive/196a45f0ede2faec11dcc6c60fbc5e7471f4bd58.tar.gz"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "build_bazel_rules_nodejs",
|
||||
sha256 = "591d2945b09ecc89fde53e56dd54cfac93322df3bc9d4747cb897ce67ba8cdbf",
|
||||
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.2.0/rules_nodejs-1.2.0.tar.gz"],
|
||||
)
|
||||
|
||||
# File is specific to Polymer and copied from the Closure Github -- should be
|
||||
# synced any time there are major changes to Polymer.
|
||||
# https://github.com/google/closure-compiler/blob/master/contrib/externs/polymer-1.0.js
|
||||
@ -1162,6 +1191,32 @@ bower_archive(
|
||||
version = "6.5.1",
|
||||
)
|
||||
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
|
||||
|
||||
yarn_install(
|
||||
name = "npm",
|
||||
package_json = "//:package.json",
|
||||
yarn_lock = "//:yarn.lock",
|
||||
)
|
||||
|
||||
yarn_install(
|
||||
name = "ui_npm",
|
||||
package_json = "//:polygerrit-ui/app/package.json",
|
||||
yarn_lock = "//:polygerrit-ui/app/yarn.lock",
|
||||
)
|
||||
|
||||
yarn_install(
|
||||
name = "ui_dev_npm",
|
||||
package_json = "//:polygerrit-ui/package.json",
|
||||
yarn_lock = "//:polygerrit-ui/yarn.lock",
|
||||
)
|
||||
|
||||
yarn_install(
|
||||
name = "tools_npm",
|
||||
package_json = "//:tools/node_tools/package.json",
|
||||
yarn_lock = "//:tools/node_tools/yarn.lock",
|
||||
)
|
||||
|
||||
# Bower component transitive dependencies.
|
||||
load("//lib/js:bower_archives.bzl", "load_bower_archives")
|
||||
|
||||
|
1
polygerrit-ui/app/.gitignore
vendored
1
polygerrit-ui/app/.gitignore
vendored
@ -1 +1,2 @@
|
||||
/plugins/
|
||||
/node_modules/
|
||||
|
9
polygerrit-ui/app/package.json
Normal file
9
polygerrit-ui/app/package.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "polygerrit-ui-dependencies",
|
||||
"description": "Gerrit Code Review - Polygerrit dependencies",
|
||||
"browser": true,
|
||||
"dependencies": {
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"private": true
|
||||
}
|
4
polygerrit-ui/app/yarn.lock
Normal file
4
polygerrit-ui/app/yarn.lock
Normal file
@ -0,0 +1,4 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
10
polygerrit-ui/package.json
Normal file
10
polygerrit-ui/package.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "polygerrit-ui-dev-dependencies",
|
||||
"description": "Gerrit Code Review - Polygerrit dev dependencies",
|
||||
"browser": true,
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"private": true
|
||||
}
|
4
polygerrit-ui/yarn.lock
Normal file
4
polygerrit-ui/yarn.lock
Normal file
@ -0,0 +1,4 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
1
tools/node_tools/.gitignore
vendored
Normal file
1
tools/node_tools/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/node_modules/
|
18
tools/node_tools/package.json
Normal file
18
tools/node_tools/package.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "gerrit-build-tools",
|
||||
"description": "Gerrit Build Tools",
|
||||
"browser": false,
|
||||
"dependencies": {
|
||||
"@bazel/rollup": "^0.41.0",
|
||||
"crisper": "^2.1.1",
|
||||
"dom5": "^3.0.1",
|
||||
"polymer-bundler": "^4.0.10",
|
||||
"polymer-cli": "^1.9.11",
|
||||
"rollup": "^1.27.5",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-terser": "^5.1.3"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"license": "Apache-2.0",
|
||||
"private": true
|
||||
}
|
8559
tools/node_tools/yarn.lock
Normal file
8559
tools/node_tools/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user