sourcegraph/client/web/dev/BUILD.bazel
Jean-Hadrien Chabran ff21dd3cc8
chore(local): hotfix when local client assets become too big (#63807)
Follow-up to
https://sourcegraph.slack.com/archives/C07KZF47K/p1720639713491779?thread_ts=1720636753.404169&cid=C07KZF47K

Basically, if we see that the local assets are above 500mb, we just nuke
it. It's a bandage btw. The `.gitkeep` is there so it doesn't break the
build because there's nothing to embed.

@eseliger and @burmudar can you test this a bit further and land it if
it's all good? My tests are good, but I don't want to hastily land
something and go in PTO five seconds before I'm out for two weeks.

## Test plan

Locally tested.

---------

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2024-07-18 14:20:39 +02:00

125 lines
3.4 KiB
Python

load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("//dev:defs.bzl", "ts_project", "vitest_test")
load("//dev:esbuild.bzl", "esbuild")
# dev/ does not contain a src/
# gazelle:js_files **/*.{ts,tsx}
# gazelle:exclude vitest.config.ts
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//client/web:tsconfig",
],
)
ts_project(
name = "dev",
srcs = [
"esbuild/build.ts",
"esbuild/chunkCleaner.ts",
"esbuild/config.ts",
"esbuild/manifestPlugin.ts",
"esbuild/server.ts",
"esbuild/webmanifest.ts",
"server/development.server.ts",
"server/production.server.ts",
"utils/constants.ts",
"utils/create-js-context.ts",
"utils/environment-config.ts",
"utils/get-api-proxy-settings.ts",
"utils/get-index-html.ts",
"utils/get-site-config.ts",
"utils/index.ts",
"utils/should-compress-response.ts",
"utils/success-banner.ts",
],
tags = [TAG_SEARCHSUITE],
tsconfig = ":tsconfig",
visibility = ["//client/web:__subpackages__"],
deps = [
"//:node_modules/@sentry/esbuild-plugin",
"//:node_modules/@types/compression",
"//:node_modules/@types/connect-history-api-fallback",
"//:node_modules/@types/express",
"//:node_modules/@types/lodash",
"//:node_modules/@types/signale",
"//:node_modules/chalk",
"//:node_modules/compression",
"//:node_modules/connect-history-api-fallback",
"//:node_modules/esbuild",
"//:node_modules/express",
"//:node_modules/express-static-gzip",
"//:node_modules/http-proxy-middleware",
"//:node_modules/jsonc-parser",
"//:node_modules/lodash",
"//:node_modules/signale",
"//client/web:node_modules/@sourcegraph/build-config",
"//client/web:node_modules/@sourcegraph/shared",
"//client/web:node_modules/@types/node",
"//client/web:web_lib",
],
)
js_library(
name = "esbuild-config-production",
srcs = ["esbuild/bazel/esbuild.bazel.production.js"],
deps = [
"//client/build-config:build-config_lib",
"//client/web:node_modules/@sourcegraph/build-config",
"//client/web/dev",
],
)
esbuild(
name = "esbuild-config-production_bundle",
srcs = [
":dev",
":esbuild-config-production",
],
entry_point = "esbuild/bazel/esbuild.bazel.production.js",
external = [
"fsevents",
"pnpapi",
"../../../../postcss.config",
# suppress esbuild require-resolve-not-external warnings
"esbuild",
"path-browserify",
"monaco-yaml/lib/esm/monaco.contribution",
"monaco-yaml/lib/esm/yaml.worker",
],
format = "cjs",
platform = "node",
sourcemap = False,
splitting = False,
target = "es2022",
visibility = ["//client:__subpackages__"],
deps = [
"//:postcss_config_js",
],
)
ts_project(
name = "dev_tests",
testonly = True,
srcs = ["esbuild/webmanifest.test.ts"],
tags = [TAG_SEARCHSUITE],
tsconfig = ":tsconfig",
deps = [
":dev",
"//:node_modules/vitest",
],
)
vitest_test(
name = "test",
data = [
":dev_tests",
],
tags = [TAG_SEARCHSUITE],
)