PR Close #26488
This commit is contained in:
@ -1,5 +1,15 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_config")
|
||||
|
||||
exports_files(["tsconfig.json"])
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig-test",
|
||||
src = "tsconfig-test.json",
|
||||
deps = ["tsconfig.json"],
|
||||
)
|
||||
|
||||
# The toolchain container used for execution is defined in the target indicated
|
||||
# by "extra_execution_platforms", "host_platform" and "platforms".
|
||||
# If you are using your own toolchain container, you need to create a platform
|
||||
@ -28,5 +38,4 @@ platform(
|
||||
value: "SYS_ADMIN"
|
||||
}
|
||||
""",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
@ -8,7 +8,9 @@ load("//packages/bazel/src:ng_rollup_bundle.bzl", _ng_rollup_bundle = "ng_rollup
|
||||
|
||||
DEFAULT_TSCONFIG_BUILD = "//packages:tsconfig-build.json"
|
||||
DEFAULT_TSCONFIG_TEST = "//packages:tsconfig-test.json"
|
||||
DEFAULT_NODE_MODULES = "@angular_deps//:node_modules"
|
||||
DEFAULT_COMPILER_BIN = "//:@bazel/typescript/tsc_wrapped"
|
||||
DEFAULT_TS_TYPINGS = "@ngdeps//typescript:typescript__typings"
|
||||
DEFAULT_KARMA_BIN = "//:@bazel/karma/karma"
|
||||
|
||||
# Packages which are versioned together on npm
|
||||
ANGULAR_SCOPED_PACKAGES = ["@angular/%s" % p for p in [
|
||||
@ -41,15 +43,34 @@ PKG_GROUP_REPLACEMENTS = {
|
||||
]""" % ",\n ".join(["\"%s\"" % s for s in ANGULAR_SCOPED_PACKAGES]),
|
||||
}
|
||||
|
||||
def ts_library(tsconfig = None, node_modules = DEFAULT_NODE_MODULES, testonly = False, **kwargs):
|
||||
def ts_library(tsconfig = None, testonly = False, deps = [], **kwargs):
|
||||
"""Default values for ts_library"""
|
||||
deps = deps + ["@ngdeps//tslib"]
|
||||
if testonly:
|
||||
# Match the types[] in //packages:tsconfig-test.json
|
||||
deps.append("@ngdeps//@types/jasmine")
|
||||
deps.append("@ngdeps//@types/node")
|
||||
if not tsconfig:
|
||||
if testonly:
|
||||
tsconfig = DEFAULT_TSCONFIG_TEST
|
||||
else:
|
||||
tsconfig = DEFAULT_TSCONFIG_BUILD
|
||||
_ts_library(tsconfig = tsconfig, node_modules = node_modules, testonly = testonly, **kwargs)
|
||||
_ts_library(
|
||||
tsconfig = tsconfig,
|
||||
testonly = testonly,
|
||||
deps = deps,
|
||||
compiler = DEFAULT_COMPILER_BIN,
|
||||
node_modules = DEFAULT_TS_TYPINGS,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def ng_module(name, tsconfig = None, entry_point = None, node_modules = DEFAULT_NODE_MODULES, testonly = False, **kwargs):
|
||||
def ng_module(name, tsconfig = None, entry_point = None, testonly = False, deps = [], **kwargs):
|
||||
"""Default values for ng_module"""
|
||||
deps = deps + ["@ngdeps//tslib"]
|
||||
if testonly:
|
||||
# Match the types[] in //packages:tsconfig-test.json
|
||||
deps.append("@ngdeps//@types/jasmine")
|
||||
deps.append("@ngdeps//@types/node")
|
||||
if not tsconfig:
|
||||
if testonly:
|
||||
tsconfig = DEFAULT_TSCONFIG_TEST
|
||||
@ -57,12 +78,27 @@ def ng_module(name, tsconfig = None, entry_point = None, node_modules = DEFAULT_
|
||||
tsconfig = DEFAULT_TSCONFIG_BUILD
|
||||
if not entry_point:
|
||||
entry_point = "public_api.ts"
|
||||
_ng_module(name = name, flat_module_out_file = name, tsconfig = tsconfig, entry_point = entry_point, node_modules = node_modules, testonly = testonly, **kwargs)
|
||||
_ng_module(
|
||||
name = name,
|
||||
flat_module_out_file = name,
|
||||
tsconfig = tsconfig,
|
||||
entry_point = entry_point,
|
||||
testonly = testonly,
|
||||
deps = deps,
|
||||
node_modules = DEFAULT_TS_TYPINGS,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
# ivy_ng_module behaves like ng_module, and under --define=compile=legacy it runs ngc with global
|
||||
# analysis but produces Ivy outputs. Under other compile modes, it behaves as ng_module.
|
||||
# TODO(alxhub): remove when ngtsc supports the same use cases.
|
||||
def ivy_ng_module(name, tsconfig = None, entry_point = None, testonly = False, **kwargs):
|
||||
def ivy_ng_module(name, tsconfig = None, entry_point = None, testonly = False, deps = [], **kwargs):
|
||||
"""Default values for ivy_ng_module"""
|
||||
deps = deps + ["@ngdeps//tslib"]
|
||||
if testonly:
|
||||
# Match the types[] in //packages:tsconfig-test.json
|
||||
deps.append("@ngdeps//@types/jasmine")
|
||||
deps.append("@ngdeps//@types/node")
|
||||
if not tsconfig:
|
||||
if testonly:
|
||||
tsconfig = DEFAULT_TSCONFIG_TEST
|
||||
@ -70,24 +106,38 @@ def ivy_ng_module(name, tsconfig = None, entry_point = None, testonly = False, *
|
||||
tsconfig = DEFAULT_TSCONFIG_BUILD
|
||||
if not entry_point:
|
||||
entry_point = "public_api.ts"
|
||||
_internal_global_ng_module(name = name, flat_module_out_file = name, tsconfig = tsconfig, entry_point = entry_point, testonly = testonly, **kwargs)
|
||||
_internal_global_ng_module(
|
||||
name = name,
|
||||
flat_module_out_file = name,
|
||||
tsconfig = tsconfig,
|
||||
entry_point = entry_point,
|
||||
testonly = testonly,
|
||||
deps = deps,
|
||||
node_modules = DEFAULT_TS_TYPINGS,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def ng_package(name, node_modules = DEFAULT_NODE_MODULES, readme_md = None, license_banner = None, **kwargs):
|
||||
def ng_package(name, readme_md = None, license_banner = None, deps = [], **kwargs):
|
||||
"""Default values for ng_package"""
|
||||
if not readme_md:
|
||||
readme_md = "//packages:README.md"
|
||||
if not license_banner:
|
||||
license_banner = "//packages:license-banner.txt"
|
||||
deps = deps + [
|
||||
"@ngdeps//tslib",
|
||||
]
|
||||
|
||||
_ng_package(
|
||||
name = name,
|
||||
deps = deps,
|
||||
readme_md = readme_md,
|
||||
license_banner = license_banner,
|
||||
replacements = PKG_GROUP_REPLACEMENTS,
|
||||
node_modules = node_modules,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def npm_package(name, replacements = {}, **kwargs):
|
||||
"""Default values for npm_package"""
|
||||
_npm_package(
|
||||
name = name,
|
||||
replacements = dict(replacements, **PKG_GROUP_REPLACEMENTS),
|
||||
@ -95,10 +145,11 @@ def npm_package(name, replacements = {}, **kwargs):
|
||||
)
|
||||
|
||||
def ts_web_test_suite(bootstrap = [], deps = [], **kwargs):
|
||||
"""Default values for ts_web_test_suite"""
|
||||
if not bootstrap:
|
||||
bootstrap = ["//:web_test_bootstrap_scripts"]
|
||||
local_deps = [
|
||||
"@angular_deps//:node_modules/tslib/tslib.js",
|
||||
"@ngdeps//node_modules/tslib:tslib.js",
|
||||
"//tools/testing:browser",
|
||||
] + deps
|
||||
|
||||
@ -116,14 +167,44 @@ def ts_web_test_suite(bootstrap = [], deps = [], **kwargs):
|
||||
# "@io_bazel_rules_webtesting//browsers:firefox-local",
|
||||
# TODO(alexeagle): add remote browsers on SauceLabs
|
||||
],
|
||||
karma = DEFAULT_KARMA_BIN,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def nodejs_binary(node_modules = DEFAULT_NODE_MODULES, **kwargs):
|
||||
_nodejs_binary(node_modules = node_modules, **kwargs)
|
||||
def nodejs_binary(**kwargs):
|
||||
"""Default values for nodejs_binary"""
|
||||
_nodejs_binary(
|
||||
# Pass-thru --define=compile=foo as an environment variable
|
||||
configuration_env_vars = ["compile"],
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def jasmine_node_test(node_modules = DEFAULT_NODE_MODULES, **kwargs):
|
||||
_jasmine_node_test(node_modules = node_modules, **kwargs)
|
||||
def jasmine_node_test(deps = [], **kwargs):
|
||||
"""Default values for jasmine_node_test"""
|
||||
deps = deps + [
|
||||
# Very common dependencies for tests
|
||||
"@ngdeps//chokidar",
|
||||
"@ngdeps//domino",
|
||||
"@ngdeps//jasmine",
|
||||
"@ngdeps//jasmine-core",
|
||||
"@ngdeps//mock-fs",
|
||||
"@ngdeps//reflect-metadata",
|
||||
"@ngdeps//tslib",
|
||||
"@ngdeps//xhr2",
|
||||
]
|
||||
_jasmine_node_test(
|
||||
deps = deps,
|
||||
# Pass-thru --define=compile=foo as an environment variable
|
||||
configuration_env_vars = ["compile"],
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def ng_rollup_bundle(node_modules = DEFAULT_NODE_MODULES, **kwargs):
|
||||
_ng_rollup_bundle(node_modules = node_modules, **kwargs)
|
||||
def ng_rollup_bundle(deps = [], **kwargs):
|
||||
"""Default values for ng_rollup_bundle"""
|
||||
deps = deps + [
|
||||
"@ngdeps//tslib",
|
||||
]
|
||||
_ng_rollup_bundle(
|
||||
deps = deps,
|
||||
**kwargs
|
||||
)
|
||||
|
@ -15,259 +15,10 @@ def ng_setup_workspace():
|
||||
to build angular
|
||||
"""
|
||||
yarn_install(
|
||||
name = "angular_deps",
|
||||
name = "ngdeps",
|
||||
package_json = "@angular//:package.json",
|
||||
yarn_lock = "@angular//:yarn.lock",
|
||||
data = ["@angular//:tools/yarn/check-yarn.js", "@angular//:tools/postinstall-patches.js"],
|
||||
manual_build_file_contents = """package(default_visibility = ["//visibility:public"])
|
||||
filegroup(
|
||||
name = "node_modules",
|
||||
srcs = glob(["/".join([
|
||||
"node_modules",
|
||||
pkg,
|
||||
"**",
|
||||
ext,
|
||||
]) for pkg in [
|
||||
"adm-zip",
|
||||
"ajv",
|
||||
"angular",
|
||||
"angular-1.5",
|
||||
"angular-1.6",
|
||||
"angular-mocks",
|
||||
"angular-mocks-1.5",
|
||||
"angular-mocks-1.6",
|
||||
"anymatch",
|
||||
"arr-diff",
|
||||
"arr-flatten",
|
||||
"arr-union",
|
||||
"array-unique",
|
||||
"asn1",
|
||||
"assert-plus",
|
||||
"assign-symbols",
|
||||
"async-each",
|
||||
"asynckit",
|
||||
"atob",
|
||||
"aws-sign2",
|
||||
"aws4",
|
||||
"balanced-match",
|
||||
"base",
|
||||
"base64-js",
|
||||
"binary-extensions",
|
||||
"blocking-proxy",
|
||||
"brace-expansion",
|
||||
"braces",
|
||||
"bytebuffer",
|
||||
"cache-base",
|
||||
"camelcase",
|
||||
"canonical-path",
|
||||
"caseless",
|
||||
"chokidar",
|
||||
"class-utils",
|
||||
"co",
|
||||
"collection-visit",
|
||||
"convert-source-map",
|
||||
"combined-stream",
|
||||
"component-emitter",
|
||||
"concat-map",
|
||||
"copy-descriptor",
|
||||
"core-util-is",
|
||||
"debug",
|
||||
"decamelize",
|
||||
"decode-uri-component",
|
||||
"define-property",
|
||||
"delayed-stream",
|
||||
"dependency-graph",
|
||||
"domino",
|
||||
"error-ex",
|
||||
"expand-brackets",
|
||||
"expand-range",
|
||||
"extend",
|
||||
"extend-shallow",
|
||||
"extglob",
|
||||
"extsprintf",
|
||||
"fast-deep-equal",
|
||||
"fast-json-stable-stringify",
|
||||
"filename-regex",
|
||||
"fill-range",
|
||||
"find-up",
|
||||
"for-in",
|
||||
"for-own",
|
||||
"forever-agent",
|
||||
"form-data",
|
||||
"fragment-cache",
|
||||
"fs.realpath",
|
||||
"fs-extra",
|
||||
"get-caller-file",
|
||||
"get-value",
|
||||
"glob",
|
||||
"glob-base",
|
||||
"glob-parent",
|
||||
"graceful-fs",
|
||||
"hammerjs",
|
||||
"har-schema",
|
||||
"har-validator",
|
||||
"has-value",
|
||||
"has-values",
|
||||
"http-signature",
|
||||
"https-proxy-agent",
|
||||
"inflight",
|
||||
"inherits",
|
||||
"is-arrayish",
|
||||
"is-accessor-descriptor",
|
||||
"is-binary-path",
|
||||
"is-buffer",
|
||||
"is-data-descriptor",
|
||||
"is-descriptor",
|
||||
"is-dotfile",
|
||||
"is-equal-shallow",
|
||||
"is-extendable",
|
||||
"is-extglob",
|
||||
"is-glob",
|
||||
"is-number",
|
||||
"is-plain-object",
|
||||
"is-posix-bracket",
|
||||
"is-primitive",
|
||||
"is-typedarray",
|
||||
"is-windows",
|
||||
"isarray",
|
||||
"isobject",
|
||||
"isstream",
|
||||
"jasmine",
|
||||
"jasmine-core",
|
||||
"jasminewd2",
|
||||
"json-schema",
|
||||
"json-schema-traverse",
|
||||
"json-stable-stringify",
|
||||
"json-stringify-safe",
|
||||
"jsprim",
|
||||
"kind-of",
|
||||
"locate-path",
|
||||
"long",
|
||||
"lru-cache",
|
||||
"magic-string",
|
||||
"map-cache",
|
||||
"map-visit",
|
||||
"math-random",
|
||||
"micromatch",
|
||||
"mime-db",
|
||||
"mime-types",
|
||||
"minimatch",
|
||||
"minimist",
|
||||
"mixin-deep",
|
||||
"mock-fs",
|
||||
"node-uuid",
|
||||
"nanomatch",
|
||||
"normalize-path",
|
||||
"oauth-sign",
|
||||
"object.omit",
|
||||
"object.pick",
|
||||
"object-copy",
|
||||
"object-visit",
|
||||
"once",
|
||||
"optimist",
|
||||
"options",
|
||||
"os-locale",
|
||||
"os-tmpdir",
|
||||
"p-limit",
|
||||
"p-locate",
|
||||
"p-try",
|
||||
"parse-glob",
|
||||
"parse-json",
|
||||
"pascalcase",
|
||||
"path-dirname",
|
||||
"path-exists",
|
||||
"path-is-absolute",
|
||||
"performance-now",
|
||||
"pify",
|
||||
"posix-character-classes",
|
||||
"preserve",
|
||||
"process-nextick-args",
|
||||
"protobufjs",
|
||||
"protractor",
|
||||
"qs",
|
||||
"randomatic",
|
||||
"read-pkg-up",
|
||||
"readable-stream",
|
||||
"readdirp",
|
||||
"reflect-metadata",
|
||||
"regex-cache",
|
||||
"regex-not",
|
||||
"remove-trailing-separator",
|
||||
"repeat-element",
|
||||
"repeat-string",
|
||||
"request",
|
||||
"require-directory",
|
||||
"require-main-filename",
|
||||
"ret",
|
||||
"rimraf",
|
||||
"safe-buffer",
|
||||
"safe-regex",
|
||||
"safer-buffer",
|
||||
"sax",
|
||||
"selenium-webdriver",
|
||||
"semver",
|
||||
"set-blocking",
|
||||
"set-immediate-shim",
|
||||
"set-value",
|
||||
"shelljs",
|
||||
"sigmund",
|
||||
"snapdragon",
|
||||
"snapdragon-node",
|
||||
"snapdragon-util",
|
||||
"source-map",
|
||||
"source-map-resolve",
|
||||
"source-map-support",
|
||||
"source-map-url",
|
||||
"sourcemap-codec",
|
||||
"split-string",
|
||||
"sshpk",
|
||||
"static-extend",
|
||||
"stringstream",
|
||||
"strip-bom",
|
||||
"tmp",
|
||||
"to-object-path",
|
||||
"to-regex",
|
||||
"to-regex-range",
|
||||
"tough-cookie",
|
||||
"tsickle",
|
||||
"tslib",
|
||||
"tsutils",
|
||||
"tunnel-agent",
|
||||
"typescript",
|
||||
"union-value",
|
||||
"universalify",
|
||||
"unset-value",
|
||||
"upath",
|
||||
"uri-js",
|
||||
"urix",
|
||||
"use",
|
||||
"util-deprecate",
|
||||
"uuid",
|
||||
"verror",
|
||||
"webdriver-js-extender",
|
||||
"webdriver-manager",
|
||||
"wordwrap",
|
||||
"wrappy",
|
||||
"xhr2",
|
||||
"xml2js",
|
||||
"xmlbuilder",
|
||||
"y18n",
|
||||
"yargs",
|
||||
"yargs-parser",
|
||||
"zone.js",
|
||||
"@angular-devkit/core",
|
||||
"@angular-devkit/schematics",
|
||||
"@types",
|
||||
"@webcomponents/custom-elements",
|
||||
] for ext in [
|
||||
"*.js",
|
||||
"*.json",
|
||||
"*.d.ts",
|
||||
]] + [
|
||||
"node_modules/protractor/**",
|
||||
"node_modules/@schematics/angular/**",
|
||||
]))
|
||||
""",
|
||||
)
|
||||
|
||||
yarn_install(
|
||||
|
11
tools/npm/package.json
Normal file
11
tools/npm/package.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"description": "minimal @npm repo",
|
||||
"dependencies": {
|
||||
"@bazel/karma": "0.19.1",
|
||||
"@bazel/typescript": "0.19.1",
|
||||
"typescript": "~3.1.1"
|
||||
},
|
||||
"scripts": {
|
||||
"//": "TODO(gmagolan): figure out how to keep dependencies here up to date with the root package.json"
|
||||
}
|
||||
}
|
3186
tools/npm/yarn.lock
Normal file
3186
tools/npm/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -14,6 +14,7 @@ ts_library(
|
||||
),
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"@ngdeps//typescript",
|
||||
],
|
||||
)
|
||||
|
||||
@ -27,6 +28,7 @@ ts_library(
|
||||
deps = [
|
||||
":lib",
|
||||
"//packages:types",
|
||||
"@ngdeps//typescript",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -10,12 +10,10 @@
|
||||
# because it introduces an extra target_bin target.
|
||||
load("@build_bazel_rules_nodejs//internal/node:node.bzl", "nodejs_binary", "nodejs_test")
|
||||
|
||||
DEFAULT_NODE_MODULES = "@angular_deps//:node_modules"
|
||||
|
||||
def js_expected_symbol_test(name, src, golden, node_modules = DEFAULT_NODE_MODULES, **kwargs):
|
||||
def js_expected_symbol_test(name, src, golden, data = [], **kwargs):
|
||||
"""This test verifies that a set of top level symbols from a javascript file match a gold file.
|
||||
"""
|
||||
all_data = [src, golden]
|
||||
all_data = data + [src, golden]
|
||||
all_data += [Label("//tools/symbol-extractor:lib")]
|
||||
all_data += [Label("@bazel_tools//tools/bash/runfiles")]
|
||||
entry_point = "angular/tools/symbol-extractor/cli.js"
|
||||
@ -25,7 +23,6 @@ def js_expected_symbol_test(name, src, golden, node_modules = DEFAULT_NODE_MODUL
|
||||
data = all_data,
|
||||
entry_point = entry_point,
|
||||
templated_args = ["$(location %s)" % src, "$(location %s)" % golden],
|
||||
node_modules = node_modules,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@ -35,6 +32,5 @@ def js_expected_symbol_test(name, src, golden, node_modules = DEFAULT_NODE_MODUL
|
||||
data = all_data,
|
||||
entry_point = entry_point,
|
||||
templated_args = ["$(location %s)" % src, "$(location %s)" % golden, "--accept"],
|
||||
node_modules = node_modules,
|
||||
**kwargs
|
||||
)
|
||||
|
@ -28,5 +28,7 @@ ts_library(
|
||||
name = "node_no_angular",
|
||||
testonly = 1,
|
||||
srcs = ["init_node_no_angular_spec.ts"],
|
||||
deps = ["//packages:types"],
|
||||
deps = [
|
||||
"//packages:types",
|
||||
],
|
||||
)
|
||||
|
@ -12,6 +12,7 @@ exports_files(["bin/ts-api-guardian"])
|
||||
ts_library(
|
||||
name = "lib",
|
||||
srcs = glob(["lib/*.ts"]),
|
||||
compiler = "//:@bazel/typescript/tsc_wrapped",
|
||||
module_name = "ts-api-guardian",
|
||||
node_modules = "@ts-api-guardian_runtime_deps//:node_modules",
|
||||
tsconfig = "//tools:tsconfig.json",
|
||||
@ -47,8 +48,18 @@ ts_library(
|
||||
name = "test_lib",
|
||||
testonly = True,
|
||||
srcs = glob(["test/*.ts"]),
|
||||
tsconfig = "//tools:tsconfig.json",
|
||||
deps = [":lib"],
|
||||
compiler = "//:@bazel/typescript/tsc_wrapped",
|
||||
node_modules = "@ngdeps//typescript:typescript__typings",
|
||||
tsconfig = "//tools:tsconfig-test",
|
||||
deps = [
|
||||
":lib",
|
||||
"@ngdeps//@types/chai",
|
||||
"@ngdeps//@types/jasmine",
|
||||
"@ngdeps//@types/node",
|
||||
"@ngdeps//chai",
|
||||
"@ngdeps//jasmine",
|
||||
"@ngdeps//typescript",
|
||||
],
|
||||
)
|
||||
|
||||
jasmine_node_test(
|
||||
|
9
tools/tsconfig-test.json
Normal file
9
tools/tsconfig-test.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"types": [
|
||||
"node",
|
||||
"jasmine"
|
||||
]
|
||||
},
|
||||
}
|
@ -18,7 +18,10 @@
|
||||
"dom"
|
||||
],
|
||||
"target": "es5",
|
||||
"skipLibCheck": true
|
||||
"skipLibCheck": true,
|
||||
"types": [
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"exclude": [
|
||||
"testing",
|
||||
|
Reference in New Issue
Block a user