mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 13:11:49 +00:00
bazel - build client/common + client/extension-api-types (#45689)
* bazel: add aspect rules_ts,jest, upgrade rules_js, generate pnpm-lock.yaml * bazel: add initial typescript rules * bazel: build client/extension-api-types * bazel: build client/common
This commit is contained in:
parent
2cc83119fb
commit
fc1589106d
@ -0,0 +1,29 @@
|
||||
# Input hashes for repository rule npm_translate_lock(name = "npm", pnpm_lock = "//:pnpm-lock.yaml").
|
||||
# This file should be checked into version control along with the pnpm-lock.yaml file.
|
||||
.npmrc=2146577291
|
||||
pnpm-lock.yaml=-1331726396
|
||||
yarn.lock=132619263
|
||||
package.json=347261704
|
||||
client/branded/package.json=784076174
|
||||
client/browser/package.json=-2024393090
|
||||
client/build-config/package.json=-745736751
|
||||
client/client-api/package.json=704860991
|
||||
client/codeintellify/package.json=26663532
|
||||
client/common/package.json=762582044
|
||||
client/eslint-plugin-wildcard/package.json=721508932
|
||||
client/extension-api-types/package.json=-2002856453
|
||||
client/extension-api/package.json=-1763899027
|
||||
client/http-client/package.json=1413453754
|
||||
client/jetbrains/package.json=1441482894
|
||||
client/observability-client/package.json=-463261822
|
||||
client/observability-server/package.json=1984976913
|
||||
client/search-ui/package.json=-602996280
|
||||
client/search/package.json=-467983686
|
||||
client/shared/package.json=426064482
|
||||
client/storybook/package.json=-1924844575
|
||||
client/template-parser/package.json=-867948495
|
||||
client/web/package.json=-1637464847
|
||||
client/wildcard/package.json=362918481
|
||||
client/vscode/package.json=1345248728
|
||||
dev/release/package.json=1426426960
|
||||
pnpm-workspace.yaml=-842641978
|
||||
@ -1,5 +1,6 @@
|
||||
node_modules
|
||||
client/branded/node_modules
|
||||
client/browser/node_modules
|
||||
client/build-config/node_modules
|
||||
client/client-api/node_modules
|
||||
client/codeintellify/node_modules
|
||||
@ -18,5 +19,7 @@ client/storybook/node_modules
|
||||
client/template-parser/node_modules
|
||||
client/web/node_modules
|
||||
client/wildcard/node_modules
|
||||
client/vscode/node_modules
|
||||
dev/release/node_modules
|
||||
|
||||
cmd/symbols/squirrel/test_repos/starlark
|
||||
|
||||
20
BUILD.bazel
20
BUILD.bazel
@ -1,5 +1,15 @@
|
||||
load("@npm//:defs.bzl", "npm_link_all_packages")
|
||||
load("@aspect_rules_js//js:defs.bzl", "js_library")
|
||||
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
|
||||
|
||||
# Gazelle config
|
||||
#
|
||||
# gazelle:prefix github.com/sourcegraph/sourcegraph
|
||||
# gazelle:build_file_name BUILD.bazel
|
||||
|
||||
# Disable some by default, only include configured BUILDs
|
||||
#
|
||||
# gazelle:aspect_js disabled
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
@ -12,3 +22,13 @@ js_library(
|
||||
"//:node_modules/@sourcegraph/prettierrc",
|
||||
],
|
||||
)
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig",
|
||||
src = "tsconfig.bazel.json",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//:node_modules/@sourcegraph/tsconfig",
|
||||
"//:tsconfig.json",
|
||||
],
|
||||
)
|
||||
|
||||
62
WORKSPACE
62
WORKSPACE
@ -15,21 +15,32 @@ bazel_skylib_workspace()
|
||||
|
||||
http_archive(
|
||||
name = "aspect_rules_js",
|
||||
sha256 = "f58d7be1bb0e4b7edb7a0085f969900345f5914e4e647b4f0d2650d5252aa87d",
|
||||
strip_prefix = "rules_js-1.8.0",
|
||||
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v1.8.0.tar.gz",
|
||||
sha256 = "ad666b12324bab8bc151772bb2eff9aadace7bfd4d624157c2ac3931860d1c95",
|
||||
strip_prefix = "rules_js-1.11.1",
|
||||
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v1.11.1.tar.gz",
|
||||
)
|
||||
|
||||
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
|
||||
|
||||
rules_js_dependencies()
|
||||
|
||||
http_archive(
|
||||
name = "rules_nodejs",
|
||||
sha256 = "50adf0b0ff6fc77d6909a790df02eefbbb3bc2b154ece3406361dda49607a7bd",
|
||||
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.7.1/rules_nodejs-core-5.7.1.tar.gz"],
|
||||
sha256 = "08337d4fffc78f7fe648a93be12ea2fc4e8eb9795a4e6aa48595b66b34555626",
|
||||
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.0/rules_nodejs-core-5.8.0.tar.gz"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "aspect_rules_ts",
|
||||
sha256 = "e81f37c4fe014fc83229e619360d51bfd6cb8ac405a7e8018b4a362efa79d000",
|
||||
strip_prefix = "rules_ts-1.0.4",
|
||||
url = "https://github.com/aspect-build/rules_ts/archive/refs/tags/v1.0.4.tar.gz",
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "aspect_rules_jest",
|
||||
sha256 = "f2be891d9b38473f08a336e5f6ca327bfdc90411b1798a1c476c6f6ceae54520",
|
||||
strip_prefix = "rules_jest-0.13.1",
|
||||
url = "https://github.com/aspect-build/rules_jest/archive/refs/tags/v0.13.1.tar.gz",
|
||||
)
|
||||
|
||||
# Node toolchain setup ==========================
|
||||
load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
|
||||
|
||||
nodejs_register_toolchains(
|
||||
@ -37,13 +48,21 @@ nodejs_register_toolchains(
|
||||
node_version = DEFAULT_NODE_VERSION,
|
||||
)
|
||||
|
||||
# rules_js setup ================================
|
||||
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
|
||||
|
||||
rules_js_dependencies()
|
||||
|
||||
# rules_js npm setup ============================
|
||||
load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")
|
||||
|
||||
npm_translate_lock(
|
||||
name = "npm",
|
||||
data = [
|
||||
# TODO: can remove these package.json labels after switching to a pnpm lockfile.
|
||||
"//:package.json",
|
||||
"//:client/branded/package.json",
|
||||
"//:client/browser/package.json",
|
||||
"//:client/build-config/package.json",
|
||||
"//:client/client-api/package.json",
|
||||
"//:client/codeintellify/package.json",
|
||||
@ -62,14 +81,35 @@ npm_translate_lock(
|
||||
"//:client/template-parser/package.json",
|
||||
"//:client/web/package.json",
|
||||
"//:client/wildcard/package.json",
|
||||
"//:client/vscode/package.json",
|
||||
"//:dev/release/package.json",
|
||||
"//:pnpm-workspace.yaml",
|
||||
],
|
||||
npmrc = "//:.npmrc",
|
||||
package_json = "//:package.json", # TODO: not needed after switch to pnpm_lock
|
||||
pnpm_lock = "//:pnpm-lock.yaml",
|
||||
update_pnpm_lock = True,
|
||||
verify_node_modules_ignored = "//:.bazelignore",
|
||||
yarn_lock = "//:yarn.lock", # TODO: replace with pnpm_lock
|
||||
yarn_lock = "//:yarn.lock",
|
||||
)
|
||||
|
||||
# rules_ts npm setup ============================
|
||||
load("@npm//:repositories.bzl", "npm_repositories")
|
||||
|
||||
npm_repositories()
|
||||
|
||||
load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies", LATEST_TS_VERSION = "LATEST_VERSION")
|
||||
|
||||
rules_ts_dependencies(ts_version = LATEST_TS_VERSION)
|
||||
|
||||
# rules_jest setup ==============================
|
||||
load("@aspect_rules_jest//jest:dependencies.bzl", "rules_jest_dependencies")
|
||||
|
||||
rules_jest_dependencies()
|
||||
|
||||
load("@aspect_rules_jest//jest:repositories.bzl", "jest_repositories")
|
||||
|
||||
jest_repositories(name = "jest")
|
||||
|
||||
load("@jest//:npm_repositories.bzl", jest_npm_repositories = "npm_repositories")
|
||||
|
||||
jest_npm_repositories()
|
||||
|
||||
8
client/BUILD.bazel
Normal file
8
client/BUILD.bazel
Normal file
@ -0,0 +1,8 @@
|
||||
# Configure gazelle for client/*
|
||||
#
|
||||
# gazelle:aspect_js_srcs_file_glob src/**/*.{js,ts,tsx,jsx}
|
||||
# gazelle:aspect_js_tests_file_glob src/**/*.{spec,test,fixture}.{js,ts,tsx,jsx}
|
||||
# gazelle:map_kind ts_project ts_project //client/shared/dev:defaults.bzl
|
||||
|
||||
# TODO: will opt-in client/* projects one at a time, remove when done
|
||||
# gazelle:aspect_js disabled
|
||||
84
client/common/BUILD.bazel
Normal file
84
client/common/BUILD.bazel
Normal file
@ -0,0 +1,84 @@
|
||||
load("@npm//:defs.bzl", "npm_link_all_packages")
|
||||
load("//client/shared/dev:defaults.bzl", "ts_project")
|
||||
|
||||
# gazelle:aspect_js enabled
|
||||
|
||||
ts_project(
|
||||
name = "common",
|
||||
srcs = [
|
||||
"src/errors/constants.ts",
|
||||
"src/errors/errors.ts",
|
||||
"src/errors/index.ts",
|
||||
"src/errors/types.ts",
|
||||
"src/errors/utils.ts",
|
||||
"src/index.ts",
|
||||
"src/types/highlight.js/lib/core.d.ts",
|
||||
"src/types/highlightjs-graphql/index.d.ts",
|
||||
"src/types/index.ts",
|
||||
"src/types/utils.ts",
|
||||
"src/util/LocalStorageSubject.ts",
|
||||
"src/util/browserDetection.ts",
|
||||
"src/util/fetchCache.ts",
|
||||
"src/util/hashCode.ts",
|
||||
"src/util/highlightNode.ts",
|
||||
"src/util/index.ts",
|
||||
"src/util/isEncodedImage.ts",
|
||||
"src/util/jsonc.ts",
|
||||
"src/util/logger.ts",
|
||||
"src/util/markdown/contributions.ts",
|
||||
"src/util/markdown/index.ts",
|
||||
"src/util/markdown/markdown.ts",
|
||||
"src/util/rxjs/asObservable.ts",
|
||||
"src/util/rxjs/combineLatestOrDefault.ts",
|
||||
"src/util/rxjs/index.ts",
|
||||
"src/util/rxjs/memoizeObservable.ts",
|
||||
"src/util/rxjs/repeatUntil.ts",
|
||||
"src/util/strings.ts",
|
||||
"src/util/types.ts",
|
||||
"src/util/url.ts",
|
||||
],
|
||||
deps = [
|
||||
"//:node_modules/@sourcegraph/extension-api-types", #keep
|
||||
"//:node_modules/@types/highlight.js",
|
||||
"//:node_modules/@types/lodash",
|
||||
"//:node_modules/@types/marked",
|
||||
"//:node_modules/@types/node", #keep
|
||||
"//:node_modules/@types/sanitize-html",
|
||||
"//:node_modules/highlight.js",
|
||||
"//:node_modules/highlightjs-graphql",
|
||||
"//:node_modules/jsonc-parser",
|
||||
"//:node_modules/lodash",
|
||||
"//:node_modules/marked",
|
||||
"//:node_modules/rxjs",
|
||||
"//:node_modules/sanitize-html",
|
||||
"//:node_modules/utility-types", #keep
|
||||
],
|
||||
)
|
||||
|
||||
ts_project(
|
||||
name = "common_tests",
|
||||
srcs = [
|
||||
"src/errors/errors.test.ts",
|
||||
"src/util/fetchCache.test.ts",
|
||||
"src/util/hashCode.test.ts",
|
||||
"src/util/highlightNode.test.ts",
|
||||
"src/util/jsonc.test.ts",
|
||||
"src/util/markdown/markdown.test.ts",
|
||||
"src/util/rxjs/asObservable.test.ts",
|
||||
"src/util/rxjs/combineLatestOrDefault.test.ts",
|
||||
"src/util/rxjs/repeatUntil.test.ts",
|
||||
"src/util/string.test.ts",
|
||||
"src/util/url.test.ts",
|
||||
],
|
||||
deps = [
|
||||
":common",
|
||||
"//:node_modules/@types/jest", #keep
|
||||
"//:node_modules/@types/mockdate",
|
||||
"//:node_modules/@types/node",
|
||||
"//:node_modules/jest-fetch-mock",
|
||||
"//:node_modules/mockdate",
|
||||
"//:node_modules/rxjs",
|
||||
],
|
||||
)
|
||||
|
||||
npm_link_all_packages(name = "node_modules")
|
||||
8
client/extension-api-types/BUILD.bazel
Normal file
8
client/extension-api-types/BUILD.bazel
Normal file
@ -0,0 +1,8 @@
|
||||
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
npm_package(
|
||||
name = "extension-api-types",
|
||||
srcs = ["package.json"] + glob(["src/**/*.d.ts"]),
|
||||
)
|
||||
11
client/extension-api/BUILD.bazel
Normal file
11
client/extension-api/BUILD.bazel
Normal file
@ -0,0 +1,11 @@
|
||||
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
npm_package(
|
||||
name = "extension-api",
|
||||
srcs = ["package.json"] + glob([
|
||||
"src/**/*.js",
|
||||
"src/**/*.d.ts",
|
||||
]),
|
||||
)
|
||||
@ -1,5 +1,7 @@
|
||||
load("@aspect_rules_js//js:defs.bzl", "js_binary")
|
||||
|
||||
# gazelle:exclude .
|
||||
|
||||
js_binary(
|
||||
name = "generate_graphql_schema",
|
||||
data = [
|
||||
|
||||
23
client/shared/dev/defaults.bzl
Normal file
23
client/shared/dev/defaults.bzl
Normal file
@ -0,0 +1,23 @@
|
||||
load("@aspect_rules_ts//ts:defs.bzl", _ts_project = "ts_project")
|
||||
|
||||
def ts_project(name, deps = [], **kwargs):
|
||||
deps = deps + [
|
||||
"//:node_modules/tslib",
|
||||
]
|
||||
|
||||
"""Default arguments for ts_project."""
|
||||
_ts_project(
|
||||
name = name,
|
||||
deps = deps,
|
||||
|
||||
# tsconfig options
|
||||
tsconfig = "//:tsconfig",
|
||||
composite = True,
|
||||
declaration = True,
|
||||
declaration_map = True,
|
||||
resolve_json_module = True,
|
||||
source_map = True,
|
||||
|
||||
# Allow any other args
|
||||
**kwargs
|
||||
)
|
||||
@ -368,6 +368,7 @@
|
||||
"@react-aria/live-announcer": "^3.1.0",
|
||||
"@sentry/browser": "^7.8.1",
|
||||
"@sourcegraph/extension-api-classes": "^1.1.0",
|
||||
"@sourcegraph/extension-api-types": "workspace:*",
|
||||
"@storybook/addon-controls": "^6.5.14",
|
||||
"@storybook/addon-knobs": "^6.4.0",
|
||||
"@visx/annotation": "^2.10.0",
|
||||
@ -449,6 +450,7 @@
|
||||
"rxjs": "^6.6.3",
|
||||
"sanitize-html": "^2.0.0",
|
||||
"semver": "^7.3.2",
|
||||
"sourcegraph": "workspace:*",
|
||||
"stream-http": "^3.2.0",
|
||||
"string-score": "^1.0.1",
|
||||
"tabbable": "^5.1.5",
|
||||
|
||||
26967
pnpm-lock.yaml
Normal file
26967
pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load Diff
5
tsconfig.bazel.json
Normal file
5
tsconfig.bazel.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["**/*"],
|
||||
"exclude": []
|
||||
}
|
||||
@ -5237,7 +5237,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@sourcegraph/extension-api-types@^2.1.0, @sourcegraph/extension-api-types@workspace:client/extension-api-types":
|
||||
"@sourcegraph/extension-api-types@^2.1.0, @sourcegraph/extension-api-types@workspace:*, @sourcegraph/extension-api-types@workspace:client/extension-api-types":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@sourcegraph/extension-api-types@workspace:client/extension-api-types"
|
||||
peerDependencies:
|
||||
@ -27306,6 +27306,7 @@ __metadata:
|
||||
"@sourcegraph/eslint-plugin-sourcegraph": ^1.0.5
|
||||
"@sourcegraph/extension-api-classes": ^1.1.0
|
||||
"@sourcegraph/extension-api-stubs": ^1.6.1
|
||||
"@sourcegraph/extension-api-types": "workspace:*"
|
||||
"@sourcegraph/prettierrc": ^3.0.3
|
||||
"@sourcegraph/stylelint-config": ^1.4.0
|
||||
"@sourcegraph/stylelint-plugin-sourcegraph": ^1.0.1
|
||||
@ -27572,6 +27573,7 @@ __metadata:
|
||||
sinon: ^9.0.2
|
||||
socket.io: ^4.5.2
|
||||
socket.io-client: ^4.5.2
|
||||
sourcegraph: "workspace:*"
|
||||
speed-measure-webpack-plugin: ^1.5.0
|
||||
storybook-addon-designs: ^6.3.1
|
||||
storybook-dark-mode: ^2.0.4
|
||||
@ -28590,7 +28592,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"sourcegraph@^25.5.0, sourcegraph@workspace:client/extension-api":
|
||||
"sourcegraph@^25.5.0, sourcegraph@workspace:*, sourcegraph@workspace:client/extension-api":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "sourcegraph@workspace:client/extension-api"
|
||||
dependencies:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user