forked from google/incremental-dom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD
112 lines (96 loc) · 2.47 KB
/
BUILD
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package(default_visibility = ["//:__subpackages__"])
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver", "ts_library")
load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle")
### Produce umd and cjs bundles
ts_library(
name = "dev",
srcs = ["index.ts"],
deps = ["//src"],
tsickle_typed = True,
)
rollup_bundle(
name = "bundle",
entry_point = ":index.ts",
deps = [":dev"],
global_name = "IncrementalDOM",
license_banner = "conf/license_header.txt",
)
genrule(
name = "incremental-dom",
srcs = [":bundle.es5umd.js"],
outs = ["dist/incremental-dom.js"],
cmd = "cp $(locations :bundle.es5umd.js) $@",
)
npm_package(
name = "npm-umd",
deps = [
":incremental-dom",
],
replacements = {
"DEBUG" : "true"
}
)
genrule(
name = "incremental-dom-cjs",
srcs = [":bundle.cjs.js"],
outs = ["dist/incremental-dom-cjs.js"],
cmd = "cp $(locations :bundle.cjs.js) $@",
)
npm_package(
name = "npm-cjs",
deps = [
":incremental-dom-cjs",
],
replacements = {
"DEBUG" : "process.env.NODE_ENV != \"production\""
}
)
### Produce minified bundle
## Create a second index so that it can have a reference to the release/ directory.
## Using the same index.ts would cause issues with index.closure.js being created twice.
genrule(
name = "release_index",
srcs = ["index.ts"],
outs = ["release_index.ts"],
cmd = "cat $(location index.ts) | sed -e 's/src/release/g' > $@",
)
ts_library(
name = "release",
srcs = [":release_index"],
deps = ["//release"],
tsickle_typed = True,
)
rollup_bundle(
name = "min-bundle",
entry_point = ":release_index.ts",
deps = [":release"],
global_name = "IncrementalDOM",
license_banner = "conf/license_header.txt",
)
## Need to run uglify to minify instead of using .min.es5umd.js, since it uses
## Terser, which has some performance issues with the output in how it inlines
## functions.
genrule(
name = "incremental-dom-min",
srcs = [":min-bundle.es5umd.js"],
outs = ["dist/incremental-dom-min.js"],
cmd = "$(location node_modules/.bin/uglifyjs) --comments --source-map=url -m -o $@ $(location min-bundle.es5umd.js)",
tools = ["node_modules/.bin/uglifyjs"],
)
npm_package(
name = "npm-min",
deps = [
":incremental-dom-min",
],
)
### Emit TS files
npm_package(
name = "npm",
srcs = ["package.json", "index.ts", "//src:all_files"],
packages = [
":npm-min",
":npm-umd",
":npm-cjs",
]
)