build(bazel): use http_server rule from rules_nodejs (#28905)

PR Close #28905
This commit is contained in:
Greg Magolan 2019-02-21 14:05:31 -08:00 committed by Ben Lesh
parent ad4a9bf03f
commit fafabc0b92
14 changed files with 9 additions and 176 deletions

View File

@ -1,8 +1,7 @@
load("//packages/bazel:index.bzl", "protractor_web_test_suite") load("//packages/bazel:index.bzl", "protractor_web_test_suite")
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver") load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle") load("@build_bazel_rules_nodejs//:defs.bzl", "http_server", "rollup_bundle")
load("//tools:defaults.bzl", "ts_library") load("//tools:defaults.bzl", "ts_library")
load("//tools/http-server:http_server.bzl", "http_server")
ts_library( ts_library(
name = "app", name = "app",

View File

@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library") load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library")
load("//tools/http-server:http_server.bzl", "http_server") load("@build_bazel_rules_nodejs//:defs.bzl", "http_server")
ng_module( ng_module(
name = "animation_world", name = "animation_world",

View File

@ -2,7 +2,7 @@ package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library") load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library")
load("//tools/symbol-extractor:index.bzl", "js_expected_symbol_test") load("//tools/symbol-extractor:index.bzl", "js_expected_symbol_test")
load("//tools/http-server:http_server.bzl", "http_server") load("@build_bazel_rules_nodejs//:defs.bzl", "http_server")
ng_module( ng_module(
name = "cyclic_import", name = "cyclic_import",

View File

@ -2,7 +2,7 @@ package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library") load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library")
load("//tools/symbol-extractor:index.bzl", "js_expected_symbol_test") load("//tools/symbol-extractor:index.bzl", "js_expected_symbol_test")
load("//tools/http-server:http_server.bzl", "http_server") load("@build_bazel_rules_nodejs//:defs.bzl", "http_server")
ng_module( ng_module(
name = "hello_world", name = "hello_world",

View File

@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle", "ts_library") load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle", "ts_library")
load("//tools/http-server:http_server.bzl", "http_server") load("@build_bazel_rules_nodejs//:defs.bzl", "http_server")
ng_module( ng_module(
name = "hello_world_i18n", name = "hello_world_i18n",

View File

@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library") load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library")
load("//tools/http-server:http_server.bzl", "http_server") load("@build_bazel_rules_nodejs//:defs.bzl", "http_server")
ng_module( ng_module(
name = "hello_world", name = "hello_world",

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library") load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library")
load("//tools/http-server:http_server.bzl", "http_server")
load("//tools/symbol-extractor:index.bzl", "js_expected_symbol_test") load("//tools/symbol-extractor:index.bzl", "js_expected_symbol_test")
load("@build_bazel_rules_nodejs//:defs.bzl", "http_server")
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver") load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
ng_module( ng_module(

View File

@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library") load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library")
load("//tools/http-server:http_server.bzl", "http_server") load("@build_bazel_rules_nodejs//:defs.bzl", "http_server")
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver") load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
ng_module( ng_module(

View File

@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library") load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library")
load("//tools/http-server:http_server.bzl", "http_server") load("@build_bazel_rules_nodejs//:defs.bzl", "http_server")
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver") load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
ng_module( ng_module(

View File

@ -1 +0,0 @@
# Marker this directory is a Bazel package.

View File

@ -1,11 +0,0 @@
# http-server
This is a simple Bazel wrapper around the http-server npm package.
A typical frontend project is served by a specific server.
For Angular's example applications, our needs are simple so we can just use http-server.
Real projects might need history-server (for router support) or even better a full-featured production server like express.
We modify http-server to support serving Brotli-compressed files, which end with a `.br` extension.
This is equivalent to gzip-compression support.
See https://github.com/alexeagle/http-server/commits/master which points to a modified ecstatic library.

View File

@ -1,20 +0,0 @@
"""Simple Bazel wrapper around npm http-server package.
See https://www.npmjs.com/package/http-server
"""
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
def http_server(templated_args = [], **kwargs):
# By default, we pass an argument pointing the http server to the
# package of the caller.
# This assumes there is an index.html in the package directory.
if not templated_args:
templated_args = [native.package_name()]
nodejs_binary(
node_modules = "@http-server_runtime_deps//:node_modules",
entry_point = "http-server/bin/http-server",
templated_args = templated_args,
**kwargs
)

View File

@ -1,9 +0,0 @@
{
"name": "http_server",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"http-server": "github:alexeagle/http-server#97205e945b69091606ed83aa0c8489e9ce65d282"
}
}

View File

@ -1,125 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
async@^1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
colors@1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"
corser@~2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/corser/-/corser-2.0.1.tgz#8eda252ecaab5840dcd975ceb90d9370c819ff87"
debug@^2.2.0:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
dependencies:
ms "2.0.0"
"ecstatic@github:alexeagle/node-ecstatic#833f734497f72f8cf396f162f46ad48c56ddc4ca":
version "3.2.0"
resolved "https://codeload.github.com/alexeagle/node-ecstatic/tar.gz/833f734497f72f8cf396f162f46ad48c56ddc4ca"
dependencies:
he "^1.1.1"
mime "^1.4.1"
minimist "^1.1.0"
url-join "^2.0.2"
eventemitter3@1.x.x:
version "1.2.0"
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-1.2.0.tgz#1c86991d816ad1e504750e73874224ecf3bec508"
he@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd"
http-proxy@^1.8.1:
version "1.16.2"
resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.16.2.tgz#06dff292952bf64dbe8471fa9df73066d4f37742"
dependencies:
eventemitter3 "1.x.x"
requires-port "1.x.x"
"http-server@github:alexeagle/http-server#97205e945b69091606ed83aa0c8489e9ce65d282":
version "0.11.1"
resolved "https://codeload.github.com/alexeagle/http-server/tar.gz/97205e945b69091606ed83aa0c8489e9ce65d282"
dependencies:
colors "1.0.3"
corser "~2.0.0"
ecstatic "github:alexeagle/node-ecstatic#833f734497f72f8cf396f162f46ad48c56ddc4ca"
http-proxy "^1.8.1"
opener "~1.4.0"
optimist "0.6.x"
portfinder "^1.0.13"
union "~0.4.3"
mime@^1.4.1:
version "1.6.0"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
minimist@0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
minimist@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
minimist@~0.0.1:
version "0.0.10"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"
mkdirp@0.5.x:
version "0.5.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
dependencies:
minimist "0.0.8"
ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
opener@~1.4.0:
version "1.4.3"
resolved "https://registry.yarnpkg.com/opener/-/opener-1.4.3.tgz#5c6da2c5d7e5831e8ffa3964950f8d6674ac90b8"
optimist@0.6.x:
version "0.6.1"
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
dependencies:
minimist "~0.0.1"
wordwrap "~0.0.2"
portfinder@^1.0.13:
version "1.0.13"
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.13.tgz#bb32ecd87c27104ae6ee44b5a3ccbf0ebb1aede9"
dependencies:
async "^1.5.2"
debug "^2.2.0"
mkdirp "0.5.x"
qs@~2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/qs/-/qs-2.3.3.tgz#e9e85adbe75da0bbe4c8e0476a086290f863b404"
requires-port@1.x.x:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
union@~0.4.3:
version "0.4.6"
resolved "https://registry.yarnpkg.com/union/-/union-0.4.6.tgz#198fbdaeba254e788b0efcb630bc11f24a2959e0"
dependencies:
qs "~2.3.3"
url-join@^2.0.2:
version "2.0.5"
resolved "https://registry.yarnpkg.com/url-join/-/url-join-2.0.5.tgz#5af22f18c052a000a48d7b82c5e9c2e2feeda728"
wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"