Skip to content

Commit 0308bf2

Browse files
committed
test: container wrapping binary built with optional deps
1 parent d670621 commit 0308bf2

9 files changed

Lines changed: 2848 additions & 2723 deletions

File tree

.aspect/rules/external_repository_action_cache/npm_translate_lock_LTE4Nzc1MDcwNjU=

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ js/private/worker/src/package.json=1787033725
3232
npm/private/lifecycle/package.json=804720835
3333
npm/private/test/npm_package/package.json=-1991705133
3434
npm/private/test/npm_package_publish/package.json=1501316979
35-
npm/private/test/package.json=550137760
35+
npm/private/test/package.json=32523622
3636
npm/private/test/subs/package.json=-897547334
3737
npm/private/test/vendored/is-odd/package.json=1041695223
3838
npm/private/test/vendored/lodash-4.17.21.tgz=-1206623349
3939
npm/private/test/vendored/semver-max/package.json=578664053
4040
package.json=1856600154
41-
pnpm-lock.yaml=-1083936682
41+
pnpm-lock.yaml=-299891068
4242
pnpm-workspace.yaml=2041973211

MODULE.bazel

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,6 @@ npm.npm_translate_lock(
243243
"no-sandbox",
244244
"requires-network",
245245
],
246-
"esbuild": [
247-
"no-sandbox",
248-
"requires-network",
249-
],
250246
"segfault-handler": [
251247
"no-sandbox",
252248
"requires-network",

npm/private/test/BUILD.bazel

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@aspect_rules_js//js:defs.bzl", "js_test")
1+
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_image_layer", "js_run_binary", "js_test")
22
load("@bazel_lib//lib:write_source_files.bzl", "write_source_files")
33
load("@bazel_skylib//rules:build_test.bzl", "build_test")
44
load("@npm//:defs.bzl", "npm_link_all_packages")
@@ -120,3 +120,89 @@ js_test(
120120
data = [":node_modules"],
121121
entry_point = "versions.js",
122122
)
123+
124+
# A node binary indirectly depending on a platform specific optional npm package
125+
js_binary(
126+
name = "esbuild_entry",
127+
testonly = True,
128+
data = [":node_modules/esbuild"],
129+
entry_point = "esbuild.js",
130+
)
131+
132+
# Use a node binary consuming an optional npm package to build a file
133+
js_run_binary(
134+
name = "versions_esbundled",
135+
testonly = True,
136+
srcs = [
137+
"versions.js",
138+
":node_modules/lodash",
139+
":node_modules/lodash-4.17.21",
140+
":node_modules/lodash-4.17.21-tar",
141+
],
142+
outs = ["versions_bundled_out.js"],
143+
args = [
144+
"$(location versions.js)",
145+
package_name() + "/versions_bundled_out.js",
146+
],
147+
tool = ":esbuild_entry",
148+
)
149+
150+
# A test simply running the compiled bundle
151+
js_test(
152+
name = "esbuilt_binary_test",
153+
entry_point = "versions_bundled_out.js",
154+
)
155+
156+
# A binary version of the compiled bundle
157+
js_binary(
158+
name = "esbuilt_binary",
159+
testonly = True,
160+
entry_point = "versions_bundled_out.js",
161+
)
162+
163+
platform(
164+
name = "amd64_linux",
165+
constraint_values = [
166+
"@platforms//os:linux",
167+
"@platforms//cpu:x86_64",
168+
],
169+
)
170+
171+
platform(
172+
name = "amd64_macos",
173+
constraint_values = [
174+
"@platforms//os:macos",
175+
"@platforms//cpu:x86_64",
176+
],
177+
)
178+
179+
# The compiled bundle in a platform specific container image layer
180+
js_image_layer(
181+
name = "esbuilt_binary_image_linux",
182+
testonly = True,
183+
binary = ":esbuilt_binary",
184+
platform = ":amd64_linux",
185+
)
186+
187+
js_image_layer(
188+
name = "esbuilt_binary_image_macos",
189+
testonly = True,
190+
binary = ":esbuilt_binary",
191+
platform = ":amd64_macos",
192+
)
193+
194+
build_test(
195+
name = "esbuild_test",
196+
targets = [
197+
# The esbuild npm package including lifecycle hooks to verify platform deps
198+
":node_modules/esbuild",
199+
200+
# The bundle target and its output which required running esbuild
201+
":versions_esbundled",
202+
"versions_bundled_out.js",
203+
204+
# Transitioned images using the bundle. Should still consume the original esbuild binary.
205+
":esbuilt_binary_image_linux",
206+
":esbuilt_binary_image_macos",
207+
],
208+
)

npm/private/test/esbuild.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// A simple wrapper around esbuild accepting 1 input file and 2 output file argument.
2+
3+
const [, , input, output] = process.argv
4+
5+
console.error('[ESBUILD] ', input, ' -> ', output)
6+
7+
require('esbuild')
8+
.build({
9+
entryPoints: [input],
10+
outfile: output,
11+
bundle: true,
12+
platform: 'node',
13+
target: 'node14',
14+
})
15+
.catch(() => process.exit(1))

npm/private/test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@plotly/regl": "2.1.2",
1616
"bufferutil": "4.0.8",
1717
"debug": "ngokevin/debug#9742c5f383a6f8046241920156236ade8ec30d53",
18-
"esbuild": "0.24.0",
18+
"esbuild": "0.27.3",
1919
"handlebars-helpers/helper-date": "github:coda/helper-date#a2cb4284148cbba7d36173dff4c7c60ce59eae55",
2020
"hot-shots": "10.0.0",
2121
"inline-fixtures": "https://registry.yarnpkg.com/inline-fixtures/-/inline-fixtures-1.1.0.tgz#5f9edf644ac02a1322012dbbb9f0a4739831d662",

npm/private/test/snapshots/npm_defs-no_dev.bzl

Lines changed: 1235 additions & 1231 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npm/private/test/snapshots/npm_defs-no_optional.bzl

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)