build: language-service package built by bazel (#23155)
PR Close #23155
This commit is contained in:
parent
6dd8f6efe4
commit
6699fb5d77
|
@ -2,9 +2,9 @@ workspace(name = "angular")
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "build_bazel_rules_nodejs",
|
name = "build_bazel_rules_nodejs",
|
||||||
url = "https://github.com/bazelbuild/rules_nodejs/archive/cd368bd71a4b04fae0eafb5c5e2c906a93772584.zip",
|
url = "https://github.com/bazelbuild/rules_nodejs/archive/99166f8eb7fc628ca561acf9f9a51a1c26edadad.zip",
|
||||||
strip_prefix = "rules_nodejs-cd368bd71a4b04fae0eafb5c5e2c906a93772584",
|
strip_prefix = "rules_nodejs-99166f8eb7fc628ca561acf9f9a51a1c26edadad",
|
||||||
sha256 = "db74c61dd8bf73cc50aed56e78b7a8ad383f5869206901506cf8d3ee27f9277f",
|
sha256 = "338e8495e5d1fa16de7190106c5675372ff4a347f6004e203e84a168db96281e",
|
||||||
)
|
)
|
||||||
|
|
||||||
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install")
|
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install")
|
||||||
|
|
|
@ -51,6 +51,9 @@ def _ng_rollup_bundle(ctx):
|
||||||
run_uglify(ctx, ctx.outputs.build_es5, ctx.outputs.build_es5_min_debug,
|
run_uglify(ctx, ctx.outputs.build_es5, ctx.outputs.build_es5_min_debug,
|
||||||
debug = True, comments = False)
|
debug = True, comments = False)
|
||||||
|
|
||||||
|
umd_rollup_config = write_rollup_config(ctx, filename = "_%s_umd.rollup.conf.js", output_format = "umd")
|
||||||
|
run_rollup(ctx, collect_es2015_sources(ctx), umd_rollup_config, ctx.outputs.build_umd)
|
||||||
|
|
||||||
run_brotli(ctx, ctx.outputs.build_es5_min, ctx.outputs.build_es5_min_compressed)
|
run_brotli(ctx, ctx.outputs.build_es5_min, ctx.outputs.build_es5_min_compressed)
|
||||||
|
|
||||||
return DefaultInfo(files=depset([ctx.outputs.build_es5_min]))
|
return DefaultInfo(files=depset([ctx.outputs.build_es5_min]))
|
||||||
|
|
|
@ -23,8 +23,10 @@ npm_package(
|
||||||
name = "npm_package",
|
name = "npm_package",
|
||||||
srcs = ["package.json"],
|
srcs = ["package.json"],
|
||||||
tags = [
|
tags = [
|
||||||
# TODO(alexeagle): enable release after landing #23090
|
"release-with-framework",
|
||||||
# "release-with-framework",
|
],
|
||||||
|
deps = [
|
||||||
|
":language-service",
|
||||||
|
"//packages/language-service/bundles:language-service",
|
||||||
],
|
],
|
||||||
deps = [":language-service"],
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
load(":rollup.bzl", "ls_rollup_bundle")
|
||||||
|
|
||||||
|
ls_rollup_bundle(
|
||||||
|
name = "language-service",
|
||||||
|
entry_point = "packages/language-service/index.js",
|
||||||
|
globals = {
|
||||||
|
"typescript": "ts",
|
||||||
|
"path": "path",
|
||||||
|
"fs": "fs",
|
||||||
|
},
|
||||||
|
license_banner = "banner.js.txt",
|
||||||
|
visibility = ["//packages/language-service:__pkg__"],
|
||||||
|
deps = ["//packages/language-service"],
|
||||||
|
)
|
|
@ -0,0 +1,19 @@
|
||||||
|
/**
|
||||||
|
* @license Angular v0.0.0-PLACEHOLDER
|
||||||
|
* (c) 2010-2018 Google, Inc. https://angular.io/
|
||||||
|
* License: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $reflect = {defineMetadata: function() {}, getOwnMetadata: function(){}};
|
||||||
|
((typeof global !== 'undefined' && global)||{})['Reflect'] = $reflect;
|
||||||
|
var $deferred, $resolved, $provided;
|
||||||
|
function $getModule(name) { return $provided[name] || require(name); }
|
||||||
|
function define(modules, cb) { $deferred = { modules: modules, cb: cb }; }
|
||||||
|
module.exports = function(provided) {
|
||||||
|
if ($resolved) return $resolved;
|
||||||
|
var result = {};
|
||||||
|
$provided = Object.assign({'reflect-metadata': $reflect}, provided || {}, { exports: result });
|
||||||
|
$deferred.cb.apply(this, $deferred.modules.map($getModule));
|
||||||
|
$resolved = result;
|
||||||
|
return result;
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
"""Custom rollup_bundle for language service.
|
||||||
|
|
||||||
|
Overrides format to AMD and produces only umd and min, no FESM.
|
||||||
|
|
||||||
|
We do this so that we bundle all of the dependencies into the bundle
|
||||||
|
except for typescript, fs and path.
|
||||||
|
|
||||||
|
This allows editors and other tools to easily use the language service bundle
|
||||||
|
without having to provide all of the angular specific peer dependencies.
|
||||||
|
"""
|
||||||
|
|
||||||
|
load("@build_bazel_rules_nodejs//internal/rollup:rollup_bundle.bzl",
|
||||||
|
"ROLLUP_ATTRS",
|
||||||
|
"rollup_module_mappings_aspect",
|
||||||
|
"write_rollup_config",
|
||||||
|
"run_rollup",
|
||||||
|
"run_uglify"
|
||||||
|
)
|
||||||
|
load("//packages/bazel/src:esm5.bzl", "esm5_outputs_aspect", "flatten_esm5", "esm5_root_dir")
|
||||||
|
|
||||||
|
# Note: the file is called "umd.js" and "umd.min.js" because of historical
|
||||||
|
# reasons. The format is actually amd and not umd, but we are afraid to rename
|
||||||
|
# the file because that would likely break the IDE and other integrations that
|
||||||
|
# have the path hardcoded in them.
|
||||||
|
_ROLLUP_OUTPUTS = {
|
||||||
|
"build_umd": "%{name}.umd.js",
|
||||||
|
"build_umd_min": "%{name}.umd.min.js",
|
||||||
|
}
|
||||||
|
|
||||||
|
def _ls_rollup_bundle(ctx):
|
||||||
|
esm5_sources = flatten_esm5(ctx)
|
||||||
|
rollup_config = write_rollup_config(ctx,
|
||||||
|
root_dir = "/".join([ctx.bin_dir.path, ctx.label.package, esm5_root_dir(ctx)]),
|
||||||
|
output_format = "amd")
|
||||||
|
run_rollup(ctx, esm5_sources, rollup_config, ctx.outputs.build_umd)
|
||||||
|
source_map = run_uglify(ctx, ctx.outputs.build_umd, ctx.outputs.build_umd_min)
|
||||||
|
return DefaultInfo(files=depset([ctx.outputs.build_umd, ctx.outputs.build_umd_min, source_map]))
|
||||||
|
|
||||||
|
ls_rollup_bundle = rule(
|
||||||
|
implementation = _ls_rollup_bundle,
|
||||||
|
attrs = dict(ROLLUP_ATTRS, **{
|
||||||
|
"deps": attr.label_list(aspects = [
|
||||||
|
rollup_module_mappings_aspect,
|
||||||
|
esm5_outputs_aspect,
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
outputs = _ROLLUP_OUTPUTS,
|
||||||
|
)
|
|
@ -8,6 +8,3 @@ set -u -e -o pipefail
|
||||||
for p in $(bazel query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //...) intersect kind(".*_package", //...) except //dist/...'); do
|
for p in $(bazel query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //...) intersect kind(".*_package", //...) except //dist/...'); do
|
||||||
bazel run -- $p.publish --access public --tag next
|
bazel run -- $p.publish --access public --tag next
|
||||||
done
|
done
|
||||||
|
|
||||||
# TODO(alexeagle): publish everything from bazel and remove this
|
|
||||||
(cd dist/packages-dist; for p in language-service; do npm publish --access public --tag next $p; done)
|
|
||||||
|
|
Loading…
Reference in New Issue