forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnpm_package_archives.bzl
57 lines (55 loc) · 1.75 KB
/
npm_package_archives.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# The @npm packages at the root node_modules are used by integration tests
# with `file:../../node_modules/foobar` references
NPM_PACKAGE_ARCHIVES = [
"@angular/animations-12",
"@angular/common-12",
"@angular/core-12",
"@angular/forms-12",
"@angular/platform-browser-12",
"@angular/platform-browser-dynamic-12",
"@angular/platform-server-12",
"@angular/router-12",
"@babel/core",
"@rollup/plugin-babel",
"@rollup/plugin-node-resolve",
"@rollup/plugin-commonjs",
"check-side-effects",
"core-js",
"google-closure-compiler",
"jasmine",
"typescript",
"rxjs",
"systemjs",
"tsickle",
"tslib",
"protractor",
"terser",
"rollup",
"rollup-plugin-sourcemaps",
"@angular/cli",
"@angular-devkit/build-angular",
"@bazel/bazelisk",
"@types/jasmine",
"@types/jasminewd2",
"@types/node",
]
def npm_package_archive_label(package_name):
return package_name.replace("/", "_").replace("@", "") + "_archive"
def npm_package_archives():
"""Function to generate pkg_tar definitions for WORKSPACE yarn_install manual_build_file_contents"""
npm_packages_to_archive = NPM_PACKAGE_ARCHIVES
result = """load("@rules_pkg//:pkg.bzl", "pkg_tar")
"""
for name in npm_packages_to_archive:
label_name = npm_package_archive_label(name)
last_segment_name = name.split("/")[-1]
result += """pkg_tar(
name = "{label_name}",
srcs = ["//{name}:{last_segment_name}__all_files"],
extension = "tar.gz",
strip_prefix = "/external/npm/node_modules/{name}",
# should not be built unless it is a dependency of another rule
tags = ["manual"],
)
""".format(name = name, label_name = label_name, last_segment_name = last_segment_name)
return result