diff --git a/BUILD.bazel b/BUILD.bazel index 22ae8bf1..6f457614 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -19,6 +19,7 @@ # https://github.com/bazelbuild/rules_go/blob/master/go/tools/gazelle/README.rst#directives # gazelle:exclude node_modules load("@io_bazel_rules_go//go:def.bzl", "gazelle") +load("@build_bazel_rules_nodejs//internal/js_library:js_library.bzl", "js_library") gazelle( name = "gazelle", @@ -48,6 +49,7 @@ skylark_doc( "//internal:ts_config.bzl", "//internal/devserver:ts_devserver.bzl", "//internal/karma:ts_web_test.bzl", + "//internal/protobufjs:ts_proto_library.bzl", ], format = "html", # The site is served at http://tsetse.info so the URL doesn't include a @@ -56,3 +58,20 @@ skylark_doc( site_root = "/api", strip_prefix = "internal/", ) + +# Runtime libraries needed by the protobufjs library. +# Any JS code produced by the ts_proto_library rule has a runtime dependency on these scripts. +js_library( + name = "protobufjs_bootstrap_scripts", + srcs = [ + "@build_bazel_rules_typescript_protobufs_compiletime_deps//:node_modules/long/dist/long.js", + "@build_bazel_rules_typescript_protobufs_compiletime_deps//:node_modules/protobufjs/dist/minimal/protobuf.min.js", + ], + # Make devmode loading work when it does require("protobufjs/minimal") + # so this is shimmed to define it to equal global.protobuf + amd_names = { + "long": "Long", + "protobufjs/minimal": "protobuf", + }, + visibility = ["//visibility:public"], +) diff --git a/WORKSPACE b/WORKSPACE index 80c2a407..70de43e5 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -16,9 +16,9 @@ workspace(name = "build_bazel_rules_typescript") http_archive( name = "build_bazel_rules_nodejs", - url = "https://github.com/bazelbuild/rules_nodejs/archive/0.5.3.zip", - strip_prefix = "rules_nodejs-0.5.3", - sha256 = "17a5515f59777b00cb25dbc710017a14273f825029b2ec60e0969d28914870be", + url = "https://github.com/bazelbuild/rules_nodejs/archive/092404e3b47e1144ecfc2937d3729b717b1052bf.zip", + strip_prefix = "rules_nodejs-092404e3b47e1144ecfc2937d3729b717b1052bf", + sha256 = "5e3dd3f76a043687939a14ce6aee3049f8bd97d2cd885ef2105ac344d05213a3", ) load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install") diff --git a/defs.bzl b/defs.bzl index d5bfd616..312cef28 100644 --- a/defs.bzl +++ b/defs.bzl @@ -21,6 +21,7 @@ load("//internal:build_defs.bzl", _ts_library = "ts_library") load("//internal:ts_config.bzl", _ts_config = "ts_config") load("//internal/devserver:ts_devserver.bzl", _ts_devserver = "ts_devserver_macro") load("//internal/karma:ts_web_test.bzl", _ts_web_test = "ts_web_test_macro") +load("//internal/protobufjs:ts_proto_library.bzl", _ts_proto_library = "ts_proto_library") ts_setup_workspace = _ts_setup_workspace ts_library = _ts_library @@ -28,5 +29,6 @@ ts_config = _ts_config ts_devserver = _ts_devserver # TODO(alexeagle): make ts_web_test work in google3 ts_web_test = _ts_web_test +ts_proto_library = _ts_proto_library # DO NOT ADD MORE rules here unless they appear in the generated docsite. # Run yarn skydoc to re-generate the docsite. diff --git a/examples/protocol_buffers/BUILD.bazel b/examples/protocol_buffers/BUILD.bazel new file mode 100644 index 00000000..b2982c67 --- /dev/null +++ b/examples/protocol_buffers/BUILD.bazel @@ -0,0 +1,60 @@ +load("@build_bazel_rules_typescript//:defs.bzl", + "ts_library", + "ts_proto_library", + "ts_web_test", + "ts_devserver", +) + +proto_library( + name = "tire_proto", + srcs = ["tire.proto"], +) + +proto_library( + name = "car_proto", + srcs = ["car.proto"], + deps = [":tire_proto"], +) + +ts_proto_library( + # The result will be "car.d.ts" named after this target. + # We could use the output_name attribute if we want the output named + # differently than the target. + name = "car", + deps = [":car_proto"], +) + +ts_library( + name = "test_lib", + testonly = True, + srcs = ["car.spec.ts"], + deps = [":car"], +) + +ts_web_test( + name = "test", + deps = ["test_lib"], + bootstrap = ["@build_bazel_rules_typescript//:protobufjs_bootstrap_scripts"], +) + +ts_library( + name = "app", + srcs = ["app.ts"], + deps = [":car"], +) + +ts_devserver( + name = "devserver", + deps = [":app"], + entry_module = "build_bazel_rules_typescript/examples/protocol_buffers/app", + bootstrap = ["@build_bazel_rules_typescript//:protobufjs_bootstrap_scripts"], +) + +# Test for production mode +load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle") + +rollup_bundle( + name = "bundle", + deps = [":app"], + entry_point = "examples/protocol_buffers/app", +) diff --git a/examples/protocol_buffers/app.ts b/examples/protocol_buffers/app.ts new file mode 100644 index 00000000..f7628395 --- /dev/null +++ b/examples/protocol_buffers/app.ts @@ -0,0 +1,7 @@ +import {Car} from './car'; + +const serverResponse = `{"make": "Porsche"}`; +const car = Car.create(JSON.parse(serverResponse)); +const el: HTMLDivElement = document.createElement('div'); +el.innerText = `Car from server: ${car.make}`; +document.body.appendChild(el); diff --git a/examples/protocol_buffers/car.proto b/examples/protocol_buffers/car.proto new file mode 100644 index 00000000..d8b04d14 --- /dev/null +++ b/examples/protocol_buffers/car.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +import "examples/protocol_buffers/tire.proto"; + +message Car { + string make = 1; + string model = 2; + int32 year = 3; + Tire front_tires = 4; + Tire rear_tires = 5; + int64 mileage = 6; +} diff --git a/examples/protocol_buffers/car.spec.ts b/examples/protocol_buffers/car.spec.ts new file mode 100644 index 00000000..803b9df2 --- /dev/null +++ b/examples/protocol_buffers/car.spec.ts @@ -0,0 +1,35 @@ +import {Car} from './car'; +import Long = require('long'); + +describe('protocol buffers', () => { + + it('allows creation of an object described by proto', () => { + const pontiac = Car.create({ + make: "pontiac", + frontTires: { + width: 225, + aspectRatio: 65, + construction: 'R', + diameter: 17, + }, + }); + expect(pontiac.make).toEqual('pontiac'); + if (!pontiac.frontTires) { + fail('Should have frontTires set'); + } else { + expect(pontiac.frontTires.width).toEqual(225); + } + }); + + // Asserts that longs are handled correctly. + // This value comes from https://github.com/dcodeIO/long.js#background + it('handles long values correctly', () => { + const pontiac = Car.create({ + make: "pontiac", + // Long.MAX_VALUE + mileage: new Long(0xFFFFFFFF, 0x7FFFFFFF), + }); + const object = Car.toObject(pontiac, {longs: String}); + expect(object["mileage"]).toEqual("9223372036854775807"); + }); +}); diff --git a/examples/protocol_buffers/tire.proto b/examples/protocol_buffers/tire.proto new file mode 100644 index 00000000..a7de133a --- /dev/null +++ b/examples/protocol_buffers/tire.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +message Tire { + string type = 1; + int32 width = 2; + int32 aspect_ratio = 3; + string construction = 4; + int32 diameter = 5; + int32 load_index = 6; + string speed_rating = 7; +} diff --git a/examples/tsconfig.json b/examples/tsconfig.json index d08c0faa..6b05f236 100644 --- a/examples/tsconfig.json +++ b/examples/tsconfig.json @@ -1,7 +1,11 @@ { "compilerOptions": { "strict": true, - "lib": ["es2015.promise", "dom", "es5"] + "lib": ["es2015.promise", "dom", "es5"], + // Include the output directory in rootDirs so that generated .d.ts files + // can be used for type-checking in the editor, for example the car.proto + // produces a car.d.ts. + "rootDirs": [".", "../bazel-bin/examples"] } } diff --git a/internal/devserver/ts_devserver.bzl b/internal/devserver/ts_devserver.bzl index ba60c33f..f9cd7f6a 100644 --- a/internal/devserver/ts_devserver.bzl +++ b/internal/devserver/ts_devserver.bzl @@ -17,6 +17,9 @@ load("@build_bazel_rules_nodejs//internal:node.bzl", "sources_aspect", ) +load("@build_bazel_rules_nodejs//internal/js_library:js_library.bzl", + "write_amd_names_shim", +) def _ts_devserver(ctx): files = depset() @@ -43,12 +46,19 @@ def _ts_devserver(ctx): workspace_name + "/" + f.short_path + "\n" for f in files ])) + amd_names_shim = ctx.actions.declare_file( + "_%s.amd_names_shim.js" % ctx.label.name, + sibling = ctx.outputs.executable) + write_amd_names_shim(ctx.actions, amd_names_shim, ctx.attr.bootstrap) + # Requirejs is always needed so its included as the first script # in script_files before any user specified scripts for the devserver # to concat in order. - script_files = depset() - script_files += ctx.files._requirejs_script - script_files += ctx.files.scripts + script_files = [] + script_files.extend(ctx.files.bootstrap) + script_files.append(ctx.file._requirejs_script) + script_files.append(amd_names_shim) + script_files.extend(ctx.files.scripts) ctx.actions.write(ctx.outputs.scripts_manifest, "".join([ workspace_name + "/" + f.short_path + "\n" for f in script_files ])) @@ -57,9 +67,9 @@ def _ts_devserver(ctx): ctx.executable._devserver, ctx.outputs.manifest, ctx.outputs.scripts_manifest, - ctx.file._requirejs_script] + ] devserver_runfiles += ctx.files.static_files - devserver_runfiles += ctx.files.scripts + devserver_runfiles += script_files serving_arg = "" if ctx.attr.serving_path: @@ -120,6 +130,9 @@ ts_devserver = rule( ts_devserver concats the following snippet after the bundle to load the application: `require(["entry_module"]);` """), + "bootstrap": attr.label_list( + doc = "Scripts to include in the JS bundle before the module loader (require.js)", + allow_files = [".js"]), "_requirejs_script": attr.label(allow_files = True, single_file = True, default = Label("@build_bazel_rules_typescript_devserver_deps//:node_modules/requirejs/require.js")), "_devserver": attr.label( default = Label("//internal/devserver/main"), diff --git a/internal/karma/ts_web_test.bzl b/internal/karma/ts_web_test.bzl index 3c74f24d..85da445f 100644 --- a/internal/karma/ts_web_test.bzl +++ b/internal/karma/ts_web_test.bzl @@ -17,6 +17,7 @@ load("@build_bazel_rules_nodejs//internal:node.bzl", "sources_aspect", "expand_path_into_runfiles", ) +load("@build_bazel_rules_nodejs//internal/js_library:js_library.bzl", "write_amd_names_shim") _CONF_TMPL = "//internal/karma:karma.conf.js" # TODO(alexeagle): users will need some control over browser; needs design @@ -45,6 +46,12 @@ def _ts_web_test_impl(ctx): expand_path_into_runfiles(ctx, f.short_path) for f in ctx.files.bootstrap ] + + amd_names_shim = ctx.actions.declare_file( + "_%s.amd_names_shim.js" % ctx.label.name, + sibling = ctx.outputs.executable) + write_amd_names_shim(ctx.actions, amd_names_shim, ctx.attr.bootstrap) + # Explicitly list the requirejs library files here, rather than use # `frameworks: ['requirejs']` # so that we control the script order, and the bootstrap files come before @@ -55,6 +62,7 @@ def _ts_web_test_impl(ctx): bootstrap_entries += [ "build_bazel_rules_typescript_karma_deps/node_modules/requirejs/require.js", "build_bazel_rules_typescript_karma_deps/node_modules/karma-requirejs/lib/adapter.js", + "/".join([ctx.workspace_name, amd_names_shim.short_path]), ] # Finally we load the user's srcs and deps user_entries = [ @@ -115,7 +123,7 @@ $KARMA ${{ARGV[@]}} return [DefaultInfo( runfiles = ctx.runfiles( files = ctx.files.srcs + ctx.files.deps + ctx.files.bootstrap + [ - conf, + conf, amd_names_shim ], transitive_files = files, # Propagate karma_bin and its runfiles diff --git a/internal/protobufjs/BUILD.bazel b/internal/protobufjs/BUILD.bazel new file mode 100644 index 00000000..662c061b --- /dev/null +++ b/internal/protobufjs/BUILD.bazel @@ -0,0 +1,19 @@ +package(default_visibility=["//visibility:public"]) +load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary") + +exports_files([ + "node_modules/protobufjs/dist/minimal/protobuf.min.js", + # Exported to be consumed for generating skydoc. + "ts_proto_library.bzl", +]) + +nodejs_binary( + name = "pbjs", + node_modules = "@build_bazel_rules_typescript_protobufs_compiletime_deps//:node_modules", + entry_point = "protobufjs/bin/pbjs", +) +nodejs_binary( + name = "pbts", + node_modules = "@build_bazel_rules_typescript_protobufs_compiletime_deps//:node_modules", + entry_point = "protobufjs/bin/pbts", +) diff --git a/internal/protobufjs/package.json b/internal/protobufjs/package.json new file mode 100644 index 00000000..7d669f6c --- /dev/null +++ b/internal/protobufjs/package.json @@ -0,0 +1,20 @@ +{ + "name": "protobufjs", + "version": "1.0.0", + "main": "index.js", + "license": "MIT", + "devDependencies": { + "chalk": "^1.1.3", + "escodegen": "^1.9.0", + "espree": "^3.5.3", + "estraverse": "^4.2.0", + "glob": "^7.1.2", + "jsdoc": "^3.5.5", + "minimist": "^1.2.0", + "protobufjs": "Use HEAD to pick up fix for https://github.com/dcodeIO/protobuf.js/pull/1018", + "protobufjs": "github:dcodeIO/protobuf.js#65d113b0079fa2570837f3cf95268ce24714a248", + "semver": "^5.5.0", + "tmp": "0.0.33", + "uglify-js": "^2.8.29" + } +} diff --git a/internal/protobufjs/ts_proto_library.bzl b/internal/protobufjs/ts_proto_library.bzl new file mode 100644 index 00000000..9482c67a --- /dev/null +++ b/internal/protobufjs/ts_proto_library.bzl @@ -0,0 +1,166 @@ +# Copyright 2017 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"Protocol Buffers" + +def _run_pbjs(actions, executable, output_name, proto_files, suffix = ".js", wrap = "amd", amd_name = ""): + js_file = actions.declare_file(output_name + suffix) + + # Create an intermediate file so that we can do some manipulation of the + # generated .js output that makes it compatible with our named AMD loading. + js_tmpl_file = actions.declare_file(output_name + suffix + ".tmpl") + + # Reference of arguments: + # https://github.com/dcodeIO/ProtoBuf.js/#pbjs-for-javascript + args = actions.args() + args.add(["--target", "static-module"]) + args.add(["--wrap", wrap]) + args.add("--strict-long") # Force usage of Long type with int64 fields + args.add(["--out", js_file.path + ".tmpl"]) + args.add([f.path for f in proto_files]) + + actions.run( + executable = executable._pbjs, + inputs = proto_files, + outputs = [js_tmpl_file], + arguments = [args], + ) + + actions.expand_template( + template = js_tmpl_file, + output = js_file, + substitutions = { + # convert anonymous AMD module + # define(["protobufjs/minimal"], function($protobuf) { + # to named + # define("wksp/path/to/module", ["protobufjs/minimal"], ... + "define([": "define('%s/%s', [" % (amd_name, output_name), + } + ) + return js_file + +def _run_pbts(actions, executable, js_file): + ts_file = actions.declare_file(js_file.basename[:-len(".closure.js")] + ".d.ts") + + # Reference of arguments: + # https://github.com/dcodeIO/ProtoBuf.js/#pbts-for-typescript + args = actions.args() + args.add(["--out", ts_file.path]) + args.add(js_file.path) + + actions.run( + executable = executable._pbts, + progress_message = "Generating typings from %s" % js_file.short_path, + inputs = [js_file], + outputs = [ts_file], + arguments = [args], + ) + return ts_file + +def _ts_proto_library(ctx): + sources = depset() + for dep in ctx.attr.deps: + if not hasattr(dep, "proto"): + fail("ts_proto_library dep %s must be a proto_library rule" % dep.label) + # TODO(alexeagle): go/new-proto-library suggests + # > should not parse .proto files. Instead, they should use the descriptor + # > set output from proto_library + # but protobuf.js doesn't seem to accept that bin format + sources = depset(transitive = [sources, dep.proto.transitive_sources]) + + output_name = ctx.attr.output_name or ctx.label.name + + js_es5 = _run_pbjs(ctx.actions, ctx.executable, output_name, sources, + amd_name = "/".join([p for p in [ + ctx.workspace_name, + ctx.label.package, + ] if p])) + js_es6 = _run_pbjs(ctx.actions, ctx.executable, output_name, sources, + suffix = ".closure.js", wrap = "es6") + dts = _run_pbts(ctx.actions, ctx.executable, js_es6) + + # Return a structure that is compatible with the deps[] of a ts_library. + return struct( + files = depset([dts]), + typescript = struct( + declarations = [dts], + transitive_declarations = [dts], + type_blacklisted_declarations = [], + es5_sources = depset([js_es5]), + es6_sources = depset([js_es6]), + transitive_es5_sources = depset(), + transitive_es6_sources = depset([js_es6]), + ), + ) + +ts_proto_library = rule( + implementation = _ts_proto_library, + attrs = { + "deps": attr.label_list(doc = "proto_library targets"), + "output_name": attr.string( + doc = """Name of the resulting module, which you will import from. + If not specified, the name will match the target's name."""), + "_pbjs": attr.label(default = Label("//internal/protobufjs:pbjs"), + executable = True, cfg = "host"), + "_pbts": attr.label(default = Label("//internal/protobufjs:pbts"), + executable = True, cfg = "host"), + }, +) +""" +Wraps https://github.com/dcodeIO/protobuf.js for use in Bazel. + +`ts_proto_library` has identical outputs to `ts_library`, so it can be used anywhere +a `ts_library` can appear, such as in the `deps[]` of another `ts_library`. + +Example: + +``` +load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_proto_library") + +ts_proto_library( + name = "car_proto", + srcs = ["car.proto"], +) + +ts_library( + name = "test_lib", + testonly = True, + srcs = ["car.spec.ts"], + deps = [":car_proto"], +) +``` + +The JavaScript produced by protobuf.js has a runtime dependency on a support library. +Under devmode (e.g. `ts_devserver`, `ts_web_test`) you'll need to include these scripts +in the `bootstrap` phase (before Require.js loads). You can use the label +`@build_bazel_rules_typescript//:protobufjs_bootstrap_scripts` to reference these scripts. + +After Require.js loads, we need to provide a name for the `protobufjs` global symbol +so that it can be require'd. Put this code somewhere in your app: +`define("protobufjs/minimal", () => protobuf);` + +To complete the example above, you could write a `ts_web_test`: + +``` +load("@build_bazel_rules_typescript//:defs.bzl", "ts_web_test") + +ts_web_test( + name = "test", + deps = ["test_lib"], + bootstrap = ["@build_bazel_rules_typescript//:protobufjs_bootstrap_scripts"], + srcs = ["require.config.js"], +) +``` + +where require.config.js contains the `define` statement above. +""" diff --git a/internal/protobufjs/yarn.lock b/internal/protobufjs/yarn.lock new file mode 100644 index 00000000..caa71009 --- /dev/null +++ b/internal/protobufjs/yarn.lock @@ -0,0 +1,467 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" + +"@protobufjs/base64@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" + +"@protobufjs/codegen@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" + +"@protobufjs/eventemitter@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" + +"@protobufjs/fetch@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" + dependencies: + "@protobufjs/aspromise" "^1.1.1" + "@protobufjs/inquire" "^1.1.0" + +"@protobufjs/float@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" + +"@protobufjs/inquire@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" + +"@protobufjs/path@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" + +"@protobufjs/pool@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" + +"@protobufjs/utf8@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" + +"@types/long@^3.0.32": + version "3.0.32" + resolved "https://registry.yarnpkg.com/@types/long/-/long-3.0.32.tgz#f4e5af31e9e9b196d8e5fca8a5e2e20aa3d60b69" + +"@types/node@^8.9.4": + version "8.10.10" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.10.tgz#fec07bc2ad549d9e6d2f7aa0fb0be3491b83163a" + +acorn-jsx@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b" + dependencies: + acorn "^3.0.4" + +acorn@^3.0.4: + version "3.3.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" + +acorn@^5.5.0: + version "5.5.3" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.5.3.tgz#f473dd47e0277a08e28e9bec5aeeb04751f0b8c9" + +align-text@^0.1.1, align-text@^0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" + dependencies: + kind-of "^3.0.2" + longest "^1.0.1" + repeat-string "^1.5.2" + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +babylon@7.0.0-beta.19: + version "7.0.0-beta.19" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.19.tgz#e928c7e807e970e0536b078ab3e0c48f9e052503" + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + +bluebird@~3.5.0: + version "3.5.1" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +camelcase@^1.0.2: + version "1.2.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" + +catharsis@~0.8.9: + version "0.8.9" + resolved "https://registry.yarnpkg.com/catharsis/-/catharsis-0.8.9.tgz#98cc890ca652dd2ef0e70b37925310ff9e90fc8b" + dependencies: + underscore-contrib "~0.3.0" + +center-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" + dependencies: + align-text "^0.1.3" + lazy-cache "^1.0.3" + +chalk@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +cliui@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" + dependencies: + center-align "^0.1.1" + right-align "^0.1.1" + wordwrap "0.0.2" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +decamelize@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + +deep-is@~0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" + +escape-string-regexp@^1.0.2, escape-string-regexp@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +escodegen@^1.9.0: + version "1.9.1" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.9.1.tgz#dbae17ef96c8e4bedb1356f4504fa4cc2f7cb7e2" + dependencies: + esprima "^3.1.3" + estraverse "^4.2.0" + esutils "^2.0.2" + optionator "^0.8.1" + optionalDependencies: + source-map "~0.6.1" + +espree@^3.5.3: + version "3.5.4" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7" + dependencies: + acorn "^5.5.0" + acorn-jsx "^3.0.0" + +esprima@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" + +estraverse@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + +fast-levenshtein@~2.0.4: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +glob@^7.1.2: + version "7.1.2" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +graceful-fs@^4.1.9: + version "4.1.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + +js2xmlparser@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-3.0.0.tgz#3fb60eaa089c5440f9319f51760ccd07e2499733" + dependencies: + xmlcreate "^1.0.1" + +jsdoc@^3.5.5: + version "3.5.5" + resolved "https://registry.yarnpkg.com/jsdoc/-/jsdoc-3.5.5.tgz#484521b126e81904d632ff83ec9aaa096708fa4d" + dependencies: + babylon "7.0.0-beta.19" + bluebird "~3.5.0" + catharsis "~0.8.9" + escape-string-regexp "~1.0.5" + js2xmlparser "~3.0.0" + klaw "~2.0.0" + marked "~0.3.6" + mkdirp "~0.5.1" + requizzle "~0.2.1" + strip-json-comments "~2.0.1" + taffydb "2.6.2" + underscore "~1.8.3" + +kind-of@^3.0.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + dependencies: + is-buffer "^1.1.5" + +klaw@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/klaw/-/klaw-2.0.0.tgz#59c128e0dc5ce410201151194eeb9cbf858650f6" + dependencies: + graceful-fs "^4.1.9" + +lazy-cache@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" + +levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" + +long@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" + +longest@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" + +marked@~0.3.6: + version "0.3.19" + resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.19.tgz#5d47f709c4c9fc3c216b6d46127280f40b39d790" + +minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + dependencies: + brace-expansion "^1.1.7" + +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +mkdirp@~0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +optionator@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.4" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + wordwrap "~1.0.0" + +os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +prelude-ls@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + +"protobufjs@github:dcodeIO/protobuf.js#65d113b0079fa2570837f3cf95268ce24714a248": + version "6.8.7" + resolved "https://codeload.github.com/dcodeIO/protobuf.js/tar.gz/65d113b0079fa2570837f3cf95268ce24714a248" + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/long" "^3.0.32" + "@types/node" "^8.9.4" + long "^4.0.0" + +repeat-string@^1.5.2: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + +requizzle@~0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/requizzle/-/requizzle-0.2.1.tgz#6943c3530c4d9a7e46f1cddd51c158fc670cdbde" + dependencies: + underscore "~1.6.0" + +right-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" + dependencies: + align-text "^0.1.1" + +semver@^5.5.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" + +source-map@~0.5.1: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + +source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + +strip-ansi@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +taffydb@2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/taffydb/-/taffydb-2.6.2.tgz#7cbcb64b5a141b6a2efc2c5d2c67b4e150b2a268" + +tmp@0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + dependencies: + os-tmpdir "~1.0.2" + +type-check@~0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + dependencies: + prelude-ls "~1.1.2" + +uglify-js@^2.8.29: + version "2.8.29" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" + dependencies: + source-map "~0.5.1" + yargs "~3.10.0" + optionalDependencies: + uglify-to-browserify "~1.0.0" + +uglify-to-browserify@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" + +underscore-contrib@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/underscore-contrib/-/underscore-contrib-0.3.0.tgz#665b66c24783f8fa2b18c9f8cbb0e2c7d48c26c7" + dependencies: + underscore "1.6.0" + +underscore@1.6.0, underscore@~1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.6.0.tgz#8b38b10cacdef63337b8b24e4ff86d45aea529a8" + +underscore@~1.8.3: + version "1.8.3" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" + +window-size@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" + +wordwrap@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" + +wordwrap@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +xmlcreate@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/xmlcreate/-/xmlcreate-1.0.2.tgz#fa6bf762a60a413fb3dd8f4b03c5b269238d308f" + +yargs@~3.10.0: + version "3.10.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" + dependencies: + camelcase "^1.0.2" + cliui "^2.1.0" + decamelize "^1.0.0" + window-size "0.1.0" diff --git a/internal/ts_repositories.bzl b/internal/ts_repositories.bzl index ac89e7d0..2e81feb4 100644 --- a/internal/ts_repositories.bzl +++ b/internal/ts_repositories.bzl @@ -38,3 +38,9 @@ def ts_setup_workspace(): package_json = "@build_bazel_rules_typescript//internal/karma:package.json", yarn_lock = "@build_bazel_rules_typescript//internal/karma:yarn.lock", ) + + yarn_install( + name = "build_bazel_rules_typescript_protobufs_compiletime_deps", + package_json = "@build_bazel_rules_typescript//internal/protobufjs:package.json", + yarn_lock = "@build_bazel_rules_typescript//internal/protobufjs:yarn.lock", + ) diff --git a/package.json b/package.json index 126920ec..fbd48398 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "devDependencies": { "@bazel/ibazel": "^0.2.0", "@types/jasmine": "^2.8.2", + "@types/long": "^4.0.0", "@types/node": "7.0.18", "@types/source-map": "^0.5.1", "@types/tmp": "^0.0.33", diff --git a/yarn.lock b/yarn.lock index 338518fa..2b9cbb76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10,6 +10,10 @@ version "2.8.2" resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.8.2.tgz#6ae4d8740c0da5d5a627df725b4eed71b8e36668" +"@types/long@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.0.tgz#719551d2352d301ac8b81db732acb6bdc28dbdef" + "@types/node@7.0.18": version "7.0.18" resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.18.tgz#cd67f27d3dc0cfb746f0bdd5e086c4c5d55be173" @@ -925,15 +929,15 @@ tsickle@0.25.x: source-map "^0.5.6" source-map-support "^0.4.2" -tslib@^1.7.1: - version "1.8.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.8.0.tgz#dc604ebad64bcbf696d613da6c954aa0e7ea1eb6" +tslib@^1.8.1: + version "1.9.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8" -tsutils@2.12.1: - version "2.12.1" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.12.1.tgz#f4d95ce3391c8971e46e54c4cf0edb0a21dd5b24" +tsutils@2.20.0: + version "2.20.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.20.0.tgz#303394064bc80be8ee04e10b8609ae852e9312d3" dependencies: - tslib "^1.7.1" + tslib "^1.8.1" tunnel-agent@^0.6.0: version "0.6.0" @@ -945,9 +949,9 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" -typescript@2.5.x: - version "2.5.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.5.3.tgz#df3dcdc38f3beb800d4bc322646b04a3f6ca7f0d" +typescript@2.6.x: + version "2.6.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4" ultron@1.0.x: version "1.0.2"