Skip to content

Commit c0d20e0

Browse files
devversionalan-agius4
authored andcommitted
build: switch beasties bundling to rules_js
Switches the beasties bundling to `rules_js`, using rollup directly from the node modules installation. Notably we are facing a small issue that doesn't cause any issues right now, because rollup tries to dereference symlinks by default given a bug: aspect-build/rules_js#1827. This means we can't rely on the jailed resolution, but in practice it shouldn't cause an issue at this point.
1 parent 3194f56 commit c0d20e0

File tree

2 files changed

+20
-40
lines changed

2 files changed

+20
-40
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@aspect_rules_js//js:defs.bzl", "js_library")
2-
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
2+
load("@npm2//:rollup/package_json.bzl", rollup = "bin")
33

44
package(default_visibility = ["//visibility:public"])
55

@@ -16,52 +16,33 @@ js_library(
1616
js_library(
1717
name = "beasties_bundled",
1818
srcs = [
19-
":bundled_beasties_files",
20-
],
21-
deps = [
22-
"//:node_modules/beasties",
19+
":bundled_beasties",
2320
],
2421
)
2522

26-
# Filter out esbuild metadata files and only copy the necessary files
27-
genrule(
28-
name = "bundled_beasties_files",
23+
rollup.rollup(
24+
name = "bundled_beasties",
2925
srcs = [
30-
":bundled_beasties",
26+
"rollup.config.mjs",
27+
"//:node_modules/@rollup/plugin-alias",
28+
"//:node_modules/@rollup/plugin-commonjs",
29+
"//:node_modules/@rollup/plugin-node-resolve",
30+
"//:node_modules/beasties",
31+
"//:node_modules/rollup-license-plugin",
32+
"//:node_modules/unenv",
3133
],
3234
outs = [
35+
"THIRD_PARTY_LICENSES.txt",
3336
"index.js",
3437
"index.js.map",
35-
"THIRD_PARTY_LICENSES.txt",
3638
],
37-
cmd = """
38-
for f in $(locations :bundled_beasties); do
39-
# Only process files inside the bundled_beasties directory
40-
if [[ "$${f}" == *bundled_beasties ]]; then
41-
cp "$${f}/index.js" $(location :index.js)
42-
cp "$${f}/index.js.map" $(location :index.js.map)
43-
cp "$${f}/THIRD_PARTY_LICENSES.txt" $(location :THIRD_PARTY_LICENSES.txt)
44-
fi
45-
done
46-
""",
47-
)
48-
49-
rollup_bundle(
50-
name = "bundled_beasties",
51-
config_file = ":rollup.config.mjs",
52-
entry_points = {
53-
"@npm//:node_modules/beasties/dist/index.mjs": "index",
54-
},
55-
format = "esm",
56-
link_workspace_root = True,
57-
output_dir = True,
58-
sourcemap = "true",
59-
deps = [
60-
"@npm//@rollup/plugin-alias",
61-
"@npm//@rollup/plugin-commonjs",
62-
"@npm//@rollup/plugin-node-resolve",
63-
"@npm//beasties",
64-
"@npm//rollup-license-plugin",
65-
"@npm//unenv",
39+
args = [
40+
"--format=esm",
41+
"--config=$(rootpath rollup.config.mjs)",
42+
"--input=node_modules/beasties/dist/index.mjs",
43+
"--sourcemap=true",
44+
"--dir=packages/angular/ssr/third_party/beasties",
6645
],
46+
progress_message = "Bundling beasties",
47+
silent_on_success = False,
6748
)

packages/angular/ssr/third_party/beasties/rollup.config.mjs

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export default {
2828
nodeResolve({
2929
preferBuiltins: false,
3030
browser: true,
31-
jail: process.cwd(),
3231
}),
3332
commonjs(),
3433
alias({

0 commit comments

Comments
 (0)