bazel: add bazel build,tests for client/* (#46193)

Webpack bundles compile but need further testing. Jest + mocha tests
compile but are marked as `manual` until further work is done to get them
passing. The four jest tests are green and enabled now, though.

## Test plan

`bazel build //client/...` and `bazel test //client/...`
This commit is contained in:
Jason Bedard 2023-02-28 20:46:03 -08:00 committed by GitHub
parent cd44ce427b
commit 10aefc4bb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
69 changed files with 6389 additions and 227 deletions

View File

@ -1,9 +1,9 @@
# 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=1671875644
yarn.lock=1326043358
package.json=-1843989810
pnpm-lock.yaml=-1725146382
yarn.lock=73545660
package.json=2077506699
client/branded/package.json=784076174
client/browser/package.json=-2024393090
client/build-config/package.json=-745736751
@ -26,4 +26,4 @@ client/web/package.json=-1637464847
client/wildcard/package.json=362918481
client/vscode/package.json=1345248728
dev/release/package.json=1426426960
pnpm-workspace.yaml=-1949047588
pnpm-workspace.yaml=-69372893

View File

@ -14,6 +14,7 @@ client/http-client/node_modules
client/jetbrains/node_modules
client/observability-client/node_modules
client/observability-server/node_modules
client/plugin-backstage/node_modules
client/shared/node_modules
client/storybook/node_modules
client/template-parser/node_modules

View File

@ -1,12 +1,15 @@
const IS_BAZEL = !!(process.env.BAZEL_BINDIR || process.env.BAZEL_TEST)
const rootDir = IS_BAZEL ? process.cwd() : __dirname
module.exports = {
require: [
'ts-node/register/transpile-only',
...(IS_BAZEL ? [] : ['ts-node/register/transpile-only']),
'abort-controller/polyfill',
__dirname + '/client/shared/dev/fetch',
__dirname + '/client/shared/dev/suppressPollyErrors',
rootDir + '/client/shared/dev/fetch',
rootDir + '/client/shared/dev/suppressPollyErrors',
],
reporter: __dirname + '/client/shared/dev/customMochaSpecReporter.js',
extension: ['js', 'ts'],
reporter: rootDir + '/client/shared/dev/customMochaSpecReporter.js',
extension: IS_BAZEL ? ['js'] : ['js', 'ts'],
// 1 minute test timeout. This must be greater than the default Puppeteer
// command timeout of 30s in order to get the stack trace to point to the
// Puppeteer command that failed instead of a cryptic test timeout

View File

@ -1,7 +1,8 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@npm//:defs.bzl", "npm_link_all_packages")
# Gazelle config
#
@ -9,7 +10,11 @@ load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
# gazelle:build_file_name BUILD.bazel
# Disable some by default, only include configured BUILDs
#
# gazelle:aspect_js disabled
# gazelle:js disabled
# gazelle:js_npm_package_target_name {dirname}_pkg
# Enable only the Aspect javascript plugin for gazelle
# gazelle:lang js
package(default_visibility = ["//visibility:public"])
@ -25,11 +30,10 @@ js_library(
ts_config(
name = "tsconfig",
src = "tsconfig.bazel.json",
src = "tsconfig.base.json",
visibility = ["//visibility:public"],
deps = [
"//:node_modules/@sourcegraph/tsconfig",
"//:tsconfig.base.json",
],
)
@ -109,4 +113,86 @@ js_library(
],
)
copy_to_bin(
name = "browserslist",
srcs = [".browserslistrc"],
visibility = ["//visibility:public"],
)
copy_to_bin(
name = "package_json",
srcs = ["package.json"],
visibility = ["//visibility:public"],
)
js_library(
name = "jest_config",
testonly = True,
srcs = [
"jest.config.base.js",
],
data = [
"jest.snapshot-resolver.js",
],
visibility = ["//visibility:public"],
deps = [
":babel_config_jest",
"//:node_modules/@testing-library/jest-dom",
"//:node_modules/abort-controller",
"//:node_modules/babel-jest",
"//:node_modules/core-js",
"//:node_modules/identity-obj-proxy",
"//:node_modules/regenerator-runtime",
"//client/shared/dev:mock",
],
)
js_library(
name = "babel_config_jest",
testonly = True,
srcs = [
"babel.config.jest.js",
],
visibility = ["//visibility:public"],
deps = [
"//:node_modules/@babel/preset-env",
"//:node_modules/signale",
],
)
js_library(
name = "babel_config",
srcs = [
"babel.config.js",
],
data = [
":package_json",
],
visibility = ["//visibility:public"],
deps = [
"//:node_modules/@babel/plugin-transform-typescript",
"//:node_modules/@babel/preset-env",
"//:node_modules/@babel/preset-react",
"//:node_modules/@babel/preset-typescript",
"//:node_modules/babel-plugin-lodash",
"//:node_modules/babel-plugin-webpack-chunkname",
"//:node_modules/semver",
"//:node_modules/signale",
],
)
js_library(
name = "mocha_config",
testonly = True,
srcs = [
".mocharc.js",
],
deps = [
"//:node_modules/abort-controller",
"//client/shared/dev:fetch-mock",
"//client/shared/dev:mocha-reporter",
"//client/shared/dev:suppress-polly-errors",
],
)
exports_files(["go.mod"])

View File

@ -101,6 +101,7 @@ load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")
npm_translate_lock(
name = "npm",
npm_package_target_name = "{dirname}_pkg",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
@ -131,6 +132,46 @@ load("@jest//:npm_repositories.bzl", jest_npm_repositories = "npm_repositories")
jest_npm_repositories()
# rules_esbuild setup ===========================
http_archive(
name = "aspect_rules_esbuild",
sha256 = "621c8ccb8a1400951c52357377eda4c575c6c901689bb629969881e0be8a8614",
strip_prefix = "rules_esbuild-175023fede7d2532dd35d89cb43b43cbe9e75678",
url = "https://github.com/aspect-build/rules_esbuild/archive/175023fede7d2532dd35d89cb43b43cbe9e75678.tar.gz",
)
load("@aspect_rules_esbuild//esbuild:dependencies.bzl", "rules_esbuild_dependencies")
rules_esbuild_dependencies()
# Register a toolchain containing esbuild npm package and native bindings
load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_VERSION", "esbuild_register_toolchains")
esbuild_register_toolchains(
name = "esbuild",
esbuild_version = LATEST_VERSION,
)
# rules_webpack setup ===========================
http_archive(
name = "aspect_rules_webpack",
sha256 = "4f30fb310d625a4045e37b9e04afb2366c56b547a73c935f308e3d9c31b77519",
strip_prefix = "rules_webpack-0.9.1",
url = "https://github.com/aspect-build/rules_webpack/releases/download/v0.9.1/rules_webpack-v0.9.1.tar.gz",
)
load("@aspect_rules_webpack//webpack:dependencies.bzl", "rules_webpack_dependencies")
rules_webpack_dependencies()
load("@aspect_rules_webpack//webpack:repositories.bzl", "webpack_repositories")
webpack_repositories(name = "webpack")
load("@webpack//:npm_repositories.bzl", webpack_npm_repositories = "npm_repositories")
webpack_npm_repositories()
# Go toolchain setup
load("@rules_buf//buf:repositories.bzl", "rules_buf_dependencies", "rules_buf_toolchains")

35
babel.config.jest.js Normal file
View File

@ -0,0 +1,35 @@
// @ts-check
const path = require('path')
// A minimal babel config only for jest transformations.
// All typescript and react transformations are done by previous
// bazel build rules, so we only need to do jest transformations here.
const logger = require('signale')
// TODO(bazel): drop when non-bazel removed.
if (!(process.env.BAZEL_BINDIR || process.env.BAZEL_TEST)) {
throw new Error(__filename + ' is only for use with Bazel')
}
/** @type {import('@babel/core').ConfigFunction} */
module.exports = api => {
api.cache.forever()
/**
* Whether to instrument files with istanbul for code coverage.
* This is needed for e2e test coverage.
*/
const instrument = Boolean(process.env.COVERAGE_INSTRUMENT && JSON.parse(process.env.COVERAGE_INSTRUMENT))
if (instrument) {
logger.info('Instrumenting code for coverage tracking')
}
return {
presets: [
// Can't put this in plugins because it needs to run as the last plugin.
...(instrument ? [{ plugins: [['babel-plugin-istanbul', { cwd: path.resolve(__dirname) }]] }] : []),
'@babel/preset-env',
],
}
}

View File

@ -26,7 +26,7 @@ module.exports = api => {
'@babel/preset-env',
{
// Node (used for testing) doesn't support modules, so compile to CommonJS for testing.
modules: isTest ? 'commonjs' : false,
modules: process.env.BABEL_MODULE ?? (isTest ? 'commonjs' : false),
bugfixes: true,
useBuiltIns: 'entry',
include: [

View File

@ -1,8 +1,27 @@
# 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 //dev:defs.bzl
# TODO: will opt-in client/* projects one at a time, remove when done
# gazelle:aspect_js disabled
# Source files:
# gazelle:js_files src/**/*.{ts,tsx}
# gazelle:js_files globals.d.ts
# Test files, snapshots etc:
# gazelle:js_test_files **/*.{spec,test}.{ts,tsx}
# gazelle:js_test_files **/mock*.{ts,tsx}
# gazelle:js_test_files **/mocks/**
# gazelle:js_test_files **/testutils/**
# gazelle:js_test_files **/tests/**
# gazelle:js_test_files **/__mocks__/**/*.{ts,tsx}
# gazelle:js_test_files **/fixtures/**/*.{ts,tsx}
# TODO(bazel): put fixtures + testutils + ? into own rules
# js_{fixture}_files **/*.{fixture,fixtures}.{ts,tsx}
# js_{fixture}_files **/testutils/**
# js_{fixture}_files **/fixtures.{ts,tsx}
# Rule configuration:
# gazelle:map_kind ts_project ts_project //dev:defs.bzl
# gazelle:map_kind npm_package npm_package //dev:defs.bzl
# Enable JS generation throughout client/*
# gazelle:js enabled
# gazelle:js_generation_mode none

View File

@ -0,0 +1,40 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "ts_project")
npm_link_all_packages(name = "node_modules")
ts_project(
name = "backstage-backend",
srcs = [
"src/client/Query.ts",
"src/client/SourcegraphClient.ts",
"src/client/index.ts",
"src/index.ts",
"src/providers/index.ts",
"src/providers/parsers.ts",
"src/providers/providers.ts",
"src/setupTests.ts",
],
deps = [
":node_modules/@backstage/catalog-model",
":node_modules/@backstage/plugin-catalog-backend",
":node_modules/@sourcegraph/http-client",
":node_modules/@sourcegraph/shared",
"//:node_modules/@apollo/client",
],
)
ts_project(
name = "backstage-backend_tests",
testonly = True,
srcs = [
"src/client/Query.test.ts",
"src/client/SourcegraphClient.test.ts",
"src/tests/integration/e2e.test.ts",
],
deps = [
":backstage-backend",
":node_modules/@jest/globals",
"//:node_modules/@apollo/client",
],
)

View File

@ -31,6 +31,7 @@ async function build(): Promise<void> {
'winston',
],
// If we don't specify module first, esbuild bundles somethings "incorrectly" and you'll get a error with './impl/format' error
// Most likely due to https://github.com/evanw/esbuild/issues/1619#issuecomment-922787629
mainFields: ['module', 'main'],
format: 'cjs',
platform: 'node',

View File

@ -0,0 +1,61 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "ts_project")
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/build-config:tsconfig",
],
)
ts_project(
name = "backstage-frontend",
srcs = [
"src/components/ExampleComponent/ExampleComponent.tsx",
"src/components/ExampleComponent/index.ts",
"src/components/ExampleFetchComponent/ExampleFetchComponent.tsx",
"src/components/ExampleFetchComponent/index.ts",
"src/index.ts",
"src/plugin.ts",
"src/routes.ts",
"src/setupTests.ts",
],
tsconfig = ":tsconfig",
deps = [
":node_modules/@backstage/core-components",
":node_modules/@backstage/core-plugin-api",
":node_modules/@material-ui/core",
":node_modules/@material-ui/lab",
":node_modules/@testing-library/jest-dom",
":node_modules/cross-fetch",
":node_modules/react",
":node_modules/react-use",
"//:node_modules/@types/react", #keep
"//:node_modules/@types/testing-library__jest-dom",
],
)
ts_project(
name = "backstage-frontend_tests",
testonly = True,
srcs = [
"src/components/ExampleComponent/ExampleComponent.test.tsx",
"src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx",
"src/plugin.test.ts",
],
tsconfig = ":tsconfig",
deps = [
":backstage-frontend",
":node_modules/@backstage/test-utils",
":node_modules/@testing-library/react",
":node_modules/msw",
":node_modules/react",
"//:node_modules/@types/react",
],
)

View File

@ -1,5 +1,32 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "jest_test", "npm_package", "sass", "ts_project")
load("//client/shared/dev:tools.bzl", "module_style_typings")
load("//dev:defs.bzl", "sass")
# TODO(bazel): storybook build
# gazelle:exclude **/*.story.{ts,tsx}
# gazelle:js_resolve **/*.module.scss :module_style_typings
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/client-api:tsconfig",
"//client/codeintellify:tsconfig",
"//client/common:tsconfig",
"//client/extension-api-types:tsconfig",
"//client/observability-client:tsconfig",
"//client/shared:tsconfig",
"//client/testing:tsconfig",
"//client/wildcard:tsconfig",
],
)
module_style_typings(
name = "module_style_typings",
@ -11,3 +38,225 @@ sass(
srcs = glob(["src/**/*.module.scss"]),
deps = ["//client/wildcard:sass-breakpoints"],
)
ts_project(
name = "branded_lib",
srcs = [
"src/components/CodeSnippet.tsx",
"src/components/DownloadSourcegraphIcon.tsx",
"src/components/SourcegraphLogo.tsx",
"src/components/Timestamp/Timestamp.tsx",
"src/components/Timestamp/index.ts",
"src/components/Toggle.tsx",
"src/components/ToggleBig.tsx",
"src/components/constants.ts",
"src/components/panel/MixPreciseAndSearchBasedReferencesToggle.tsx",
"src/components/panel/TabbedPanelContent.fixtures.ts",
"src/components/panel/TabbedPanelContent.tsx",
"src/components/panel/views/EmptyPanelView.tsx",
"src/components/panel/views/ExtensionsLoadingView.tsx",
"src/components/panel/views/FileLocations.tsx",
"src/components/panel/views/PanelContent.tsx",
"src/components/panel/views/locations.ts",
"src/globals.d.ts",
"src/index.ts",
"src/search-ui/components/CodeExcerpt.tsx",
"src/search-ui/components/CodeHostIcon.tsx",
"src/search-ui/components/CommitSearchResult.tsx",
"src/search-ui/components/CommitSearchResultMatch.tsx",
"src/search-ui/components/CopyPathAction.tsx",
"src/search-ui/components/FileContentSearchResult.tsx",
"src/search-ui/components/FileMatchChildren.tsx",
"src/search-ui/components/FilePathSearchResult.tsx",
"src/search-ui/components/LastSyncedIcon.tsx",
"src/search-ui/components/LegacyResultContainer.tsx",
"src/search-ui/components/OwnerSearchResult.tsx",
"src/search-ui/components/QueryExamples.constants.ts",
"src/search-ui/components/QueryExamples.tsx",
"src/search-ui/components/RepoFileLink.tsx",
"src/search-ui/components/RepoSearchResult.tsx",
"src/search-ui/components/ResultContainer.tsx",
"src/search-ui/components/SearchResultStar.tsx",
"src/search-ui/components/SymbolSearchResult.tsx",
"src/search-ui/components/SyntaxHighlightedSearchQuery.tsx",
"src/search-ui/components/codeLinkNavigation.ts",
"src/search-ui/components/index.ts",
"src/search-ui/components/useQueryExamples.tsx",
"src/search-ui/documentation/ModalVideo.tsx",
"src/search-ui/experimental.ts",
"src/search-ui/index.ts",
"src/search-ui/input/CodeMirrorQueryInput.tsx",
"src/search-ui/input/LazyQueryInput.tsx",
"src/search-ui/input/QueryInput.ts",
"src/search-ui/input/SearchBox.tsx",
"src/search-ui/input/SearchButton.tsx",
"src/search-ui/input/SearchContextDropdown.tsx",
"src/search-ui/input/SearchContextMenu.tsx",
"src/search-ui/input/SearchHelpDropdownButton.tsx",
"src/search-ui/input/SearchHistoryDropdown.tsx",
"src/search-ui/input/codemirror/completion.ts",
"src/search-ui/input/codemirror/history.ts",
"src/search-ui/input/codemirror/index.ts",
"src/search-ui/input/codemirror/loading-indicator.ts",
"src/search-ui/input/codemirror/parsedQuery.ts",
"src/search-ui/input/codemirror/placeholder.ts",
"src/search-ui/input/codemirror/syntax-highlighting.ts",
"src/search-ui/input/codemirror/token-info.ts",
"src/search-ui/input/experimental/CodeMirrorQueryInputWrapper.tsx",
"src/search-ui/input/experimental/LazyCodeMirrorQueryInput.tsx",
"src/search-ui/input/experimental/Suggestions.tsx",
"src/search-ui/input/experimental/SyntaxHighlightedSearchQuery.tsx",
"src/search-ui/input/experimental/codemirror/history.ts",
"src/search-ui/input/experimental/codemirror/syntax-highlighting.ts",
"src/search-ui/input/experimental/filters.ts",
"src/search-ui/input/experimental/index.ts",
"src/search-ui/input/experimental/modes.ts",
"src/search-ui/input/experimental/optionRenderer.tsx",
"src/search-ui/input/experimental/suggestionsExtension.ts",
"src/search-ui/input/experimental/utils.ts",
"src/search-ui/input/toggles/CopyQueryButton.tsx",
"src/search-ui/input/toggles/QueryInputToggle.tsx",
"src/search-ui/input/toggles/SmartSearchToggle.tsx",
"src/search-ui/input/toggles/Toggles.tsx",
"src/search-ui/input/toggles/index.ts",
"src/search-ui/results/AnnotatedSearchExample.tsx",
"src/search-ui/results/NoResultsPage.tsx",
"src/search-ui/results/StreamingSearchResultsFooter.tsx",
"src/search-ui/results/StreamingSearchResultsList.tsx",
"src/search-ui/results/progress/StreamingProgress.tsx",
"src/search-ui/results/progress/StreamingProgressCount.tsx",
"src/search-ui/results/progress/StreamingProgressSkippedButton.tsx",
"src/search-ui/results/progress/StreamingProgressSkippedPopover.tsx",
"src/search-ui/results/progress/utils.ts",
"src/search-ui/results/sidebar/FilterLink.tsx",
"src/search-ui/results/sidebar/QuickLink.tsx",
"src/search-ui/results/sidebar/SearchFilterSection.tsx",
"src/search-ui/results/sidebar/SearchReference.tsx",
"src/search-ui/results/sidebar/SearchSidebar.tsx",
"src/search-ui/results/sidebar/SearchTypeLink.tsx",
"src/search-ui/results/sidebar/helpers.ts",
"src/search-ui/results/sidebar/revisions.ts",
"src/search-ui/results/use-items-to-show.ts",
"src/search-ui/results/useSearchResultsKeyboardNavigation.ts",
"src/search-ui/util/events.ts",
"src/search-ui/util/index.ts",
"src/search-ui/util/query.ts",
"src/search-ui/util/stars.ts",
],
tsconfig = ":tsconfig",
# TODO(bazel): type-only #keep imports
deps = [
":module_style_typings",
":node_modules/@sourcegraph/codeintellify", #keep
":node_modules/@sourcegraph/common",
":node_modules/@sourcegraph/extension-api-types", #keep
":node_modules/@sourcegraph/observability-client",
":node_modules/@sourcegraph/shared",
":node_modules/@sourcegraph/wildcard",
"//:node_modules/@codemirror/autocomplete",
"//:node_modules/@codemirror/commands",
"//:node_modules/@codemirror/lint",
"//:node_modules/@codemirror/state",
"//:node_modules/@codemirror/view",
"//:node_modules/@mdi/js",
"//:node_modules/@reach/visually-hidden",
"//:node_modules/@types/classnames",
"//:node_modules/@types/history", #keep
"//:node_modules/@types/lodash",
"//:node_modules/@types/node",
"//:node_modules/@types/react",
"//:node_modules/@types/react-dom",
"//:node_modules/@types/sanitize-html",
"//:node_modules/@types/uuid",
"//:node_modules/classnames",
"//:node_modules/comlink", #keep
"//:node_modules/copy-to-clipboard",
"//:node_modules/date-fns",
"//:node_modules/fzf",
"//:node_modules/history", #keep
"//:node_modules/lodash",
"//:node_modules/mdi-react",
"//:node_modules/react",
"//:node_modules/react-dom",
"//:node_modules/react-router-dom",
"//:node_modules/react-sticky-box",
"//:node_modules/react-visibility-sensor",
"//:node_modules/rxjs",
"//:node_modules/sanitize-html",
"//:node_modules/ts-key-enum",
"//:node_modules/use-resize-observer",
"//:node_modules/uuid",
"//client/shared:shared_lib", #keep
],
)
ts_project(
name = "branded_tests",
testonly = True,
srcs = [
"src/components/Timestamp/Timestamp.test.tsx",
"src/components/Toggle.test.tsx",
"src/components/ToggleBig.test.tsx",
"src/components/panel/TabbedPanelContent.test.tsx",
"src/components/panel/views/locations.test.ts",
"src/search-ui/components/CodeExcerpt.test.tsx",
"src/search-ui/components/FileContentSearchResult.test.tsx",
"src/search-ui/components/FileMatchChildren.test.tsx",
"src/search-ui/components/LegacyResultContainer.test.tsx",
"src/search-ui/components/RepoFileLink.test.tsx",
"src/search-ui/components/SyntaxHighlightedSearchQuery.test.tsx",
"src/search-ui/input/LazyQueryInput.test.tsx",
"src/search-ui/input/SearchContextDropdown.test.tsx",
"src/search-ui/input/SearchContextMenu.test.tsx",
"src/search-ui/input/codemirror/completion.test.ts",
"src/search-ui/input/experimental/utils.test.ts",
"src/search-ui/input/toggles/Toggles.test.tsx",
"src/search-ui/results/progress/StreamingProgressCount.test.tsx",
"src/search-ui/results/progress/StreamingProgressSkippedButton.test.tsx",
"src/search-ui/results/progress/StreamingProgressSkippedPopover.test.tsx",
"src/search-ui/results/sidebar/FilterLink.test.tsx",
"src/search-ui/results/sidebar/QuickLink.test.tsx",
"src/search-ui/results/sidebar/SearchFilterSection.test.tsx",
"src/search-ui/results/sidebar/helpers.test.ts",
"src/search-ui/results/use-items-to-show.test.ts",
],
tsconfig = ":tsconfig",
deps = [
":branded_lib",
":node_modules/@sourcegraph/shared",
":node_modules/@sourcegraph/testing",
":node_modules/@sourcegraph/wildcard",
"//:node_modules/@testing-library/react",
"//:node_modules/@testing-library/user-event",
"//:node_modules/@types/history",
"//:node_modules/@types/lodash",
"//:node_modules/@types/react",
"//:node_modules/@types/react-dom",
"//:node_modules/@types/sinon",
"//:node_modules/history",
"//:node_modules/lodash",
"//:node_modules/mdi-react",
"//:node_modules/react",
"//:node_modules/react-dom",
"//:node_modules/rxjs",
"//:node_modules/sinon",
],
)
npm_package(
name = "branded_pkg",
srcs = [
"package.json",
":branded_lib",
":module_styles", #keep
],
)
jest_test(
name = "test",
data = [
":branded_tests",
],
# TODO(bazel): enable when snapshots updated to support pre-compiled .js files
tags = ["manual"],
)

View File

@ -1,6 +1,41 @@
load("//dev:defs.bzl", "sass")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "jest_test", "sass", "ts_project")
load("//client/shared/dev:generate_graphql_operations.bzl", "generate_graphql_operations")
load("//client/shared/dev:tools.bzl", "module_style_typings")
# TODO(bazel): storybook build
# gazelle:exclude **/*.story.{ts,tsx}
# gazelle:js_resolve **/*.module.scss :module_style_typings
# Assets included as data
# gazelle:js_ignore_imports ../../../../assets/img/sourcegraph-mark.svg
# Bundled [s]css:
# gazelle:js_resolve **/branded.scss :src/branded.css
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/branded:tsconfig",
"//client/build-config:tsconfig",
"//client/client-api:tsconfig",
"//client/codeintellify:tsconfig",
"//client/common:tsconfig",
"//client/extension-api-types:tsconfig",
"//client/http-client:tsconfig",
"//client/shared:tsconfig",
"//client/wildcard:tsconfig",
],
)
module_style_typings(
name = "module_style_typings",
deps = ["//client/wildcard:sass-breakpoints"],
@ -27,3 +62,247 @@ sass(
"//client/wildcard:sass-utils",
],
)
js_library(
name = "graphql_operations_files",
# Keep in sync with glob in client/shared/dev/generateGraphQlOperations.js
srcs = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
],
# TODO: Ignore legacy build generated file as it conflicts with the Bazel
# build. This can be removed after the migration.
[
"src/graphql-operations.ts",
"src/**/*.module.scss.d.ts",
],
),
visibility = ["//client/shared:__pkg__"],
)
generate_graphql_operations(
name = "graphql_operations_ts",
srcs = [
":graphql_operations_files",
"//client/browser/src/browser-extension/scripts:graphql_operations_files",
"//client/browser/src/integration:graphql_operations_files",
],
out = "src/graphql-operations.ts",
interface_name = "BrowserGraphQlOperations",
visibility = ["//client/shared:__pkg__"],
)
ts_project(
name = "graphql_operations",
srcs = ["src/graphql-operations.ts"],
tsconfig = ":tsconfig",
deps = [
":node_modules/@sourcegraph/shared",
],
)
ts_project(
name = "browser",
srcs = [
"code-intel-extensions.json",
"src/browser-extension/ThemeWrapper.tsx",
"src/browser-extension/after-install-page/AfterInstallPageContent.tsx",
"src/browser-extension/browser-action-icon.ts",
"src/browser-extension/environmentAssertion.ts",
"src/browser-extension/knownCodeHosts.ts",
"src/browser-extension/options-menu/OptionsPage.tsx",
"src/browser-extension/options-menu/OptionsPageAdvancedSettings.tsx",
"src/browser-extension/options-menu/components/OptionsPageContainer.tsx",
"src/browser-extension/util/index.ts",
"src/browser-extension/web-extension-api/ExtensionStorageSubject.ts",
"src/browser-extension/web-extension-api/fromBrowserEvent.ts",
"src/browser-extension/web-extension-api/runtime.ts",
"src/browser-extension/web-extension-api/storage.ts",
"src/browser-extension/web-extension-api/types.ts",
"src/globals.d.ts",
"src/native-integration/integration.main.ts",
"src/native-integration/phabricator/integration.main.ts",
"src/native-integration/phabricator/util.ts",
"src/shared/backend/diffs.tsx",
"src/shared/backend/extension-api-conversion.tsx",
"src/shared/backend/headers.ts",
"src/shared/backend/requestGraphQl.ts",
"src/shared/backend/search.tsx",
"src/shared/backend/server.ts",
"src/shared/backend/userEvents.tsx",
"src/shared/cli/index.ts",
"src/shared/cli/search.ts",
"src/shared/code-hosts/bitbucket-cloud/codeHost.ts",
"src/shared/code-hosts/bitbucket-cloud/context.ts",
"src/shared/code-hosts/bitbucket-cloud/domFunctions.ts",
"src/shared/code-hosts/bitbucket-cloud/fileInfo.ts",
"src/shared/code-hosts/bitbucket-cloud/scrape.ts",
"src/shared/code-hosts/bitbucket/api.ts",
"src/shared/code-hosts/bitbucket/codeHost.tsx",
"src/shared/code-hosts/bitbucket/context.tsx",
"src/shared/code-hosts/bitbucket/domFunctions.ts",
"src/shared/code-hosts/bitbucket/fileInfo.ts",
"src/shared/code-hosts/bitbucket/scrape.ts",
"src/shared/code-hosts/gerrit/codeHost.ts",
"src/shared/code-hosts/github/codeHost.tsx",
"src/shared/code-hosts/github/domFunctions.ts",
"src/shared/code-hosts/github/extensions.tsx",
"src/shared/code-hosts/github/fileInfo.ts",
"src/shared/code-hosts/github/util.tsx",
"src/shared/code-hosts/gitlab/api.ts",
"src/shared/code-hosts/gitlab/codeHost.ts",
"src/shared/code-hosts/gitlab/domFunctions.ts",
"src/shared/code-hosts/gitlab/extensions.ts",
"src/shared/code-hosts/gitlab/fileInfo.ts",
"src/shared/code-hosts/gitlab/scrape.ts",
"src/shared/code-hosts/phabricator/backend.tsx",
"src/shared/code-hosts/phabricator/codeHost.ts",
"src/shared/code-hosts/phabricator/domFunctions.ts",
"src/shared/code-hosts/phabricator/fileInfo.ts",
"src/shared/code-hosts/phabricator/index.tsx",
"src/shared/code-hosts/phabricator/scrape.ts",
"src/shared/code-hosts/phabricator/util.tsx",
"src/shared/code-hosts/shared/SignInButton.tsx",
"src/shared/code-hosts/shared/ViewOnSourcegraphButton.tsx",
"src/shared/code-hosts/shared/codeHost.tsx",
"src/shared/code-hosts/shared/codeHostTestUtils.ts",
"src/shared/code-hosts/shared/codeViews.ts",
"src/shared/code-hosts/shared/errors.ts",
"src/shared/code-hosts/shared/extensions.tsx",
"src/shared/code-hosts/shared/getNotificationClassName.ts",
"src/shared/code-hosts/shared/hoverAlerts.tsx",
"src/shared/code-hosts/shared/inject.ts",
"src/shared/code-hosts/shared/nativeTooltips.tsx",
"src/shared/code-hosts/shared/testHelpers.ts",
"src/shared/code-hosts/shared/util/fileInfo.ts",
"src/shared/code-hosts/shared/util/selections.ts",
"src/shared/code-hosts/shared/views.ts",
"src/shared/code-hosts/sourcegraph/inject.tsx",
"src/shared/components/CodeViewToolbar.tsx",
"src/shared/components/OpenDiffOnSourcegraph.tsx",
"src/shared/components/OpenOnSourcegraph.tsx",
"src/shared/components/ShortcutProvider.tsx",
"src/shared/components/SourcegraphIconButton.tsx",
"src/shared/components/TrackAnchorClick.tsx",
"src/shared/components/WildcardThemeProvider.tsx",
"src/shared/context.ts",
"src/shared/platform/context.ts",
"src/shared/platform/extensionHost.ts",
"src/shared/platform/inlineExtensionsService.ts",
"src/shared/platform/ports.ts",
"src/shared/platform/settings.ts",
"src/shared/platform/worker.ts",
"src/shared/polyfills.ts",
"src/shared/repo/backend.tsx",
"src/shared/repo/index.tsx",
"src/shared/sentry/index.ts",
"src/shared/tracking/eventLogger.tsx",
"src/shared/util/context.tsx",
"src/shared/util/dom.tsx",
"src/shared/util/featureFlags.ts",
"src/shared/util/optionFlags.ts",
"src/types/ajs/index.d.ts",
"src/types/string-score/index.d.ts",
"src/types/webextension-polyfill/index.d.ts",
],
tsconfig = ":tsconfig",
# TODO(bazel): type-only #keep imports
deps = [
":graphql_operations",
":module_style_typings",
":node_modules/@sourcegraph/branded",
":node_modules/@sourcegraph/client-api",
":node_modules/@sourcegraph/codeintellify",
":node_modules/@sourcegraph/common",
":node_modules/@sourcegraph/extension-api-types", #keep
":node_modules/@sourcegraph/http-client",
":node_modules/@sourcegraph/shared",
":node_modules/@sourcegraph/wildcard",
"//:node_modules/@mdi/js",
"//:node_modules/@reach/combobox",
"//:node_modules/@sentry/browser",
"//:node_modules/@sourcegraph/extension-api-classes",
"//:node_modules/@types/classnames",
"//:node_modules/@types/history",
"//:node_modules/@types/jest", #keep
"//:node_modules/@types/lodash",
"//:node_modules/@types/mz",
"//:node_modules/@types/node",
"//:node_modules/@types/react",
"//:node_modules/@types/react-dom",
"//:node_modules/@types/simmerjs",
"//:node_modules/@types/uuid",
"//:node_modules/classnames",
"//:node_modules/comlink", #keep
"//:node_modules/graphql",
"//:node_modules/history",
"//:node_modules/jest", #keep
"//:node_modules/jsonc-parser",
"//:node_modules/lodash",
"//:node_modules/mdi-react",
"//:node_modules/mz",
"//:node_modules/react",
"//:node_modules/react-dom",
"//:node_modules/rxjs",
"//:node_modules/simmerjs",
"//:node_modules/utility-types", #keep
"//:node_modules/uuid",
"//:node_modules/webextension-polyfill",
],
)
ts_project(
name = "browser_tests",
testonly = True,
srcs = [
"src/shared/code-hosts/bitbucket-cloud/codeHost.test.ts",
"src/shared/code-hosts/bitbucket/codeHost.test.ts",
"src/shared/code-hosts/bitbucket/domFunctions.test.ts",
"src/shared/code-hosts/bitbucket/scrape.test.ts",
"src/shared/code-hosts/github/codeHost.test.ts",
"src/shared/code-hosts/github/domFunctions.test.ts",
"src/shared/code-hosts/github/fileInfo.test.ts",
"src/shared/code-hosts/github/util.test.ts",
"src/shared/code-hosts/gitlab/codeHost.test.ts",
"src/shared/code-hosts/gitlab/domFunctions.test.ts",
"src/shared/code-hosts/gitlab/scrape.test.ts",
"src/shared/code-hosts/phabricator/codeHost.test.ts",
"src/shared/code-hosts/phabricator/domFunctions.test.ts",
"src/shared/code-hosts/phabricator/fileInfo.test.ts",
"src/shared/code-hosts/shared/ViewOnSourcegraphButton.test.tsx",
"src/shared/code-hosts/shared/codeHost.test.tsx",
"src/shared/code-hosts/shared/codeViews.test.ts",
"src/shared/code-hosts/shared/views.test.ts",
"src/shared/code-hosts/sourcegraph/inject.test.tsx",
],
tsconfig = ":tsconfig",
deps = [
":browser",
":node_modules/@sourcegraph/common",
":node_modules/@sourcegraph/http-client",
":node_modules/@sourcegraph/shared",
":node_modules/@sourcegraph/wildcard", #keep
"//:node_modules/@testing-library/react",
"//:node_modules/@types/lodash",
"//:node_modules/@types/mz",
"//:node_modules/@types/node",
"//:node_modules/@types/sinon",
"//:node_modules/jest-fetch-mock",
"//:node_modules/lodash",
"//:node_modules/mz",
"//:node_modules/process",
"//:node_modules/rxjs",
"//:node_modules/sinon",
"//:node_modules/util",
],
)
jest_test(
name = "test",
data = [
":browser_tests",
],
# TODO(bazel): enable when snapshots updated to support pre-compiled .js files
tags = ["manual"],
)

View File

@ -0,0 +1,6 @@
package(default_visibility = ["//visibility:public"])
filegroup(
name = "assets",
srcs = glob(["**/*.{svg,png}"]),
)

View File

@ -0,0 +1,2 @@
# gazelle:js_files **/*.{ts,tsx}
# gazelle:ignore

View File

@ -0,0 +1,16 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
# Disable building 'scripts' directory
# gazelle:ignore
js_library(
name = "graphql_operations_files",
# Keep in sync with glob in client/shared/dev/generateGraphQlOperations.js
srcs = glob(
[
"**/*.ts",
"**/*.tsx",
],
),
visibility = ["//client/browser:__pkg__"],
)

View File

@ -0,0 +1,53 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("//dev:defs.bzl", "ts_project")
# end-to-end/ does not contain a src/
# gazelle:js_files **/*.{ts,tsx}
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/browser:tsconfig",
"//client/shared/src/testing:tsconfig",
],
)
ts_project(
name = "end-to-end",
srcs = ["shared.ts"],
tsconfig = ":tsconfig",
deps = [
"//:node_modules/@types/node",
"//:node_modules/expect",
"//:node_modules/puppeteer", #keep
"//client/browser:node_modules/@sourcegraph/shared",
],
)
ts_project(
name = "end-to-end_tests",
testonly = True,
srcs = [
"bitbucket.test.ts",
"ghe.test.ts",
"github.test.ts",
"gitlab.test.ts",
"phabricator.test.ts",
],
tsconfig = ":tsconfig",
deps = [
":end-to-end",
"//:node_modules/@types/lodash",
"//:node_modules/@types/node",
"//:node_modules/expect",
"//:node_modules/lodash",
"//:node_modules/puppeteer", #keep
"//:node_modules/rxjs",
"//client/browser", #keep
"//client/browser:node_modules/@sourcegraph/common",
"//client/browser:node_modules/@sourcegraph/shared",
],
)

View File

@ -0,0 +1,14 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
# TODO(bazel): disabled for now
# gazelle:js disabled
# integration/ does not contain a src/
# # gazelle:js_files **/*.{ts,tsx}
js_library(
name = "graphql_operations_files",
# Keep in sync with glob in client/shared/dev/generateGraphQlOperations.js
srcs = glob(["**/*.{ts,tsx}"]),
visibility = ["//client/browser:__pkg__"],
)

View File

@ -0,0 +1,51 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "npm_package", "ts_project")
# TODO(bazel): currently handled with #keep
# gazelle:js_resolve **/esbuild/* //client/build-config/src/esbuild
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
],
)
ts_project(
name = "build-config_lib",
srcs = [
"src/index.ts",
"src/paths.ts",
"src/utils/environment-config.ts",
"src/webpack/babel-loader.ts",
"src/webpack/css-loader.ts",
"src/webpack/getCacheConfig.ts",
"src/webpack/monaco-editor.ts",
"src/webpack/plugins.ts",
],
module = "commonjs",
tsconfig = ":tsconfig",
deps = [
":node_modules/@statoscope/webpack-plugin",
":node_modules/monaco-editor-webpack-plugin",
":node_modules/terser-webpack-plugin",
":node_modules/webpack",
"//:node_modules/@types/node",
"//:node_modules/monaco-editor", #keep
"//client/build-config/src/esbuild",
],
)
npm_package(
name = "build-config_pkg",
srcs = [
"package.json",
":build-config_lib",
],
type = "commonjs",
)

View File

@ -0,0 +1,24 @@
# TODO(bazel): esbuild build disabled, mocked for now
load("@aspect_rules_js//js:defs.bzl", "js_library")
genrule(
name = "esbuild-mocked",
outs = ["plugins.js"],
cmd = "echo 'exports.stylePlugin = {}' > $@",
)
genrule(
name = "esbuild-mocked-types",
outs = ["plugins.d.ts"],
cmd = "echo 'export const stylePlugin: any' > $@",
)
js_library(
name = "esbuild",
srcs = [
":esbuild-mocked",
":esbuild-mocked-types",
],
visibility = ["//client/build-config:__pkg__"],
)

View File

@ -2,6 +2,9 @@
import fs from 'fs'
import path from 'path'
// TODO(bazel): drop when non-bazel removed.
const IS_BAZEL = !!(process.env.BAZEL_BINDIR || process.env.BAZEL_TEST)
// NOTE: use fs.realpathSync() in addition to path.resolve() to resolve
// symlinks to the real path. This is required for webpack plugins using
// `include: [...file path...]` when the file path contains symlinks such
@ -16,7 +19,7 @@ export function resolveWithSymlink(...args: string[]): string {
}
}
export const ROOT_PATH = resolveWithSymlink(__dirname, '../../../')
export const ROOT_PATH = IS_BAZEL ? process.cwd() : resolveWithSymlink(__dirname, '../../../')
export const WORKSPACES_PATH = resolveWithSymlink(ROOT_PATH, 'client')
export const NODE_MODULES_PATH = resolveWithSymlink(ROOT_PATH, 'node_modules')
export const MONACO_EDITOR_PATH = resolveWithSymlink(NODE_MODULES_PATH, 'monaco-editor')

View File

@ -46,3 +46,5 @@ export const getCSSLoaders = (...loaders: webpack.RuleSetUseItem[]): webpack.Rul
},
},
]
export const getBazelCSSLoaders = (...loaders: webpack.RuleSetUseItem[]): webpack.RuleSetUse => loaders

View File

@ -4,18 +4,23 @@ import webpack from 'webpack'
import { ROOT_PATH } from '../paths'
// TODO(bazel): drop when non-bazel removed.
const IS_BAZEL = !!process.env.BAZEL_BINDIR
interface CacheConfigOptions {
invalidateCacheFiles: string[]
invalidateCacheFiles?: string[]
}
export const getCacheConfig = ({ invalidateCacheFiles }: CacheConfigOptions): webpack.Configuration['cache'] => ({
export const getCacheConfig = ({ invalidateCacheFiles = [] }: CacheConfigOptions): webpack.Configuration['cache'] => ({
type: 'filesystem',
buildDependencies: {
// Invalidate cache on config change.
config: [
...invalidateCacheFiles,
path.resolve(ROOT_PATH, 'babel.config.js'),
path.resolve(ROOT_PATH, 'postcss.config.js'),
],
config: IS_BAZEL
? invalidateCacheFiles
: [
...invalidateCacheFiles,
path.resolve(ROOT_PATH, 'babel.config.js'),
path.resolve(ROOT_PATH, 'postcss.config.js'),
],
},
})

View File

@ -0,0 +1,55 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "npm_package", "ts_project")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/extension-api:tsconfig",
"//client/extension-api-types:tsconfig",
"//client/template-parser:tsconfig",
],
)
ts_project(
name = "client-api_lib",
srcs = [
"src/contribution.ts",
"src/hover.ts",
"src/index.ts",
"src/reference.ts",
"src/textDocument.ts",
],
tsconfig = ":tsconfig",
# TODO(bazel): "#keep"s required for type-only imports
deps = [
":node_modules/@sourcegraph/extension-api-types", #keep
":node_modules/@sourcegraph/template-parser", #keep
"//:node_modules/@sourcegraph/extension-api-classes",
"//:node_modules/utility-types", #keep
],
)
ts_project(
name = "client-api_tests",
testonly = True,
srcs = ["src/hover.test.ts"],
tsconfig = ":tsconfig",
deps = [
":client-api_lib",
"//:node_modules/@sourcegraph/extension-api-classes",
],
)
npm_package(
name = "client-api_pkg",
srcs = [
"package.json",
":client-api_lib",
],
)

View File

@ -0,0 +1,91 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "jest_test", "npm_package", "ts_project")
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/common:tsconfig",
"//client/extension-api-types:tsconfig",
],
)
ts_project(
name = "codeintellify_lib",
srcs = [
"src/helpers.ts",
"src/hoverifier.ts",
"src/index.ts",
"src/loading.ts",
"src/overlayPosition.ts",
"src/positions.ts",
"src/state.ts",
"src/tokenPosition.ts",
"src/types.ts",
"src/typings/html.d.ts",
],
tsconfig = ":tsconfig",
# TODO(bazel): "#keep"s required for type-only imports
deps = [
":node_modules/@sourcegraph/common",
":node_modules/@sourcegraph/extension-api-types", #keep
"//:node_modules/@types/lodash",
"//:node_modules/lodash",
"//:node_modules/rxjs",
"//:node_modules/ts-key-enum",
],
)
ts_project(
name = "codeintellify_tests",
testonly = True,
srcs = [
"src/hoverifier.test.ts",
"src/loading.test.ts",
"src/overlayPosition.test.ts",
"src/positions.test.ts",
"src/testutils/dom.test.ts",
"src/testutils/dom.ts",
"src/testutils/fixtures.ts",
"src/testutils/generate.ts",
"src/testutils/github/generate.ts",
"src/testutils/mouse.ts",
"src/testutils/revision.ts",
"src/testutils/sourcegraph/generate.ts",
"src/tokenPosition.test.ts",
],
data = [
"src/testutils/github/styles.css",
"src/testutils/mux.go.txt",
"src/testutils/sourcegraph/styles.css",
],
tsconfig = ":tsconfig",
deps = [
":codeintellify_lib",
":node_modules/@sourcegraph/common",
"//:node_modules/@types/lodash",
"//:node_modules/@types/node",
"//:node_modules/lodash",
"//:node_modules/rxjs",
],
)
npm_package(
name = "codeintellify_pkg",
srcs = [
"package.json",
":codeintellify_lib",
],
)
jest_test(
name = "test",
data = [
":codeintellify_tests",
],
)

View File

@ -1,10 +1,21 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "ts_project")
load("//dev:defs.bzl", "jest_test", "npm_package", "ts_project")
# gazelle:aspect_js enabled
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/extension-api-types:tsconfig",
],
)
ts_project(
name = "common",
name = "common_lib",
srcs = [
"src/errors/constants.ts",
"src/errors/errors.ts",
@ -38,6 +49,8 @@ ts_project(
"src/util/types.ts",
"src/util/url.ts",
],
tsconfig = ":tsconfig",
# TODO(bazel): "#keep"s required for type-only imports
deps = [
":node_modules/@sourcegraph/extension-api-types", #keep
"//:node_modules/@types/highlight.js",
@ -52,7 +65,7 @@ ts_project(
"//:node_modules/jsonc-parser",
"//:node_modules/lodash",
"//:node_modules/marked",
"//:node_modules/react-router-dom-v5-compat", #keep
"//:node_modules/react-router-dom", #keep
"//:node_modules/rxjs",
"//:node_modules/sanitize-html",
"//:node_modules/utility-types", #keep
@ -61,6 +74,7 @@ ts_project(
ts_project(
name = "common_tests",
testonly = True,
srcs = [
"src/errors/errors.test.ts",
"src/util/fetchCache.test.ts",
@ -74,9 +88,9 @@ ts_project(
"src/util/string.test.ts",
"src/util/url.test.ts",
],
tsconfig = ":tsconfig",
deps = [
":common",
"//:node_modules/@types/jest", #keep
":common_lib",
"//:node_modules/@types/mockdate",
"//:node_modules/@types/node",
"//:node_modules/jest-fetch-mock",
@ -85,4 +99,17 @@ ts_project(
],
)
npm_link_all_packages(name = "node_modules")
npm_package(
name = "common_pkg",
srcs = [
"package.json",
":common_lib",
],
)
jest_test(
name = "test",
data = [
":common_tests",
],
)

View File

@ -0,0 +1,11 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "npm_package")
# gazelle:js_files **/*.ts
npm_link_all_packages(name = "node_modules")
npm_package(
name = "eslint-plugin-wildcard_pkg",
srcs = ["package.json"],
)

View File

@ -1,8 +1,31 @@
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "npm_package")
package(default_visibility = ["//visibility:public"])
npm_package(
name = "extension-api-types",
srcs = ["package.json"] + glob(["src/**/*.d.ts"]),
# .dts-only library done manually
# gazelle:js disabled
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/extension-api:tsconfig",
],
)
npm_link_all_packages(name = "node_modules")
npm_package(
name = "extension-api-types_pkg",
srcs = [
"package.json",
"src/hover.d.ts",
"src/index.d.ts",
"src/location.d.ts",
"src/workspace.d.ts",
],
)

View File

@ -1,11 +1,29 @@
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "npm_package")
package(default_visibility = ["//visibility:public"])
npm_package(
name = "extension-api",
srcs = ["package.json"] + glob([
"src/**/*.js",
"src/**/*.d.ts",
]),
# Disable gazelle for the js/dts-only package
# gazelle:js disabled
# gazelle:js_files **/*.{ts,tsx}
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
],
)
npm_link_all_packages(name = "node_modules")
npm_package(
name = "extension-api_pkg",
srcs = [
"package.json",
"src/index.js",
"src/sourcegraph.d.ts",
],
)

View File

@ -0,0 +1,81 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "jest_test", "npm_package", "ts_project")
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/common:tsconfig",
],
)
ts_project(
name = "http-client_lib",
srcs = [
"src/graphql/apollo/client.ts",
"src/graphql/apollo/fromObservableQuery.ts",
"src/graphql/apollo/hooks.ts",
"src/graphql/apollo/index.ts",
"src/graphql/constants.ts",
"src/graphql/graphql.ts",
"src/graphql/links/concurrent-requests-link.ts",
"src/graphql/links/index.ts",
"src/graphql/types.ts",
"src/http-status-error.ts",
"src/index.ts",
],
tsconfig = ":tsconfig",
# TODO(bazel): "#keep"s required for type-only imports
deps = [
":node_modules/@sourcegraph/common",
"//:node_modules/@apollo/client",
"//:node_modules/@types/lodash",
"//:node_modules/@types/node-fetch", #keep
"//:node_modules/@types/react",
"//:node_modules/apollo3-cache-persist",
"//:node_modules/graphql",
"//:node_modules/lodash",
"//:node_modules/node-fetch", #keep
"//:node_modules/react",
"//:node_modules/rxjs",
"//:node_modules/utility-types", #keep
],
)
ts_project(
name = "http-client_tests",
testonly = True,
srcs = [
"src/graphql/apollo/fromObservableQuery.test.ts",
"src/graphql/graphql.test.ts",
],
tsconfig = ":tsconfig",
deps = [
":http-client_lib",
"//:node_modules/@apollo/client",
"//:node_modules/@types/sinon",
"//:node_modules/delay",
"//:node_modules/rxjs",
"//:node_modules/sinon",
],
)
npm_package(
name = "http-client_pkg",
srcs = [
"package.json",
":http-client_lib",
],
)
jest_test(
name = "test",
data = [
":http-client_tests",
],
)

View File

@ -1,27 +1,29 @@
load("//client/shared/dev:generate_graphql_operations.bzl", "generate_graphql_operations")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
# dts-only done manually
# gazelle:js disabled
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/branded:tsconfig",
"//client/build-config:tsconfig",
"//client/common:tsconfig",
"//client/http-client:tsconfig",
"//client/shared:tsconfig",
"//client/storybook:tsconfig",
"//client/wildcard:tsconfig",
],
)
js_library(
name = "graphql_operations_files",
# Keep in sync with glob in client/shared/dev/generateGraphQlOperations.js
srcs = glob(
[
"webview/src/**/*.ts",
"webview/src/**/*.tsx",
],
# TODO: Ignore legacy build generated file as it conflicts with the Bazel
# build. This can be removed after the migration.
[
"webview/src/graphql-operations.ts",
],
),
)
generate_graphql_operations(
name = "graphql_operations",
srcs = [
"//client/jetbrains/webview:graphql_operations_files",
],
out = "src/graphql-operations.ts",
interface_name = "JetBrainsGraphQlOperations",
name = "jetbrains",
srcs = ["globals.d.ts"],
)

View File

@ -1,2 +1,2 @@
# TODO(bazel): remove when no longer generated into src
webview/src/graphql-operations.ts
src/graphql-operations.ts

View File

@ -1,6 +1,15 @@
load("//dev:defs.bzl", "sass", "ts_project")
load("//client/shared/dev:tools.bzl", "module_style_typings")
load("//client/shared/dev:generate_graphql_operations.bzl", "generate_graphql_operations")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("//dev:defs.bzl", "sass")
# TODO(bazel): storybook build
# gazelle:exclude **/*.story.{ts,tsx}
# gazelle:js_resolve **/*.module.scss :module_style_typings
# Bundled [s]css:
# gazelle:js_resolve **/index.scss :src/index.css
module_style_typings(
name = "module_style_typings",
@ -36,6 +45,93 @@ js_library(
"src/**/*.ts",
"src/**/*.tsx",
],
# TODO: Ignore legacy build generated file as it conflicts with the Bazel
# build. This can be removed after the migration.
[
"src/graphql-operations.ts",
"src/**/*.module.scss.d.ts",
],
),
visibility = ["//client/jetbrains:__pkg__"],
visibility = ["//client/shared:__pkg__"],
)
generate_graphql_operations(
name = "graphql_operations_ts",
srcs = [
":graphql_operations_files",
],
out = "src/graphql-operations.ts",
interface_name = "JetBrainsGraphQlOperations",
visibility = ["//client/shared:__pkg__"],
)
ts_project(
name = "graphql_operations",
srcs = ["src/graphql-operations.ts"],
tsconfig = "//client/jetbrains:tsconfig",
deps = [
"//client/jetbrains:node_modules/@sourcegraph/shared",
],
)
ts_project(
name = "webview",
srcs = [
"src/bridge-mock/call-java-mock.ts",
"src/bridge-mock/index.ts",
"src/bridge-mock/renderColorDebugger.tsx",
"src/bridge-mock/theme-snapshots/dark.ts",
"src/bridge-mock/theme-snapshots/light.ts",
"src/search/App.tsx",
"src/search/GlobalKeyboardListeners.ts",
"src/search/StatusBar.tsx",
"src/search/index.tsx",
"src/search/input/JetBrainsSearchBox.tsx",
"src/search/input/JetBrainsToggles.tsx",
"src/search/java-to-js-bridge.ts",
"src/search/jetbrains-icons/Search.tsx",
"src/search/js-to-java-bridge.ts",
"src/search/lib/ExpirationCache.ts",
"src/search/lib/blob.ts",
"src/search/lib/requestGraphQl.ts",
"src/search/results/CommitSearchResult.tsx",
"src/search/results/FileSearchResult.tsx",
"src/search/results/InfoDivider.tsx",
"src/search/results/PathSearchResult.tsx",
"src/search/results/RepoName.tsx",
"src/search/results/RepoSearchResult.tsx",
"src/search/results/SearchResultHeader.tsx",
"src/search/results/SearchResultLayout.tsx",
"src/search/results/SearchResultList.tsx",
"src/search/results/SelectableSearchResult.tsx",
"src/search/results/TrimmedCodeLineWithHighlights.tsx",
"src/search/results/utils.ts",
"src/search/types.d.ts",
"src/sourcegraph-api-access/api-gateway.ts",
"src/sourcegraphSettings.ts",
"src/telemetry/EventLogger.ts",
],
data = [
":package_styles",
],
tsconfig = "//client/jetbrains:tsconfig",
deps = [
":graphql_operations",
":module_style_typings",
"//:node_modules/@mdi/js",
"//:node_modules/@types/classnames",
"//:node_modules/@types/react",
"//:node_modules/@types/react-dom",
"//:node_modules/classnames",
"//:node_modules/js-base64",
"//:node_modules/mdi-react",
"//:node_modules/react",
"//:node_modules/react-dom",
"//:node_modules/rxjs",
"//client/jetbrains:node_modules/@sourcegraph/branded",
"//client/jetbrains:node_modules/@sourcegraph/common",
"//client/jetbrains:node_modules/@sourcegraph/http-client",
"//client/jetbrains:node_modules/@sourcegraph/shared",
"//client/jetbrains:node_modules/@sourcegraph/wildcard",
],
)

View File

@ -0,0 +1,93 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "jest_test", "npm_package", "ts_project")
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/common:tsconfig",
],
)
ts_project(
name = "observability-client_lib",
srcs = [
"src/constants.ts",
"src/exporters/consoleBatchSpanExporter.ts",
"src/index.ts",
"src/instrumentations/constants.ts",
"src/instrumentations/fetch.ts",
"src/instrumentations/history.ts",
"src/instrumentations/window-load.ts",
"src/processors/clientAttributesSpanProcessor.ts",
"src/processors/sharedSpanStoreProcessor.ts",
"src/react/TraceSpanProvider/TraceSpanProvider.tsx",
"src/react/TraceSpanProvider/index.ts",
"src/react/TraceSpanProvider/useNewTraceContextProviderValue.ts",
"src/react/constants.ts",
"src/react/index.ts",
"src/react/useCurrentSpan.ts",
"src/sdk/createActiveSpan.ts",
"src/sdk/createFinishedSpan.ts",
"src/sdk/getTracingUrl.ts",
"src/sdk/index.ts",
"src/sdk/instrumentationBaseWeb.ts",
"src/sdk/performance.ts",
"src/sdk/sharedSpanStore.ts",
"src/sdk/span.ts",
"src/sdk/trace.ts",
"src/sdk/tracer.ts",
"src/types/@opentelemetry/api/index.d.ts",
"src/types/@opentelemetry/core/index.d.ts",
"src/types/@opentelemetry/exporter-trace-otlp-http/index.d.ts",
"src/types/@opentelemetry/instrumentation/index.d.ts",
"src/types/@opentelemetry/resources/index.d.ts",
"src/types/@opentelemetry/sdk-trace-base/index.d.ts",
"src/types/@opentelemetry/semantic-conventions/index.d.ts",
],
tsconfig = ":tsconfig",
deps = [
":node_modules/@sourcegraph/common",
"//:node_modules/@opentelemetry/api",
"//:node_modules/@opentelemetry/core",
"//:node_modules/@opentelemetry/exporter-trace-otlp-http",
"//:node_modules/@opentelemetry/instrumentation",
"//:node_modules/@opentelemetry/resources",
"//:node_modules/@opentelemetry/sdk-trace-base",
"//:node_modules/@opentelemetry/sdk-trace-web",
"//:node_modules/@opentelemetry/semantic-conventions",
"//:node_modules/@types/lodash",
"//:node_modules/@types/react",
"//:node_modules/is-absolute-url",
"//:node_modules/lodash",
"//:node_modules/react",
],
)
npm_package(
name = "observability-client_pkg",
srcs = [
"package.json",
":observability-client_lib",
],
)
ts_project(
name = "observability-client_tests",
testonly = True,
srcs = ["src/sdk/__tests__/getTracingUrl.test.ts"],
tsconfig = ":tsconfig",
deps = [":observability-client_lib"],
)
jest_test(
name = "test",
data = [
":observability-client_tests",
],
)

View File

@ -0,0 +1,63 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "jest_test", "ts_project")
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/build-config:tsconfig",
],
)
ts_project(
name = "observability-server",
srcs = [
"src/constants.ts",
"src/honeycomb/clone-boards.ts",
"src/libhoney.d.ts",
"src/sdk.ts",
"src/webBundleSize/getBundleSizeStats.ts",
"src/webBundleSize/index.ts",
],
tsconfig = ":tsconfig",
deps = [
":node_modules/@sourcegraph/build-config",
"//:node_modules/@opentelemetry/semantic-conventions",
"//:node_modules/@types/glob",
"//:node_modules/@types/lodash",
"//:node_modules/@types/node",
"//:node_modules/@types/node-fetch",
"//:node_modules/@types/signale",
"//:node_modules/envalid",
"//:node_modules/glob",
"//:node_modules/libhoney",
"//:node_modules/lodash",
"//:node_modules/node-fetch",
"//:node_modules/signale",
],
)
ts_project(
name = "observability-server_tests",
testonly = True,
srcs = ["src/webBundleSize/getBundleSizeStats.test.ts"],
tsconfig = ":tsconfig",
deps = [
":observability-server",
"//:node_modules/@types/node",
],
)
jest_test(
name = "test",
data = [
":observability-server_tests",
],
# TODO(bazel): requires webpack setup for testing
tags = ["manual"],
)

View File

@ -1,8 +1,42 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "jest_test", "npm_package", "sass", "ts_project")
load("//client/shared/dev:generate_schema.bzl", "generate_schema")
load("//client/shared/dev:generate_graphql_operations.bzl", "generate_graphql_operations")
load("//client/shared/dev:tools.bzl", "module_style_typings")
load("//dev:defs.bzl", "sass")
# TODO(bazel): @sourcegraph/shared is currently used by jest setup scripts and must be compiled to commonjs.
# This should be changed to esm once jest setup scripts are moved to a separate package that can be
# compiled to commonjs specifically and only for jest.
# TODO(bazel): storybook build
# gazelle:exclude **/*.story.{ts,tsx}
# gazelle:js_resolve **/*.module.scss :module_style_typings
# gazelle:js_resolve ../graphql-operations //client/shared:graphql_operations
# gazelle:js_ignore_imports **/*.worker.ts
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/build-config:tsconfig",
"//client/client-api:tsconfig",
"//client/codeintellify:tsconfig",
"//client/common:tsconfig",
"//client/extension-api:tsconfig",
"//client/extension-api-types:tsconfig",
"//client/http-client:tsconfig",
"//client/template-parser:tsconfig",
"//client/testing:tsconfig",
"//client/wildcard:tsconfig",
],
)
module_style_typings(
name = "module_style_typings",
@ -14,12 +48,24 @@ sass(
)
generate_graphql_operations(
name = "graphql_operations",
name = "graphql_operations_ts",
srcs = [
":graphql_operations_files",
"//client/shared/src/api/integration-test:graphql_operations_files",
"//client/shared/src/testing:graphql_operations_files",
],
out = "src/graphql-operations.ts",
interface_name = "SharedGraphQlOperations",
visibility = ["//client/shared:__pkg__"],
)
ts_project(
name = "graphql_operations",
srcs = ["src/graphql-operations.ts"],
tsconfig = ":tsconfig",
deps = [
"//:node_modules/@apollo/client",
],
)
js_library(
@ -34,18 +80,466 @@ js_library(
"src/testing/**/*.*",
# TODO: Ignore legacy build generated file as it conflicts with the Bazel
# build. This can be removed after the migration.
"src/schema.ts",
"src/graphql-operations.ts",
"src/**/*.module.scss.d.ts",
],
),
visibility = ["//client/shared:__pkg__"],
)
[generate_schema(
name = name,
out = "src/schema/%s.schema.d.ts" % name,
) for name in [
"json-schema-draft-07",
"site",
"settings",
"batch_spec",
]]
generate_schema(
name = "json-schema-draft-07",
out = "src/schema/json-schema-draft-07.schema.d.ts",
)
generate_schema(
name = "site",
out = "src/schema/site.schema.d.ts",
)
generate_schema(
name = "settings",
out = "src/schema/settings.schema.d.ts",
)
generate_schema(
name = "batch_spec",
out = "src/schema/batch_spec.schema.d.ts",
)
ts_project(
name = "shared_lib",
srcs = [
"src/actions/ActionItem.tsx",
"src/actions/ActionsContainer.tsx",
"src/actions/ActionsNavItems.tsx",
"src/actions/SimpleActionItem.tsx",
"src/actions/actions.ts",
"src/api/client/api/api.ts",
"src/api/client/api/common.ts",
"src/api/client/connection.ts",
"src/api/client/mainthread-api.ts",
"src/api/client/search.ts",
"src/api/client/services/settings.ts",
"src/api/client/types/textDocument.ts",
"src/api/contract.ts",
"src/api/extension/activation.ts",
"src/api/extension/api/api.ts",
"src/api/extension/api/callViewProvidersInParallel.ts",
"src/api/extension/api/codeEditor.ts",
"src/api/extension/api/common.ts",
"src/api/extension/api/context/context.ts",
"src/api/extension/api/contribution.ts",
"src/api/extension/api/directoryViewer.ts",
"src/api/extension/api/documentHighlights.ts",
"src/api/extension/api/getInsightsViews.ts",
"src/api/extension/api/logging.ts",
"src/api/extension/api/textDocument.ts",
"src/api/extension/api/types.ts",
"src/api/extension/api/utils/prefixSumComputer.ts",
"src/api/extension/api/utils/wordHelpers.ts",
"src/api/extension/api/workspaceRoot.ts",
"src/api/extension/extensionApi.ts",
"src/api/extension/extensionHost.ts",
"src/api/extension/extensionHostApi.ts",
"src/api/extension/extensionHostState.ts",
"src/api/extension/main.worker.ts",
"src/api/extension/test/test-helpers.ts",
"src/api/extension/util.ts",
"src/api/extension/utils/ReferenceCounter.ts",
"src/api/extension/worker.ts",
"src/api/features.ts",
"src/api/sharedEventLogger.ts",
"src/api/textDocumentTypes.ts",
"src/api/util.ts",
"src/api/viewerTypes.ts",
"src/auth.ts",
"src/backend/apolloCache.ts",
"src/backend/errors.ts",
"src/backend/file.ts",
"src/backend/repo.ts",
"src/backend/settings.ts",
"src/codeintel/api.ts",
"src/codeintel/legacy-extensions/api.ts",
"src/codeintel/legacy-extensions/indicators.ts",
"src/codeintel/legacy-extensions/language-specs/comments.ts",
"src/codeintel/legacy-extensions/language-specs/cpp.ts",
"src/codeintel/legacy-extensions/language-specs/go.ts",
"src/codeintel/legacy-extensions/language-specs/identifiers.ts",
"src/codeintel/legacy-extensions/language-specs/java.ts",
"src/codeintel/legacy-extensions/language-specs/language-spec.ts",
"src/codeintel/legacy-extensions/language-specs/languages.ts",
"src/codeintel/legacy-extensions/language-specs/python.ts",
"src/codeintel/legacy-extensions/language-specs/typescript.ts",
"src/codeintel/legacy-extensions/language-specs/util.ts",
"src/codeintel/legacy-extensions/logging.ts",
"src/codeintel/legacy-extensions/lsif/api.ts",
"src/codeintel/legacy-extensions/lsif/definition-hover.ts",
"src/codeintel/legacy-extensions/lsif/highlights.ts",
"src/codeintel/legacy-extensions/lsif/implementations.ts",
"src/codeintel/legacy-extensions/lsif/locations.ts",
"src/codeintel/legacy-extensions/lsif/providers.ts",
"src/codeintel/legacy-extensions/lsif/ranges.ts",
"src/codeintel/legacy-extensions/lsif/references.ts",
"src/codeintel/legacy-extensions/lsif/stencil.ts",
"src/codeintel/legacy-extensions/providers.ts",
"src/codeintel/legacy-extensions/search/config.ts",
"src/codeintel/legacy-extensions/search/conversion.ts",
"src/codeintel/legacy-extensions/search/docstrings.ts",
"src/codeintel/legacy-extensions/search/markdown.ts",
"src/codeintel/legacy-extensions/search/providers.ts",
"src/codeintel/legacy-extensions/search/queries.ts",
"src/codeintel/legacy-extensions/search/settings.ts",
"src/codeintel/legacy-extensions/search/squirrel.ts",
"src/codeintel/legacy-extensions/search/tokens.ts",
"src/codeintel/legacy-extensions/telemetry.ts",
"src/codeintel/legacy-extensions/util.ts",
"src/codeintel/legacy-extensions/util/api.ts",
"src/codeintel/legacy-extensions/util/graphql.ts",
"src/codeintel/legacy-extensions/util/helpers.ts",
"src/codeintel/legacy-extensions/util/ix.ts",
"src/codeintel/legacy-extensions/util/promise.ts",
"src/codeintel/legacy-extensions/util/uri.ts",
"src/codeintel/scip.ts",
"src/codeintel/searchContext.ts",
"src/commandPalette/CommandList.tsx",
"src/commandPalette/EmptyCommandList.tsx",
"src/commandPalette/EmptyCommandListContainer/EmptyCommandListContainer.tsx",
"src/commandPalette/EmptyCommandListContainer/index.ts",
"src/commands/commands.ts",
"src/components/CodeMirrorEditor.tsx",
"src/components/HighlightedMatches.tsx",
"src/components/MonacoEditor.tsx",
"src/components/NoMonacoEditor.tsx",
"src/components/Path.tsx",
"src/components/PrefetchableFile.tsx",
"src/components/RepoLink.tsx",
"src/components/UserAvatar.tsx",
"src/components/VirtualList.tsx",
"src/components/icons.tsx",
"src/components/languageIcons.tsx",
"src/components/ranking/LineRanking.ts",
"src/components/ranking/PerFileResultRanking.ts",
"src/components/ranking/PerFileResultRankingTestHelpers.ts",
"src/components/ranking/ZoektRanking.ts",
"src/components/utils/size.ts",
"src/contributions/contributions.ts",
"src/deprecated-theme-utils.ts",
"src/extensions/controller.ts",
"src/extensions/createNoopLoadedController.ts",
"src/extensions/createSyncLoadedController.ts",
"src/extensions/extension.ts",
"src/extensions/extensionManifest.ts",
"src/extensions/extensions.ts",
"src/globals.d.ts",
"src/hover/CopyLinkIcon.tsx",
"src/hover/HoverOverlay.fixtures.ts",
"src/hover/HoverOverlay.tsx",
"src/hover/HoverOverlay.types.ts",
"src/hover/HoverOverlayAlerts/HoverOverlayAlerts.tsx",
"src/hover/HoverOverlayAlerts/index.ts",
"src/hover/HoverOverlayContents/HoverOverlayContent/HoverOverlayContent.tsx",
"src/hover/HoverOverlayContents/HoverOverlayContent/index.ts",
"src/hover/HoverOverlayContents/HoverOverlayContents.tsx",
"src/hover/HoverOverlayContents/index.ts",
"src/hover/HoverOverlayLogo/HoverOverlayLogo.tsx",
"src/hover/HoverOverlayLogo/index.ts",
"src/hover/actions.ts",
"src/hover/helpers.ts",
"src/hover/useLogTelemetryEvent.ts",
"src/keyboardShortcuts.ts",
"src/keyboardShortcuts/keyboardShortcuts.ts",
"src/keyboardShortcuts/useKeyboardShortcut.ts",
"src/languages.ts",
"src/notifications/NotificationItem.tsx",
"src/notifications/Notifications.tsx",
"src/notifications/notification.ts",
"src/platform/context.ts",
"src/polyfills/configure-core-js.ts",
"src/polyfills/index.ts",
"src/polyfills/polyfill.ts",
"src/polyfills/vendor/eventSource.d.ts",
"src/react-shortcuts/Shortcut.tsx",
"src/react-shortcuts/ShortcutManager.tsx",
"src/react-shortcuts/ShortcutProvider.tsx",
"src/react-shortcuts/index.ts",
"src/react-shortcuts/keys.ts",
"src/schema/extensionSchema.ts",
"src/schema/settings.schema.d.ts", #keep
"src/search/backend.ts",
"src/search/helpers.ts",
"src/search/helpers/queryExample.ts",
"src/search/helpers/searchContext.ts",
"src/search/index.ts",
"src/search/integration/index.ts",
"src/search/integration/streaming-search-mocks.ts",
"src/search/query/completion.ts",
"src/search/query/completion-utils.ts",
"src/search/query/decoratedToken.ts",
"src/search/query/diagnostics.ts",
"src/search/query/filters.ts",
"src/search/query/hover.ts",
"src/search/query/languageFilter.ts",
"src/search/query/metrics.ts",
"src/search/query/monaco.ts",
"src/search/query/parser.ts",
"src/search/query/parserFuzz.ts",
"src/search/query/patternMatcher.ts",
"src/search/query/predicates.ts",
"src/search/query/printer.ts",
"src/search/query/providers.ts",
"src/search/query/providers-utils.ts",
"src/search/query/query.ts",
"src/search/query/scanner.ts",
"src/search/query/selectFilter.ts",
"src/search/query/token.ts",
"src/search/query/transformer.ts",
"src/search/query/utils.ts",
"src/search/query/validate.ts",
"src/search/query/visitor.ts",
"src/search/searchQueryState.tsx",
"src/search/stream.ts",
"src/search/suggestions/index.ts",
"src/settings/edit.ts",
"src/settings/settings.tsx",
"src/settings/temporary/TemporarySettings.ts",
"src/settings/temporary/TemporarySettingsProvider.tsx",
"src/settings/temporary/TemporarySettingsStorage.ts",
"src/settings/temporary/diffMode.ts",
"src/settings/temporary/index.ts",
"src/settings/temporary/migrateLocalStorageToTemporarySettings.ts",
"src/settings/temporary/recentSearches.ts",
"src/settings/temporary/searchSidebar.ts",
"src/settings/temporary/testUtils.tsx",
"src/settings/temporary/tourState.ts",
"src/settings/temporary/useTemporarySetting.ts",
"src/stories/MockedStoryProvider.tsx",
"src/stories/index.ts",
"src/symbols/SymbolIcon.tsx",
"src/symbols/SymbolKind.tsx",
"src/symbols/SymbolTag.tsx",
"src/symbols/symbolIcons.ts",
"src/telemetry/telemetryService.ts",
"src/theme.ts",
"src/tracking/event-log-creators.ts",
"src/tracking/utm.ts",
"src/types/core-js/configurator.d.ts",
"src/types/jasmine/index.d.ts",
"src/types/puppeteer-firefox/index.d.ts",
"src/types/storybook-chromatic/index.d.ts",
"src/types/string-score/index.d.ts",
"src/types/web-ext/index.d.ts",
"src/util/dom.ts",
"src/util/globbing.ts",
"src/util/lazyComponent.tsx",
"src/util/url.ts",
"src/util/useInputValidation.ts",
],
tsconfig = ":tsconfig",
deps = [
":graphql_operations",
":module_style_typings",
":node_modules/@sourcegraph/client-api",
":node_modules/@sourcegraph/codeintellify",
":node_modules/@sourcegraph/common",
":node_modules/@sourcegraph/extension-api-types", #keep
":node_modules/@sourcegraph/http-client",
":node_modules/@sourcegraph/template-parser",
":node_modules/@sourcegraph/wildcard",
"//:node_modules/@apollo/client",
"//:node_modules/@codemirror/language",
"//:node_modules/@codemirror/state",
"//:node_modules/@codemirror/view",
"//:node_modules/@lezer/highlight",
"//:node_modules/@mdi/js",
"//:node_modules/@microsoft/fetch-event-source",
"//:node_modules/@sourcegraph/extension-api-classes",
"//:node_modules/@storybook/addon-actions",
"//:node_modules/@types/classnames",
"//:node_modules/@types/history",
"//:node_modules/@types/lodash",
"//:node_modules/@types/lru-cache",
"//:node_modules/@types/minimatch",
"//:node_modules/@types/node",
"//:node_modules/@types/puppeteer",
"//:node_modules/@types/react",
"//:node_modules/axe-core", #keep
"//:node_modules/classnames",
"//:node_modules/comlink",
"//:node_modules/core-js",
"//:node_modules/fast-json-stable-stringify",
"//:node_modules/history",
"//:node_modules/jest", #keep
"//:node_modules/js-base64",
"//:node_modules/lodash",
"//:node_modules/lru-cache",
"//:node_modules/mdi-react",
"//:node_modules/minimatch",
"//:node_modules/monaco-editor",
"//:node_modules/puppeteer",
"//:node_modules/react",
"//:node_modules/react-visibility-sensor",
"//:node_modules/regexpp",
"//:node_modules/rxjs",
"//:node_modules/string-score",
"//:node_modules/tabbable",
"//:node_modules/tagged-template-noop",
"//:node_modules/ts-key-enum",
"//:node_modules/use-deep-compare-effect",
"//:node_modules/util",
"//:node_modules/utility-types", #keep
"//:node_modules/zustand", #keep
"//schema:settings", #keep
],
)
ts_project(
name = "shared_tests",
testonly = True,
srcs = [
"src/actions/ActionItem.test.tsx",
"src/actions/ActionsNavItems.test.tsx",
"src/api/client/mainthread-api.test.ts",
"src/api/client/types/textDocument.test.ts",
"src/api/extension/api/callViewProvidersInParallel.test.ts",
"src/api/extension/api/context/context.test.ts",
"src/api/extension/api/contribution.test.ts",
"src/api/extension/api/textDocument.test.ts",
"src/api/extension/api/utils/prefixSumComputer.test.ts",
"src/api/extension/api/utils/wordHelpers.test.ts",
"src/api/extension/test/activation.test.ts",
"src/api/extension/test/extensionHost.configuration.test.ts",
"src/api/extension/test/extensionHost.documentHighlights.test.ts",
"src/api/extension/test/extensionHost.hover.test.ts",
"src/api/extension/test/extensionHost.logging.test.ts",
"src/api/extension/test/extensionHost.providers.test.ts",
"src/api/extension/test/extensionHost.search.test.ts",
"src/api/util.test.ts",
"src/backend/errors.test.ts",
"src/codeintel/legacy-extensions/init.test.ts",
"src/codeintel/legacy-extensions/language-specs/cpp.test.ts",
"src/codeintel/legacy-extensions/language-specs/go.test.ts",
"src/codeintel/legacy-extensions/language-specs/java.test.ts",
"src/codeintel/legacy-extensions/language-specs/python.test.ts",
"src/codeintel/legacy-extensions/language-specs/spec.test.ts",
"src/codeintel/legacy-extensions/language-specs/typescript.test.ts",
"src/codeintel/legacy-extensions/lsif/definition-hover.test.ts",
"src/codeintel/legacy-extensions/lsif/highlights.test.ts",
"src/codeintel/legacy-extensions/lsif/locations.test.ts",
"src/codeintel/legacy-extensions/lsif/providers.test.ts",
"src/codeintel/legacy-extensions/lsif/ranges.test.ts",
"src/codeintel/legacy-extensions/lsif/references.test.ts",
"src/codeintel/legacy-extensions/lsif/stencil.test.ts",
"src/codeintel/legacy-extensions/lsif/util.test.ts",
"src/codeintel/legacy-extensions/providers.test.ts",
"src/codeintel/legacy-extensions/search/conversion.test.ts",
"src/codeintel/legacy-extensions/search/docstrings.test.ts",
"src/codeintel/legacy-extensions/search/markdown.test.ts",
"src/codeintel/legacy-extensions/search/providers.test.ts",
"src/codeintel/legacy-extensions/search/queries.test.ts",
"src/codeintel/legacy-extensions/search/tokens.test.ts",
"src/codeintel/legacy-extensions/util/ix.test.ts",
"src/codeintel/legacy-extensions/util/uri.test.ts",
"src/commandPalette/CommandList.test.ts",
"src/commands/commands.test.ts",
"src/components/HighlightedMatches.test.tsx",
"src/components/Path.test.tsx",
"src/components/RepoLink.test.tsx",
"src/components/UserAvatar.test.tsx",
"src/components/ranking/LineRanking.test.tsx",
"src/components/ranking/ZoektRanking.test.tsx",
"src/contributions/contributions.test.ts",
"src/extensions/extension.test.ts",
"src/hover/HoverOverlay.test.tsx",
"src/hover/actions.test.ts",
"src/keyboardShortcuts/useKeyboardShortcut.test.tsx",
"src/languages.test.ts",
"src/react-shortcuts/ShortcutManager.test.tsx",
"src/search/helpers/queryExample.test.ts",
"src/search/query/completion.test.ts",
"src/search/query/decoratedToken.test.ts",
"src/search/query/diagnostics.test.ts",
"src/search/query/filters.test.ts",
"src/search/query/hover.test.ts",
"src/search/query/languageFilter.test.ts",
"src/search/query/metrics.test.ts",
"src/search/query/parser.test.ts",
"src/search/query/patternMatcher.test.ts",
"src/search/query/predicates.test.ts",
"src/search/query/printer.test.ts",
"src/search/query/providers-utils.test.ts",
"src/search/query/scanner.test.ts",
"src/search/query/selectFilter.test.ts",
"src/search/query/transformer.test.ts",
"src/search/query/validate.test.ts",
"src/search/query/visitor.test.ts",
"src/settings/settings.test.ts",
"src/settings/temporary/useTemporarySetting.test.tsx",
"src/tracking/utm.test.ts",
"src/util/dom.test.ts",
"src/util/url.test.ts",
"src/util/useInputValidation.test.ts",
],
tsconfig = ":tsconfig",
deps = [
":graphql_operations",
":node_modules/@sourcegraph/client-api",
":node_modules/@sourcegraph/codeintellify",
":node_modules/@sourcegraph/common",
":node_modules/@sourcegraph/http-client",
":node_modules/@sourcegraph/template-parser",
":node_modules/@sourcegraph/testing",
":node_modules/@sourcegraph/wildcard",
":shared_lib",
"//:node_modules/@apollo/client",
"//:node_modules/@sourcegraph/extension-api-classes",
"//:node_modules/@sourcegraph/extension-api-stubs",
"//:node_modules/@testing-library/react",
"//:node_modules/@testing-library/user-event",
"//:node_modules/@types/history",
"//:node_modules/@types/lodash",
"//:node_modules/@types/mock-require",
"//:node_modules/@types/node",
"//:node_modules/@types/react",
"//:node_modules/@types/sinon",
"//:node_modules/comlink",
"//:node_modules/history",
"//:node_modules/lodash",
"//:node_modules/mock-require",
"//:node_modules/monaco-editor",
"//:node_modules/p-timeout",
"//:node_modules/react",
"//:node_modules/rxjs",
"//:node_modules/sinon",
"//client/shared/src/testing",
],
)
npm_package(
name = "shared_pkg",
srcs = [
"package.json",
":batch_spec", #keep
":module_styles", #keep
":settings", #keep
":shared_lib",
":site", #keep
"//client/shared/src/testing", #keep
],
)
filegroup(
name = "snapshots",
srcs = glob(["src/**/__snapshots__/*"]),
)
jest_test(
name = "test",
data = [
":shared_tests",
":snapshots",
],
# TODO(bazel): enable when snapshots updated to support pre-compiled .js files
tags = ["manual"],
)

View File

@ -1,4 +1,10 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library")
load("//dev:defs.bzl", "ts_project")
# gazelle:ignore
# dev/ does not contain a src/
# gazelle:js_files **/*.{ts,tsx}
js_binary(
name = "generate_schema",
@ -10,8 +16,6 @@ js_binary(
visibility = ["//client/shared:__pkg__"],
)
# gazelle:exclude .
js_library(
name = "extract_graphql_operation_codegen_plugin",
srcs = [
@ -37,3 +41,78 @@ js_binary(
entry_point = "generateGraphQlOperations.js",
visibility = ["//client:__subpackages__"],
)
ts_project(
name = "mock_ts",
srcs = [
"mockDomRect.ts",
"mockMatchMedia.ts",
"mockResizeObserver.ts",
"mockSentryBrowser.ts",
"mockUniqueId.ts",
"reactCleanup.ts",
"setLinkComponentForTest.ts",
],
extends = None,
module = "commonjs",
tsconfig = "//client/shared:tsconfig",
visibility = ["//visibility:private"],
deps = [
"//:node_modules/@sentry/browser",
"//:node_modules/@testing-library/react",
"//:node_modules/@types/jest",
"//:node_modules/@types/node",
"//:node_modules/@types/react",
"//:node_modules/react",
"//:node_modules/react-visibility-sensor",
"//:node_modules/resize-observer-polyfill",
"//:node_modules/use-resize-observer",
"//client/shared:node_modules/@sourcegraph/wildcard",
],
)
js_library(
name = "mock",
srcs = [
"jest-environment.js",
"jestGlobalSetup.js",
"mockDate.js",
],
data = [
":fetch-mock",
":mock_ts",
],
visibility = ["//visibility:public"],
deps = [
"//:node_modules/@peculiar/webcrypto",
"//:node_modules/jest-environment-jsdom",
"//:node_modules/mockdate",
"//:node_modules/react",
],
)
js_library(
name = "fetch-mock",
srcs = ["fetch.js"],
visibility = ["//visibility:public"],
deps = [
"//:node_modules/node-fetch",
],
)
js_library(
name = "mocha-reporter",
srcs = [
"customMochaSpecReporter.js",
],
data = [
"//:node_modules/mocha",
],
visibility = ["//visibility:public"],
)
js_library(
name = "suppress-polly-errors",
srcs = ["suppressPollyErrors.js"],
visibility = ["//visibility:public"],
)

View File

@ -19,14 +19,14 @@ const SHARED_DOCUMENTS_GLOB = [`${SHARED_FOLDER}/src/**/*.{ts,tsx}`]
const WEB_DOCUMENTS_GLOB = [
`${WEB_FOLDER}/src/**/*.{ts,tsx}`,
`${WEB_FOLDER}/src/regression/**/*.*`,
`!${WEB_FOLDER}/src/end-to-end/**/*.*`,
`!${WEB_FOLDER}/src/end-to-end/**/*.*`, // TODO(bazel): can remove when non-bazel dropped
]
const SVELTEKIT_DOCUMENTS_GLOB = [`${SVELTEKIT_FOLDER}/src/lib/**/*.ts`]
const BROWSER_DOCUMENTS_GLOB = [
`${BROWSER_FOLDER}/src/**/*.{ts,tsx}`,
`!${BROWSER_FOLDER}/src/end-to-end/**/*.*`,
`!${BROWSER_FOLDER}/src/end-to-end/**/*.*`, // TODO(bazel): can remove when non-bazel dropped
'!**/*.d.ts',
]

View File

@ -1,6 +1,6 @@
load("@aspect_rules_js//js:defs.bzl", "js_run_binary")
def generate_graphql_operations(name, interface_name, srcs, out):
def generate_graphql_operations(name, interface_name, srcs, out, **kwargs):
"""Generate a graphql operations Typescript interface.
Args:
@ -12,6 +12,7 @@ def generate_graphql_operations(name, interface_name, srcs, out):
produced in or copied to the Bazel output tree, so it's recommended to use js_library
with a glob pattern equivalent to the one in generateGraphQlOperations.js.
out: Name of the typescript file to output.
**kwargs: general args
"""
js_run_binary(
name = name,
@ -23,4 +24,5 @@ def generate_graphql_operations(name, interface_name, srcs, out):
],
chdir = native.package_name(),
tool = "//client/shared/dev:generate_graphql_operations",
**kwargs
)

View File

@ -7,4 +7,4 @@ import { cleanup } from '@testing-library/react'
* Normally `cleanup` should be called automatically after each test.
* https://testing-library.com/docs/svelte-testing-library/api/#cleanup
*/
global.afterEach(cleanup)
afterEach(cleanup)

View File

@ -1,3 +1,14 @@
import { setLinkComponent, AnchorLink } from '@sourcegraph/wildcard'
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
setLinkComponent(AnchorLink)
// HACK: when running tests within the client/wildcard package the link component
// state is within a local non-packaged version of Link. Set the AnchorLink in the
// local version instead of the packaged version.
if (process.env.JS_BINARY__PACKAGE?.startsWith('client/wildcard/')) {
const { setLinkComponent, AnchorLink } = require('../../wildcard/src/components/Link')
setLinkComponent(AnchorLink)
} else {
const { setLinkComponent, AnchorLink } = require('@sourcegraph/wildcard')
setLinkComponent(AnchorLink)
}

View File

@ -0,0 +1,16 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
# Exclude integration-test/ ts compilation
# gazelle:exclude .
js_library(
name = "graphql_operations_files",
# Keep in sync with glob in client/shared/dev/generateGraphQlOperations.js
srcs = glob(
[
"**/*.ts",
"**/*.tsx",
],
),
visibility = ["//client/shared:__pkg__"],
)

View File

@ -0,0 +1,114 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("//dev:defs.bzl", "ts_project")
# testing/ does not contain a src/
# gazelle:js_files **/*.{ts,tsx}
# gazelle:js_test_files make-everything-main-library
# gazelle:js_resolve sourcegraph //client/shared:node_modules/@sourcegraph/client-api
js_library(
name = "graphql_operations_files",
# Keep in sync with glob in client/shared/dev/generateGraphQlOperations.js
srcs = glob(
[
"**/*.ts",
"**/*.tsx",
],
),
visibility = ["//client/shared:__pkg__"],
)
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:node_modules/@types/mocha",
"//:node_modules/@types/node",
"//client/shared:tsconfig",
],
)
ts_project(
name = "testing",
srcs = [
"MockIntersectionObserver.ts",
"accessibility.ts",
"apollo/createGraphQLClientGetter.ts",
"apollo/index.ts",
"apollo/mockedTestProvider.tsx",
"config.ts",
"console.ts",
"coverage.ts",
"dom-test-helpers.ts",
"dom-utils.ts",
"driver.ts",
"integration/context.ts",
"integration/graphQlResults.ts",
"integration/mockExtension.ts",
"integration/polly/CdpAdapter.ts",
"mockReactVisibilitySensor.tsx",
"screenshotReporter.ts",
"searchContexts/testHelpers.ts",
"searchTestHelpers.ts",
"simulateMenuItemClick.ts",
"testHelpers.ts",
"utils.ts",
],
tsconfig = "//client/shared:tsconfig",
deps = [
"//:node_modules/@apollo/client",
"//:node_modules/@axe-core/puppeteer",
"//:node_modules/@percy/puppeteer",
"//:node_modules/@pollyjs/adapter",
"//:node_modules/@pollyjs/core",
"//:node_modules/@pollyjs/persister-fs",
"//:node_modules/@testing-library/react",
"//:node_modules/@types/jest", #keep
"//:node_modules/@types/lodash",
"//:node_modules/@types/mime-types",
"//:node_modules/@types/mocha",
"//:node_modules/@types/mz",
"//:node_modules/@types/node",
"//:node_modules/@types/pollyjs__adapter",
"//:node_modules/@types/pollyjs__core",
"//:node_modules/@types/pollyjs__persister-fs",
"//:node_modules/@types/prettier",
"//:node_modules/@types/puppeteer",
"//:node_modules/@types/react",
"//:node_modules/@types/sinon",
"//:node_modules/@types/uuid",
"//:node_modules/chalk",
"//:node_modules/date-fns",
"//:node_modules/delay",
"//:node_modules/expect",
"//:node_modules/graphql", #keep
"//:node_modules/jest", #keep
"//:node_modules/jest-mock-extended",
"//:node_modules/jsonc-parser",
"//:node_modules/lodash",
"//:node_modules/message-port-polyfill",
"//:node_modules/mime-types",
"//:node_modules/mocha",
"//:node_modules/mz",
"//:node_modules/p-retry",
"//:node_modules/p-timeout",
"//:node_modules/prettier",
"//:node_modules/puppeteer",
"//:node_modules/react",
"//:node_modules/rxjs",
"//:node_modules/sinon",
"//:node_modules/string-width",
"//:node_modules/term-size",
"//:node_modules/ts-key-enum",
"//:node_modules/util",
"//:node_modules/uuid",
"//client/shared:node_modules/@sourcegraph/build-config",
"//client/shared:node_modules/@sourcegraph/common",
"//client/shared:node_modules/@sourcegraph/http-client",
"//client/shared:node_modules/sourcegraph",
"//client/shared:shared_lib",
],
)

View File

@ -3,7 +3,9 @@
"references": [{ "path": "../.." }],
"compilerOptions": {
"types": ["mocha", "node"],
"module": "commonjs",
"paths": {
"*": ["../types/*", "*"],
},
},
"include": ["**/*"],
"exclude": [],

View File

@ -1,5 +1,26 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "npm_package", "sass", "ts_project")
load("//client/shared/dev:tools.bzl", "module_style_typings")
load("//dev:defs.bzl", "sass")
# gazelle:js_resolve **/*.module.scss :module_style_typings
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/build-config:tsconfig",
"//client/common:tsconfig",
"//client/http-client:tsconfig",
"//client/shared:tsconfig",
"//client/wildcard:tsconfig",
],
)
module_style_typings(
name = "module_style_typings",
@ -9,3 +30,80 @@ sass(
name = "module_styles",
srcs = glob(["src/**/*.module.scss"]),
)
ts_project(
name = "storybook_lib",
srcs = [
"globals.d.ts",
"src/decorators/withChromaticThemes/ChromaticRoot/ChromaticRoot.tsx",
"src/decorators/withChromaticThemes/ChromaticRoot/index.ts",
"src/decorators/withChromaticThemes/index.ts",
"src/decorators/withChromaticThemes/withChromaticThemes.tsx",
"src/dllPlugin/ensureDllBundleIsReady.ts",
"src/dllPlugin/getVendorModules.ts",
"src/dllPlugin/getWebpackStats.ts",
"src/dllPlugin/index.ts",
"src/environment-config.ts",
"src/main.ts",
"src/preview.ts",
"src/themes.ts",
"src/webpack.config.common.ts",
"src/webpack.config.dll.ts",
],
tsconfig = ":tsconfig",
# TODO(bazel): "#keep"s required for type-only imports
deps = [
":module_style_typings",
":node_modules/@sourcegraph/build-config",
":node_modules/@sourcegraph/wildcard",
"//:node_modules/@storybook/addon-actions",
"//:node_modules/@storybook/addon-console",
"//:node_modules/@storybook/addons", #keep
"//:node_modules/@storybook/core-common", #keep
"//:node_modules/@storybook/react", #keep
"//:node_modules/@storybook/theming",
"//:node_modules/@types/case-sensitive-paths-webpack-plugin",
"//:node_modules/@types/classnames",
"//:node_modules/@types/lodash",
"//:node_modules/@types/node",
"//:node_modules/@types/react",
"//:node_modules/@types/signale",
"//:node_modules/@types/speed-measure-webpack-plugin",
"//:node_modules/case-sensitive-paths-webpack-plugin",
"//:node_modules/classnames",
"//:node_modules/focus-visible",
"//:node_modules/jsonc-parser",
"//:node_modules/lodash",
"//:node_modules/open-color",
"//:node_modules/react",
"//:node_modules/signale",
"//:node_modules/speed-measure-webpack-plugin",
"//:node_modules/storybook-addon-designs",
"//:node_modules/webpack",
"//:node_modules/webpack-manifest-plugin",
],
)
ts_project(
name = "storybook_tests",
testonly = True,
srcs = ["src/coverage.test.ts"],
tsconfig = ":tsconfig",
# TODO(bazel): "#keep"s required for type-only imports
deps = [
":node_modules/@sourcegraph/shared",
"//:node_modules/@storybook/addon-storyshots",
"//:node_modules/@storybook/addon-storyshots-puppeteer",
"//:node_modules/@types/node",
"//:node_modules/url",
],
)
npm_package(
name = "storybook_pkg",
srcs = [
"package.json",
":module_styles", #keep
":storybook_lib",
],
)

View File

@ -0,0 +1,47 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "npm_package", "ts_project")
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
],
)
ts_project(
name = "template-parser_lib",
srcs = [
"src/expr/evaluator.ts",
"src/expr/index.ts",
"src/expr/lexer.ts",
"src/expr/parser.ts",
"src/index.ts",
"src/types.ts",
],
tsconfig = ":tsconfig",
)
ts_project(
name = "template-parser_tests",
testonly = True,
srcs = [
"src/expr/evaluator.test.ts",
"src/expr/lexer.test.ts",
"src/expr/parser.test.ts",
],
tsconfig = ":tsconfig",
deps = [":template-parser_lib"],
)
npm_package(
name = "template-parser_pkg",
srcs = [
"package.json",
":template-parser_lib",
],
)

View File

@ -0,0 +1,34 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "npm_package", "ts_project")
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
],
)
ts_project(
name = "testing_lib",
srcs = [
"src/aria-asserts.ts",
"src/index.ts",
],
tsconfig = ":tsconfig",
deps = [
"//:node_modules/@types/jest", #keep
],
)
npm_package(
name = "testing_pkg",
srcs = [
"package.json",
":testing_lib",
],
)

View File

@ -1,5 +1,35 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "sass", "ts_project")
load("//client/shared/dev:generate_graphql_operations.bzl", "generate_graphql_operations")
load("//client/shared/dev:tools.bzl", "module_style_typings")
load("//dev:defs.bzl", "sass")
# TODO(bazel): webpack workers?
# gazelle:js_ignore_imports **/*.worker.ts
# gazelle:js_resolve **/*.module.scss :module_style_typings
# gazelle:js_resolve vscode //:node_modules/@types/vscode
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/branded:tsconfig",
"//client/build-config:tsconfig",
"//client/client-api:tsconfig",
"//client/codeintellify:tsconfig",
"//client/common:tsconfig",
"//client/extension-api-types:tsconfig",
"//client/http-client:tsconfig",
"//client/shared:tsconfig",
"//client/wildcard:tsconfig",
],
)
module_style_typings(
name = "module_style_typings",
@ -29,3 +59,186 @@ sass(
"//client/wildcard:global-styles",
],
)
js_library(
name = "graphql_operations_files",
# Keep in sync with glob in client/shared/dev/generateGraphQlOperations.js
srcs = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
],
# TODO: Ignore legacy build generated file as it conflicts with the Bazel
# build. This can be removed after the migration.
[
"src/graphql-operations.ts",
"src/**/*.module.scss.d.ts",
],
),
visibility = ["//client/shared:__pkg__"],
)
generate_graphql_operations(
name = "graphql_operations_ts",
srcs = [
":graphql_operations_files",
],
out = "src/graphql-operations.ts",
interface_name = "VSCodeGraphQlOperations",
visibility = ["//client/shared:__pkg__"],
)
ts_project(
name = "graphql_operations",
srcs = ["src/graphql-operations.ts"],
tsconfig = ":tsconfig",
deps = [
":node_modules/@sourcegraph/shared",
],
)
ts_project(
name = "vscode",
srcs = [
"code-intel-extensions.json",
"globals.d.ts",
"package.json",
"src/backend/authenticatedUser.ts",
"src/backend/blobContent.ts",
"src/backend/eventLogger.ts",
"src/backend/fetch.ts",
"src/backend/files.ts",
"src/backend/instanceVersion.ts",
"src/backend/node-fetch-fake-for-browser.ts",
"src/backend/proxy-agent-fake-for-browser.ts",
"src/backend/repositoryMetadata.ts",
"src/backend/requestGraphQl.ts",
"src/backend/searchContexts.ts",
"src/backend/sourcegraphSettings.ts",
"src/backend/streamSearch.ts",
"src/code-intel/SourcegraphDefinitionProvider.ts",
"src/code-intel/SourcegraphHoverProvider.ts",
"src/code-intel/SourcegraphReferenceProvider.ts",
"src/code-intel/initialize.ts",
"src/code-intel/languages.ts",
"src/code-intel/location.ts",
"src/commands/browserActionsNode.ts",
"src/commands/browserActionsWeb.ts",
"src/commands/git-helpers.ts",
"src/commands/initialize.ts",
"src/common/links.ts",
"src/contract.ts",
"src/extension.ts",
"src/file-system/FileTree.ts",
"src/file-system/FilesTreeDataProvider.ts",
"src/file-system/SourcegraphFileSystemProvider.ts",
"src/file-system/SourcegraphUri.ts",
"src/file-system/commands.ts",
"src/file-system/initialize.ts",
"src/log.ts",
"src/settings/LocalStorageService.ts",
"src/settings/accessTokenSetting.ts",
"src/settings/displayWarnings.ts",
"src/settings/endpointSetting.ts",
"src/settings/invalidation.ts",
"src/settings/readConfiguration.ts",
"src/settings/recommendations.ts",
"src/settings/uninstall.ts",
"src/state.ts",
"src/vsCodeApi.ts",
"src/webview/comlink/extensionEndpoint.ts",
"src/webview/comlink/index.ts",
"src/webview/comlink/webviewEndpoint.ts",
"src/webview/commands.ts",
"src/webview/initialize.ts",
"src/webview/platform/AuthProvider.ts",
"src/webview/platform/EventLogger.ts",
"src/webview/platform/context.ts",
"src/webview/platform/polyfills/index.ts",
"src/webview/platform/polyfills/polyfill.ts",
"src/webview/platform/telemetryService.ts",
"src/webview/search-panel/MatchHandlersContext.ts",
"src/webview/search-panel/RepoView.tsx",
"src/webview/search-panel/SearchHomeView.tsx",
"src/webview/search-panel/SearchResultsView.tsx",
"src/webview/search-panel/alias/CommitSearchResult.tsx",
"src/webview/search-panel/alias/FileMatchChildren.tsx",
"src/webview/search-panel/alias/ModalVideo.tsx",
"src/webview/search-panel/alias/RepoFileLink.tsx",
"src/webview/search-panel/alias/RepoSearchResult.tsx",
"src/webview/search-panel/alias/SymbolSearchResult.tsx",
"src/webview/search-panel/alias/fetchSearchContext.ts",
"src/webview/search-panel/api.ts",
"src/webview/search-panel/components/BrandHeader.tsx",
"src/webview/search-panel/components/ButtonDropdownCta.tsx",
"src/webview/search-panel/components/HomeFooter.tsx",
"src/webview/search-panel/components/SavedSearchForm.tsx",
"src/webview/search-panel/components/SearchExamples.tsx",
"src/webview/search-panel/components/SearchResultsInfoBar.tsx",
"src/webview/search-panel/components/icons.tsx",
"src/webview/search-panel/index.tsx",
"src/webview/sidebars/auth/AuthSidebarView.tsx",
"src/webview/sidebars/help/HelpSidebarView.tsx",
"src/webview/sidebars/help/index.tsx",
"src/webview/sidebars/history/HistorySidebarView.tsx",
"src/webview/sidebars/history/components/RecentFilesSection.tsx",
"src/webview/sidebars/history/components/RecentRepositoriesSection.tsx",
"src/webview/sidebars/history/components/RecentSearchesSection.tsx",
"src/webview/sidebars/history/components/SavedSearchesSection.tsx",
"src/webview/sidebars/search/ContextInvalidatedSidebarView.tsx",
"src/webview/sidebars/search/SearchSidebarView.tsx",
"src/webview/sidebars/search/api.ts",
"src/webview/sidebars/search/extension-host/index.ts",
"src/webview/sidebars/search/extension-host/main.worker.ts",
"src/webview/sidebars/search/extension-host/worker.ts",
"src/webview/sidebars/search/index.tsx",
"src/webview/theming/monacoTheme.ts",
"src/webview/theming/sourcegraphTheme.ts",
],
tsconfig = ":tsconfig",
# TODO(bazel): type-only #keep imports
deps = [
":graphql_operations",
":module_style_typings",
":node_modules/@sourcegraph/branded",
":node_modules/@sourcegraph/client-api", #keep
":node_modules/@sourcegraph/codeintellify", #keep
":node_modules/@sourcegraph/common",
":node_modules/@sourcegraph/extension-api-types", #keep
":node_modules/@sourcegraph/http-client",
":node_modules/@sourcegraph/shared",
":node_modules/@sourcegraph/wildcard",
"//:node_modules/@mdi/js",
"//:node_modules/@reach/visually-hidden",
"//:node_modules/@types/classnames",
"//:node_modules/@types/lodash",
"//:node_modules/@types/node",
"//:node_modules/@types/node-fetch",
"//:node_modules/@types/react",
"//:node_modules/@types/react-dom",
"//:node_modules/@types/uuid",
"//:node_modules/@types/vscode",
"//:node_modules/@vscode/webview-ui-toolkit",
"//:node_modules/agent-base", #keep
"//:node_modules/classnames",
"//:node_modules/comlink",
"//:node_modules/core-js",
"//:node_modules/execa",
"//:node_modules/graphql",
"//:node_modules/http-proxy-agent",
"//:node_modules/https-proxy-agent",
"//:node_modules/lodash",
"//:node_modules/mdi-react",
"//:node_modules/monaco-editor",
"//:node_modules/node-fetch",
"//:node_modules/react",
"//:node_modules/react-dom",
"//:node_modules/react-router-dom",
"//:node_modules/rxjs",
"//:node_modules/use-deep-compare-effect",
"//:node_modules/uuid",
"//:node_modules/zustand",
"//client/common:common_lib", #keep
"//client/shared:shared_lib", #keep
],
)

View File

@ -0,0 +1,6 @@
# TODO(bazel): disabled for now
# gazelle:js disabled
# The library itself is a testing library so put all files into the main library
# gazelle:js_files **/*.{ts,tsx}
# gazelle:js_test_files does-not-exist-to-disable

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,63 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("//dev:defs.bzl", "ts_project")
# dev/ does not contain a src/
# gazelle:js_files **/*.{ts,tsx}
# gazelle:js_test_files there-are-no-tests
# TODO(bazel): wip - currently broken
# gazelle:exclude **/server/development.server.ts
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//client/web:tsconfig",
],
)
ts_project(
name = "dev",
srcs = [
"esbuild/build.ts",
"esbuild/manifestPlugin.ts",
"esbuild/server.ts",
"mocks/mockEventLogger.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",
],
module = "commonjs",
tsconfig = ":tsconfig",
deps = [
"//:node_modules/@types/compression",
"//:node_modules/@types/connect-history-api-fallback",
"//:node_modules/@types/express",
"//:node_modules/@types/jest", #keep
"//:node_modules/@types/lodash",
"//:node_modules/@types/node",
"//: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",
"//:node_modules/webpack", #keep
"//client/web:node_modules/@sourcegraph/build-config",
"//client/web:node_modules/@sourcegraph/common",
"//client/web:web_lib", #keep
],
)

View File

@ -3,4 +3,5 @@
"compilerOptions": {
"module": "commonjs",
},
"include": ["**/*"],
}

View File

@ -0,0 +1,59 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("//dev:defs.bzl", "ts_project")
load("//dev:mocha.bzl", "mocha_test")
# end-to-end/ does not contain a src/
# gazelle:js_files **/*.{ts,tsx}
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:node_modules/@types/mocha",
"//:node_modules/@types/node",
"//client/shared/src/testing:tsconfig",
"//client/web:tsconfig",
"//schema:tsconfig",
],
)
ts_project(
name = "end-to-end",
srcs = [
"utils/cloneRepos.ts",
"utils/initEndToEndTest.ts",
],
tsconfig = ":tsconfig",
deps = [
"//:node_modules/@types/mockdate",
"//:node_modules/mockdate",
"//client/web:node_modules/@sourcegraph/shared",
],
)
ts_project(
name = "end-to-end_tests",
testonly = True,
srcs = [
"code-intel/repository-component.test.ts",
"frontend-platform/site-admin.test.ts",
"frontend-platform/theme-switcher.test.ts",
],
tsconfig = ":tsconfig",
deps = [
":end-to-end",
"//:node_modules/@types/lodash",
"//:node_modules/@types/mocha",
"//:node_modules/expect",
"//:node_modules/lodash",
"//:node_modules/mocha",
"//client/web:node_modules/@sourcegraph/shared",
],
)
mocha_test(
name = "e2e",
tests = [test.replace(".ts", ".js") for test in glob(["**/*.test.ts"])],
deps = [":end-to-end_tests"],
)

View File

@ -0,0 +1,98 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("//dev:defs.bzl", "ts_project")
# integration/ does not contain a src/
# gazelle:js_files **/*.{ts,tsx}
# gazelle:js_resolve sourcegraph //client/shared:node_modules/@sourcegraph/client-api
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//client/shared/src/testing:tsconfig",
"//client/web:tsconfig",
],
)
ts_project(
name = "integration",
srcs = [
"context.ts",
"environment.ts",
"graphQlResponseHelpers.ts",
"graphQlResults.ts",
"insights/utils/override-insights-graphql-api.ts",
"jscontext.ts",
"temporarySettingsContext.ts",
"utils.ts",
],
tsconfig = ":tsconfig",
# TODO(bazel): type-only imports
deps = [
"//:node_modules/@types/pollyjs__core", #keep
"//:node_modules/puppeteer", #keep
"//client/web:graphql_operations",
"//client/web:node_modules/@sourcegraph/common",
"//client/web:node_modules/@sourcegraph/shared",
"//client/web:web_lib", #keep
"//client/web/dev",
],
)
ts_project(
name = "integration_tests",
testonly = True,
srcs = [
"batches.test.ts",
"blob-viewer.test.ts",
"code-monitoring.test.ts",
"codemirror-blob-view.test.ts",
"commit-page.test.ts",
"insights/create-insights.test.ts",
"insights/dashboards/add-remove-insights.test.ts",
"insights/dashboards/create-dashboard.test.ts",
"insights/dashboards/delete-dashboard.test.ts",
"insights/dashboards/render-empty-dashboard.test.ts",
"insights/dashboards/render-populated-dashboard.test.ts",
"insights/dashboards/update-dashboard.test.ts",
"insights/delete-insights.test.ts",
"insights/drill-down-filters.test.ts",
"insights/edit-search-insights.test.ts",
"insights/fixtures/calculated-insights.ts",
"insights/fixtures/dashboards.ts",
"insights/fixtures/insights-metadata.ts",
"insights/fixtures/runtime-insights.ts",
"insights/insight/dashboard-cards.test.ts",
"insights/insight/insight-chart-focus.test.ts",
"insights/single-insight-page.test.ts",
"insights/utils/mock-helpers.ts",
"nav.test.ts",
"notebook.test.ts",
"org.test.ts",
"profile.test.ts",
"repository.test.ts",
"request-access.test.ts",
"search.test.ts",
"search-aggregation.test.ts",
"search-contexts.test.ts",
"settings.test.ts",
"sign-in.test.ts",
],
tsconfig = ":tsconfig",
deps = [
":integration",
"//:node_modules/@types/lodash",
"//:node_modules/@types/mocha",
"//:node_modules/@types/node",
"//:node_modules/date-fns",
"//:node_modules/delay",
"//:node_modules/expect",
"//:node_modules/lodash",
"//:node_modules/mocha",
"//:node_modules/ts-key-enum",
"//client/web:graphql_operations",
"//client/web:node_modules/@sourcegraph/common",
"//client/web:node_modules/@sourcegraph/shared",
],
)

View File

@ -0,0 +1,78 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("//dev:defs.bzl", "ts_project")
# regression/ does not contain a src/
# gazelle:js_files **/*.{ts,tsx}
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:node_modules/@types/mocha",
"//:node_modules/@types/node",
"//client/shared/src/testing:tsconfig",
"//client/web:tsconfig",
"//schema:tsconfig",
],
)
js_library(
name = "graphql_operations_files",
# Keep in sync with glob in client/shared/dev/generateGraphQlOperations.js
srcs = glob(["**/*.*"]),
visibility = ["//client/web:__pkg__"],
)
ts_project(
name = "regression",
srcs = [
"util/GraphQlClient.ts",
"util/ScreenshotVerifier.ts",
"util/TestResourceManager.ts",
"util/api.ts",
"util/helpers.ts",
"util/init.ts",
"util/settings.ts",
],
tsconfig = ":tsconfig",
deps = [
"//:node_modules/@types/lodash",
"//:node_modules/jsonc-parser",
"//:node_modules/lodash",
"//:node_modules/puppeteer", #keep
"//:node_modules/rxjs",
"//:node_modules/ts-key-enum",
"//client/web:graphql_operations", #keep
"//client/web:node_modules/@sourcegraph/common",
"//client/web:node_modules/@sourcegraph/http-client",
"//client/web:node_modules/@sourcegraph/shared",
],
)
ts_project(
name = "regression_tests",
testonly = True,
srcs = [
"codeintel.test.ts",
"core.test.ts",
"init.test.ts",
"integrations.test.ts",
],
tsconfig = ":tsconfig",
deps = [
":regression",
"//:node_modules/@types/mocha",
"//:node_modules/delay",
"//:node_modules/expect",
"//:node_modules/jsonc-parser",
"//:node_modules/mocha",
"//:node_modules/rxjs",
"//:node_modules/ts-key-enum",
"//client/web:graphql_operations",
"//client/web:node_modules/@sourcegraph/common",
"//client/web:node_modules/@sourcegraph/http-client",
"//client/web:node_modules/@sourcegraph/shared",
],
)

View File

@ -0,0 +1,296 @@
// @ts-check
const path = require('path')
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
const SentryWebpackPlugin = require('@sentry/webpack-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
const CssMinimizerWebpackPlugin = require('css-minimizer-webpack-plugin')
const mapValues = require('lodash/mapValues')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const webpack = require('webpack')
const { WebpackManifestPlugin } = require('webpack-manifest-plugin')
const { StatsWriterPlugin } = require('webpack-stats-plugin')
const {
ROOT_PATH,
STATIC_ASSETS_PATH,
getBabelLoader,
getCacheConfig,
getMonacoWebpackPlugin,
getBazelCSSLoaders: getCSSLoaders,
getTerserPlugin,
getProvidePlugin,
getCSSModulesLoader,
getMonacoCSSRule,
getMonacoTTFRule,
getBasicCSSLoader,
getStatoscopePlugin,
} = require('@sourcegraph/build-config')
const { IS_PRODUCTION, IS_DEVELOPMENT, ENVIRONMENT_CONFIG, writeIndexHTMLPlugin } = require('./dev/utils')
// const { isHotReloadEnabled } = require('./src/integration/environment')
const {
NODE_ENV,
CI: IS_CI,
INTEGRATION_TESTS,
ENTERPRISE,
EMBED_DEVELOPMENT,
ENABLE_SENTRY,
ENABLE_OPEN_TELEMETRY,
SOURCEGRAPH_API_URL,
WEBPACK_BUNDLE_ANALYZER,
WEBPACK_EXPORT_STATS_FILENAME,
WEBPACK_SERVE_INDEX,
WEBPACK_STATS_NAME,
WEBPACK_USE_NAMED_CHUNKS,
WEBPACK_DEVELOPMENT_DEVTOOL,
SENTRY_UPLOAD_SOURCE_MAPS,
COMMIT_SHA,
VERSION,
SENTRY_DOT_COM_AUTH_TOKEN,
SENTRY_ORGANIZATION,
SENTRY_PROJECT,
} = ENVIRONMENT_CONFIG
const IS_PERSISTENT_CACHE_ENABLED = IS_DEVELOPMENT && !IS_CI
const IS_EMBED_ENTRY_POINT_ENABLED = ENTERPRISE && (IS_PRODUCTION || (IS_DEVELOPMENT && EMBED_DEVELOPMENT))
const RUNTIME_ENV_VARIABLES = {
NODE_ENV,
ENABLE_SENTRY,
ENABLE_OPEN_TELEMETRY,
INTEGRATION_TESTS,
COMMIT_SHA,
...(WEBPACK_SERVE_INDEX && { SOURCEGRAPH_API_URL }),
}
const hotLoadablePaths = ['branded', 'shared', 'web', 'wildcard'].map(workspace =>
path.resolve(ROOT_PATH, 'client', workspace, 'src')
)
// Third-party npm dependencies that contain jsx syntax
const NPM_JSX = ['react-visibility-sensor/visibility-sensor.js']
const enterpriseDirectory = path.resolve(__dirname, 'src', 'enterprise')
const styleLoader = IS_DEVELOPMENT ? 'style-loader' : MiniCssExtractPlugin.loader
// Used to ensure that we include all initial chunks into the Webpack manifest.
const initialChunkNames = {
react: 'react',
opentelemetry: 'opentelemetry',
}
/** @type {import('webpack').Configuration} */
const config = {
context: process.cwd(),
mode: IS_PRODUCTION ? 'production' : 'development',
stats: {
// Minimize logging in case if Webpack is used along with multiple other services.
// Use `normal` output preset in case of running standalone web server.
preset: WEBPACK_SERVE_INDEX || IS_PRODUCTION ? 'normal' : 'errors-warnings',
errorDetails: true,
timings: true,
},
infrastructureLogging: {
// Controls webpack-dev-server logging level.
level: 'warn',
},
target: 'browserslist',
// Use cache only in `development` mode to speed up production build.
cache: IS_PERSISTENT_CACHE_ENABLED && getCacheConfig({ invalidateCacheFiles: [] }),
optimization: {
minimize: IS_PRODUCTION,
minimizer: [getTerserPlugin(), new CssMinimizerWebpackPlugin()],
splitChunks: {
cacheGroups: {
[initialChunkNames.react]: {
test: /[/\\]node_modules.*[/\\](react|react-dom)[/\\]/,
name: initialChunkNames.react,
chunks: 'all',
},
[initialChunkNames.opentelemetry]: {
test: /[/\\]node_modules.*[/\\](@opentelemetry)[/\\]/,
name: initialChunkNames.opentelemetry,
chunks: 'all',
},
},
},
...(IS_DEVELOPMENT && {
removeAvailableModules: false,
removeEmptyChunks: false,
splitChunks: false,
}),
},
// entry: { ... SET BY BAZEL RULE ... }
// TODO(bazel): why is this sest by webpack_bundle() but not webpack_dev_server()?
entry: {
app: './client/web/src/main.js',
},
devServer: {
port: 8080,
},
output: {
// path: STATIC_ASSETS_PATH,
// Do not [hash] for development -- see https://github.com/webpack/webpack-dev-server/issues/377#issuecomment-241258405
// Note: [name] will vary depending on the Webpack chunk. If specified, it will use a provided chunk name, otherwise it will fallback to a deterministic id.
filename:
IS_PRODUCTION && !WEBPACK_USE_NAMED_CHUNKS
? 'scripts/[name].[contenthash].bundle.js'
: 'scripts/[name].bundle.js',
chunkFilename:
IS_PRODUCTION && !WEBPACK_USE_NAMED_CHUNKS ? 'scripts/[name]-[contenthash].chunk.js' : 'scripts/[name].chunk.js',
publicPath: '/.assets/',
globalObject: 'self',
pathinfo: false,
},
// Inline source maps for integration tests to preserve readable stack traces.
// See related issue here: https://github.com/puppeteer/puppeteer/issues/985
devtool: IS_PRODUCTION ? (INTEGRATION_TESTS ? 'inline-source-map' : 'source-map') : WEBPACK_DEVELOPMENT_DEVTOOL,
plugins: [
// Change scss imports to the pre-compiled css files
new webpack.NormalModuleReplacementPlugin(/.*\.scss$/, resource => {
resource.request = resource.request.replace(/\.scss$/, '.css')
}),
// TODO(bazel): implement *.worker.ts support
new webpack.IgnorePlugin({
resourceRegExp: /.*\.worker\.ts/,
}),
new webpack.DefinePlugin({
'process.env': mapValues(RUNTIME_ENV_VARIABLES, JSON.stringify),
}),
// TODO(bazel): why does the provide plugin crash?
// getProvidePlugin(),
new MiniCssExtractPlugin({
// Do not [hash] for development -- see https://github.com/webpack/webpack-dev-server/issues/377#issuecomment-241258405
filename:
IS_PRODUCTION && !WEBPACK_USE_NAMED_CHUNKS
? 'styles/[name].[contenthash].bundle.css'
: 'styles/[name].bundle.css',
}),
// getMonacoWebpackPlugin(),
new WebpackManifestPlugin({
writeToFileEmit: false,
fileName: 'webpack.manifest.json',
seed: {
environment: NODE_ENV,
},
// Only output files that are required to run the application.
filter: ({ isInitial, name }) =>
isInitial || Object.values(initialChunkNames).some(initialChunkName => name?.includes(initialChunkName)),
}),
...(WEBPACK_SERVE_INDEX && IS_PRODUCTION ? [writeIndexHTMLPlugin] : []),
WEBPACK_BUNDLE_ANALYZER && getStatoscopePlugin(WEBPACK_STATS_NAME),
// isHotReloadEnabled && new ReactRefreshWebpackPlugin({ overlay: false }),
IS_PRODUCTION &&
new CompressionPlugin({
filename: '[path][base].gz',
algorithm: 'gzip',
test: /\.(js|css|svg)$/,
compressionOptions: {
/** Maximum compression level for Gzip */
level: 9,
},
}),
IS_PRODUCTION &&
new CompressionPlugin({
filename: '[path][base].br',
algorithm: 'brotliCompress',
test: /\.(js|css|svg)$/,
compressionOptions: {
/** Maximum compression level for Brotli */
level: 11,
},
/**
* We get little/no benefits from compressing files that are already under this size.
* We can fall back to dynamic gzip for these.
*/
threshold: 10240,
}),
VERSION &&
SENTRY_UPLOAD_SOURCE_MAPS &&
new SentryWebpackPlugin({
silent: true,
org: SENTRY_ORGANIZATION,
project: SENTRY_PROJECT,
authToken: SENTRY_DOT_COM_AUTH_TOKEN,
release: `frontend@${VERSION}`,
include: path.join(STATIC_ASSETS_PATH, 'scripts', '*.map'),
}),
WEBPACK_EXPORT_STATS_FILENAME &&
new StatsWriterPlugin({
filename: WEBPACK_EXPORT_STATS_FILENAME,
stats: {
all: false, // disable all the stats
hash: true, // compilation hash
entrypoints: true,
chunks: true,
chunkModules: true, // modules
ids: true, // IDs of modules and chunks (webpack 5)
cachedAssets: true, // information about the cached assets (webpack 5)
nestedModules: true, // concatenated modules
usedExports: true,
assets: true,
chunkOrigins: true, // chunks origins stats (to find out which modules require a chunk)
timings: true, // modules timing information
performance: true, // info about oversized assets
},
}),
].filter(Boolean),
resolve: {
extensions: ['.mjs', '.jsx', '.js', '.json'],
mainFields: ['es2015', 'module', 'browser', 'main'],
fallback: {
path: require.resolve('path-browserify'),
punycode: require.resolve('punycode'),
util: require.resolve('util'),
},
alias: {
// react-visibility-sensor's main field points to a UMD bundle instead of ESM
// https://github.com/joshwnj/react-visibility-sensor/issues/148
'react-visibility-sensor': require.resolve('react-visibility-sensor').replace('/dist/', '/'),
},
},
module: {
rules: [
// Some third-party deps need jsx transpiled still
{
test: new RegExp('node_modules/' + NPM_JSX.join('|')),
use: [{ loader: require.resolve('babel-loader') }],
},
{
test: /\.m?js$/,
type: 'javascript/auto',
resolve: {
// Allow importing without file extensions
// https://webpack.js.org/configuration/module/#resolvefullyspecified
fullySpecified: false,
},
},
// TODO(bazel): why is this required when it is supposedly enabled by default?
{
test: /\.json$/,
type: 'json',
},
{
test: /\.css$/,
// CSS Modules loaders are only applied when the file is explicitly named as CSS module stylesheet using the extension `.module.scss`.
include: /\.module\.css$/,
use: getCSSLoaders(styleLoader, getCSSModulesLoader({ sourceMap: IS_DEVELOPMENT })),
},
{
test: /\.css$/,
exclude: /\.module\.css$/,
use: getCSSLoaders(styleLoader, getBasicCSSLoader()),
},
getMonacoTTFRule(),
{ test: /\.ya?ml$/, type: 'asset/source' },
{ test: /\.(png|woff2)$/, type: 'asset/resource' },
],
},
}
module.exports = config

View File

@ -1,6 +1,27 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "jest_test", "npm_package", "sass", "ts_project")
load("//client/shared/dev:tools.bzl", "module_style_typings")
load("//dev:defs.bzl", "sass")
# TODO(bazel): storybook build
# gazelle:exclude **/*.story.{ts,tsx}
# gazelle:js_resolve **/*.module.scss :module_style_typings
# gazelle:js_ignore_imports **/global-styles/index.scss
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/common:tsconfig",
"//client/testing:tsconfig",
],
)
npm_link_all_packages(name = "node_modules")
module_style_typings(
name = "module_style_typings",
@ -8,7 +29,6 @@ module_style_typings(
":sass-breakpoints",
"//:node_modules/@reach/dialog",
"//:node_modules/@reach/tabs",
"//:node_modules/open-color",
],
)
@ -70,3 +90,463 @@ copy_to_bin(
srcs = SASS_UTILS,
visibility = ["//visibility:public"],
)
ts_project(
name = "wildcard_lib",
srcs = [
"globals.d.ts",
"src/components/Alert/Alert.tsx",
"src/components/Alert/AlertLink.tsx",
"src/components/Alert/constants.ts",
"src/components/Alert/index.ts",
"src/components/Alert/utils.ts",
"src/components/Badge/Badge.tsx",
"src/components/Badge/ProductStatusBadge.tsx",
"src/components/Badge/constants.ts",
"src/components/Badge/index.ts",
"src/components/BeforeUnloadPrompt/BeforeUnloadPrompt.tsx",
"src/components/BeforeUnloadPrompt/index.ts",
"src/components/Button/Button.tsx",
"src/components/Button/ButtonGroup.tsx",
"src/components/Button/constants.ts",
"src/components/Button/index.ts",
"src/components/Button/story/ButtonVariants.tsx",
"src/components/Button/utils.ts",
"src/components/ButtonLink/ButtonLink.tsx",
"src/components/ButtonLink/index.ts",
"src/components/Card/Card.tsx",
"src/components/Card/components/CardBody.tsx",
"src/components/Card/components/CardFooter.tsx",
"src/components/Card/components/CardHeader.tsx",
"src/components/Card/components/CardList.tsx",
"src/components/Card/components/CardSubtitle.tsx",
"src/components/Card/components/CardText.tsx",
"src/components/Card/components/CardTitle.tsx",
"src/components/Card/components/index.ts",
"src/components/Card/constants.ts",
"src/components/Card/index.ts",
"src/components/Charts/components/bar-chart/BarChart.tsx",
"src/components/Charts/components/bar-chart/BarChartContent.tsx",
"src/components/Charts/components/bar-chart/components/GroupedBars.tsx",
"src/components/Charts/components/bar-chart/components/StackedBars.tsx",
"src/components/Charts/components/bar-chart/components/TooltipContent.tsx",
"src/components/Charts/components/bar-chart/index.ts",
"src/components/Charts/components/bar-chart/types.ts",
"src/components/Charts/components/bar-chart/utils/get-grouped-categories.ts",
"src/components/Charts/components/line-chart/LineChart.tsx",
"src/components/Charts/components/line-chart/LineChartContent.tsx",
"src/components/Charts/components/line-chart/components/LineDataSeries.tsx",
"src/components/Charts/components/line-chart/components/PointGlyph.tsx",
"src/components/Charts/components/line-chart/components/index.ts",
"src/components/Charts/components/line-chart/components/legend-list/LegendList.tsx",
"src/components/Charts/components/line-chart/components/stacked-area/StackedArea.tsx",
"src/components/Charts/components/line-chart/components/stacked-area/get-stacked-area-paths.ts",
"src/components/Charts/components/line-chart/components/tooltip/TooltipContent.tsx",
"src/components/Charts/components/line-chart/components/tooltip/index.ts",
"src/components/Charts/components/line-chart/components/tooltip/utils/get-list-window.ts",
"src/components/Charts/components/line-chart/event-helpers.ts",
"src/components/Charts/components/line-chart/index.ts",
"src/components/Charts/components/line-chart/keyboard-navigation.ts",
"src/components/Charts/components/line-chart/types.ts",
"src/components/Charts/components/line-chart/utils/colors.ts",
"src/components/Charts/components/line-chart/utils/data-guards.ts",
"src/components/Charts/components/line-chart/utils/data-series-processing/get-series-data.ts",
"src/components/Charts/components/line-chart/utils/data-series-processing/get-stacked-series-data.ts",
"src/components/Charts/components/line-chart/utils/data-series-processing/helpers.ts",
"src/components/Charts/components/line-chart/utils/data-series-processing/index.ts",
"src/components/Charts/components/line-chart/utils/data-series-processing/types.ts",
"src/components/Charts/components/line-chart/utils/generate-points-field.ts",
"src/components/Charts/components/line-chart/utils/get-chart-content-sizes.ts",
"src/components/Charts/components/line-chart/utils/get-min-max-boundary.ts",
"src/components/Charts/components/line-chart/utils/index.ts",
"src/components/Charts/components/pie-chart/PieChart.tsx",
"src/components/Charts/components/pie-chart/components/PieArc.tsx",
"src/components/Charts/components/pie-chart/index.ts",
"src/components/Charts/components/stacked-meter/StackedMeter.tsx",
"src/components/Charts/components/stacked-meter/index.ts",
"src/components/Charts/constants.ts",
"src/components/Charts/core/components/MaybeLink.tsx",
"src/components/Charts/core/components/SvgRoot.tsx",
"src/components/Charts/core/components/axis/Axis.tsx",
"src/components/Charts/core/components/axis/Tick.tsx",
"src/components/Charts/core/components/axis/tick-formatters.ts",
"src/components/Charts/core/components/scroll-box/ScrollBox.tsx",
"src/components/Charts/core/components/scroll-box/index.ts",
"src/components/Charts/core/components/tooltip/Tooltip.tsx",
"src/components/Charts/core/index.ts",
"src/components/Charts/index.ts",
"src/components/Charts/types.ts",
"src/components/Collapse/Collapse.tsx",
"src/components/Collapse/index.ts",
"src/components/Combobox/Combobox.tsx",
"src/components/Combobox/MultiCombobox.tsx",
"src/components/Combobox/index.ts",
"src/components/Container/Container.tsx",
"src/components/Container/index.ts",
"src/components/ErrorAlert/ErrorAlert.tsx",
"src/components/ErrorAlert/index.ts",
"src/components/ErrorMessage/ErrorMessage.tsx",
"src/components/ErrorMessage/index.ts",
"src/components/Feedback/FeedbackBadge/FeedbackBadge.tsx",
"src/components/Feedback/FeedbackBadge/constant.ts",
"src/components/Feedback/FeedbackBadge/index.ts",
"src/components/Feedback/FeedbackPrompt/FeedbackPrompt.tsx",
"src/components/Feedback/FeedbackPrompt/index.ts",
"src/components/Feedback/FeedbackText/FeedbackText.tsx",
"src/components/Feedback/FeedbackText/index.ts",
"src/components/Feedback/index.ts",
"src/components/Form/Checkbox/Checkbox.tsx",
"src/components/Form/Checkbox/index.tsx",
"src/components/Form/FlexTextArea/FlexTextArea.tsx",
"src/components/Form/FlexTextArea/index.ts",
"src/components/Form/Form/Form.tsx",
"src/components/Form/Form/getDefaultInputProps.ts",
"src/components/Form/Form/hooks/index.ts",
"src/components/Form/Form/hooks/useCheckboxes.ts",
"src/components/Form/Form/hooks/useField.ts",
"src/components/Form/Form/hooks/useForm.ts",
"src/components/Form/Form/hooks/utils/get-event-value.ts",
"src/components/Form/Form/hooks/utils/use-async-validation.ts",
"src/components/Form/Form/hooks/validators.ts",
"src/components/Form/Form/index.ts",
"src/components/Form/FormGroup/FormGroup.tsx",
"src/components/Form/FormGroup/index.ts",
"src/components/Form/Input/Input.tsx",
"src/components/Form/Input/index.tsx",
"src/components/Form/Input/utils/getInputStatus.ts",
"src/components/Form/LoaderInput/LoaderInput.tsx",
"src/components/Form/LoaderInput/index.ts",
"src/components/Form/RadioButton/RadioButton.tsx",
"src/components/Form/RadioButton/index.tsx",
"src/components/Form/Select/Select.tsx",
"src/components/Form/Select/index.ts",
"src/components/Form/TextArea/TextArea.tsx",
"src/components/Form/TextArea/index.ts",
"src/components/Form/index.ts",
"src/components/Form/internal/AccessibleFieldType.ts",
"src/components/Form/internal/BaseControlInput.tsx",
"src/components/Form/internal/FormFieldLabel.tsx",
"src/components/Form/internal/FormFieldMessage.tsx",
"src/components/Form/internal/utils.ts",
"src/components/Grid/Grid.tsx",
"src/components/Grid/index.tsx",
"src/components/Icon/Icon.tsx",
"src/components/Icon/constants.ts",
"src/components/Icon/index.ts",
"src/components/Link/AnchorLink/AnchorLink.tsx",
"src/components/Link/AnchorLink/index.ts",
"src/components/Link/Link/Link.tsx",
"src/components/Link/Link/index.ts",
"src/components/Link/LinkOrSpan/LinkOrSpan.tsx",
"src/components/Link/LinkOrSpan/index.ts",
"src/components/Link/RouterLink/RouterLink.tsx",
"src/components/Link/RouterLink/index.ts",
"src/components/Link/createLinkUrl.tsx",
"src/components/Link/index.ts",
"src/components/LoadingSpinner/LoadingSpinner.tsx",
"src/components/LoadingSpinner/index.ts",
"src/components/Markdown/Markdown.tsx",
"src/components/Markdown/index.ts",
"src/components/Menu/Menu.tsx",
"src/components/Menu/MenuButton.tsx",
"src/components/Menu/MenuDisabledItem.tsx",
"src/components/Menu/MenuDivider.tsx",
"src/components/Menu/MenuHeader.tsx",
"src/components/Menu/MenuItem.tsx",
"src/components/Menu/MenuLink.tsx",
"src/components/Menu/MenuList.tsx",
"src/components/Menu/MenuText.tsx",
"src/components/Menu/index.ts",
"src/components/Modal/Modal.tsx",
"src/components/Modal/constants.ts",
"src/components/Modal/index.ts",
"src/components/NavMenu/NavMenu.tsx",
"src/components/NavMenu/index.ts",
"src/components/PageHeader/Breadcrumb/Breadcrumb.tsx",
"src/components/PageHeader/Breadcrumb/index.ts",
"src/components/PageHeader/Heading/Heading.tsx",
"src/components/PageHeader/Heading/index.ts",
"src/components/PageHeader/PageHeader.tsx",
"src/components/PageHeader/index.ts",
"src/components/PageSelector/PageSelector.tsx",
"src/components/PageSelector/index.tsx",
"src/components/PageSwitcher/PageSwitcher.tsx",
"src/components/PageSwitcher/index.tsx",
"src/components/Panel/Panel.tsx",
"src/components/Panel/constants.ts",
"src/components/Panel/index.ts",
"src/components/Panel/story/TabbedPanelContent.fixtures.ts",
"src/components/Panel/useResizablePanel.ts",
"src/components/Panel/utils.ts",
"src/components/Popover/Popover.tsx",
"src/components/Popover/components/PopoverTrigger.tsx",
"src/components/Popover/components/floating-panel/FloatingPanel.tsx",
"src/components/Popover/components/popover-content/PopoverContent.tsx",
"src/components/Popover/components/popover-content/index.ts",
"src/components/Popover/components/popover-tail/PopoverTail.tsx",
"src/components/Popover/components/popover-tail/index.ts",
"src/components/Popover/contexts/internal-context.ts",
"src/components/Popover/contexts/public-context.ts",
"src/components/Popover/index.ts",
"src/components/Popover/tether/index.ts",
"src/components/Popover/tether/models/geometry/point.ts",
"src/components/Popover/tether/models/geometry/rectangle.ts",
"src/components/Popover/tether/models/tether-models.ts",
"src/components/Popover/tether/services/geometry/actions/get-constrained-element.ts",
"src/components/Popover/tether/services/geometry/actions/get-element-constraints.ts",
"src/components/Popover/tether/services/geometry/actions/get-elements-intersection.ts",
"src/components/Popover/tether/services/geometry/actions/get-extended-constraint.ts",
"src/components/Popover/tether/services/geometry/actions/get-joined-element.ts",
"src/components/Popover/tether/services/geometry/actions/get-target-element.ts",
"src/components/Popover/tether/services/geometry/actions/rectangle-position-helpers.ts",
"src/components/Popover/tether/services/geometry/actions/tooltip-marker-utils.ts",
"src/components/Popover/tether/services/geometry/constants.ts",
"src/components/Popover/tether/services/geometry/index.ts",
"src/components/Popover/tether/services/tether-browser.ts",
"src/components/Popover/tether/services/tether-layout.ts",
"src/components/Popover/tether/services/tether-position.ts",
"src/components/Popover/tether/services/tether-registry.ts",
"src/components/Popover/tether/services/tether-render.ts",
"src/components/Popover/tether/services/tether-state.ts",
"src/components/Popover/tether/services/types.ts",
"src/components/Popover/types.ts",
"src/components/SourcegraphIcon/SourcegraphIcon.tsx",
"src/components/SourcegraphIcon/index.ts",
"src/components/Tabs/Tabs.tsx",
"src/components/Tabs/context.ts",
"src/components/Tabs/index.ts",
"src/components/Tabs/useScrollBackToActive.ts",
"src/components/Tabs/useShouldPanelRender.ts",
"src/components/Tooltip/Tooltip.tsx",
"src/components/Tooltip/index.ts",
"src/components/Tree/Tree.tsx",
"src/components/Tree/index.ts",
"src/components/Tree/react-accessible-treeview/index.tsx",
"src/components/Tree/react-accessible-treeview/utils.ts",
"src/components/Typography/Code/Code.tsx",
"src/components/Typography/Code/index.ts",
"src/components/Typography/Heading/H1.tsx",
"src/components/Typography/Heading/H2.tsx",
"src/components/Typography/Heading/H3.tsx",
"src/components/Typography/Heading/H4.tsx",
"src/components/Typography/Heading/H5.tsx",
"src/components/Typography/Heading/H6.tsx",
"src/components/Typography/Heading/Heading.tsx",
"src/components/Typography/Heading/index.ts",
"src/components/Typography/Label/Label.tsx",
"src/components/Typography/Label/index.ts",
"src/components/Typography/Label/utils.ts",
"src/components/Typography/Text/Text.tsx",
"src/components/Typography/Text/index.ts",
"src/components/Typography/constants.ts",
"src/components/Typography/index.ts",
"src/components/Typography/utils.ts",
"src/components/index.ts",
"src/global-styles/GlobalStylesStory/ColorVariants/ColorVariants.tsx",
"src/global-styles/GlobalStylesStory/ColorVariants/index.ts",
"src/global-styles/GlobalStylesStory/FormFieldVariants/FormFieldVariants.tsx",
"src/global-styles/GlobalStylesStory/FormFieldVariants/index.ts",
"src/global-styles/GlobalStylesStory/TextVariants/TextVariants.tsx",
"src/global-styles/GlobalStylesStory/TextVariants/index.ts",
"src/global-styles/GlobalStylesStory/constants.ts",
"src/global-styles/GlobalStylesStory/utils.ts",
"src/hooks/index.ts",
"src/hooks/useAccordion.ts",
"src/hooks/useAutoFocus.ts",
"src/hooks/useControlledState.ts",
"src/hooks/useDebounce.ts",
"src/hooks/useDeepMemo.ts",
"src/hooks/useElementObscuredArea.ts",
"src/hooks/useFocusOnLoadedMore.ts",
"src/hooks/useInterval.ts",
"src/hooks/useIsMounted.ts",
"src/hooks/useIsTruncated.ts",
"src/hooks/useKeyboard.ts",
"src/hooks/useLocalStorage.ts",
"src/hooks/useMatchMedia.ts",
"src/hooks/useMeasure.ts",
"src/hooks/useObservable.ts",
"src/hooks/useOffsetPagination.ts",
"src/hooks/useOnClickOutside.ts",
"src/hooks/usePrompt.tsx",
"src/hooks/useSearchParameters.ts",
"src/hooks/useSessionStorage.ts",
"src/hooks/useStopwatch.ts",
"src/hooks/useStorageHook.ts",
"src/hooks/useTimeoutManager.ts",
"src/hooks/useUpdateEffect.ts",
"src/hooks/useWildcardTheme.tsx",
"src/hooks/useWindowSize.ts",
"src/index.ts",
"src/stories/BrandedStory.tsx",
"src/stories/hooks/index.ts",
"src/stories/hooks/useChromaticTheme.ts",
"src/stories/hooks/usePrependStyles.ts",
"src/stories/hooks/useStorybookTheme.ts",
"src/stories/index.ts",
"src/stories/utils/isChromatic.ts",
"src/testing/index.ts",
"src/testing/render-with-branded-context.tsx",
"src/types.ts",
"src/utils/index.ts",
"src/utils/linkClickHandler.ts",
"src/utils/screenReaderAnnounce.ts",
"src/viewports.ts",
],
data = [
":global-styles",
],
tsconfig = ":tsconfig",
deps = [
":module_style_typings",
":node_modules/@sourcegraph/common",
"//:node_modules/@mdi/js",
"//:node_modules/@reach/auto-id",
"//:node_modules/@reach/combobox",
"//:node_modules/@reach/dialog",
"//:node_modules/@reach/menu-button",
"//:node_modules/@reach/tabs",
"//:node_modules/@reach/visually-hidden",
"//:node_modules/@react-aria/live-announcer",
"//:node_modules/@testing-library/react",
"//:node_modules/@types/classnames",
"//:node_modules/@types/d3-format",
"//:node_modules/@types/d3-scale", #keep
"//:node_modules/@types/d3-shape", #keep
"//:node_modules/@types/d3-time-format",
"//:node_modules/@types/d3-voronoi", #keep
"//:node_modules/@types/history", #keep
"//:node_modules/@types/lodash",
"//:node_modules/@types/node", #keep
"//:node_modules/@types/react",
"//:node_modules/@types/react-dom",
"//:node_modules/@types/uuid",
"//:node_modules/@visx/annotation",
"//:node_modules/@visx/axis",
"//:node_modules/@visx/event",
"//:node_modules/@visx/glyph",
"//:node_modules/@visx/grid",
"//:node_modules/@visx/group",
"//:node_modules/@visx/responsive",
"//:node_modules/@visx/scale",
"//:node_modules/@visx/shape",
"//:node_modules/@visx/text", #keep
"//:node_modules/@visx/voronoi",
"//:node_modules/chromatic",
"//:node_modules/classnames",
"//:node_modules/d3-format",
"//:node_modules/d3-scale", #keep
"//:node_modules/d3-shape", #keep
"//:node_modules/d3-time-format",
"//:node_modules/d3-voronoi", #keep
"//:node_modules/history", #keep
"//:node_modules/is-absolute-url",
"//:node_modules/lodash",
"//:node_modules/mdi-react",
"//:node_modules/react",
"//:node_modules/react-dom",
"//:node_modules/react-focus-lock",
"//:node_modules/react-router-dom",
"//:node_modules/react-spring",
"//:node_modules/rxjs",
"//:node_modules/storybook-addon-designs",
"//:node_modules/storybook-dark-mode",
"//:node_modules/ts-key-enum",
"//:node_modules/use-callback-ref",
"//:node_modules/use-resize-observer",
"//:node_modules/utility-types", #keep
"//:node_modules/uuid",
],
)
ts_project(
name = "wildcard_tests",
testonly = True,
srcs = [
"src/components/Alert/Alert.test.tsx",
"src/components/Button/Button.test.tsx",
"src/components/ButtonLink/ButtonLink.test.tsx",
"src/components/Card/Card.test.tsx",
"src/components/Charts/components/line-chart/LineChart.test.tsx",
"src/components/Charts/components/line-chart/components/tooltip/utils/get-list-window.test.ts",
"src/components/Charts/components/line-chart/story/mocks.ts",
"src/components/Charts/components/line-chart/utils/data-series-processing/get-series-data.test.ts",
"src/components/Charts/components/line-chart/utils/get-min-max-boundary.test.ts",
"src/components/Charts/components/stacked-meter/StackedMeter.test.tsx",
"src/components/Collapse/Collapse.test.tsx",
"src/components/ErrorAlert/ErrorAlert.test.tsx",
"src/components/Feedback/FeedbackBadge/FeedbackBadge.test.tsx",
"src/components/Feedback/FeedbackPrompt/FeedbackPrompt.test.tsx",
"src/components/Feedback/FeedbackText/FeedbackText.test.tsx",
"src/components/Form/Input/Input.test.tsx",
"src/components/Form/LoaderInput/LoaderInput.test.tsx",
"src/components/Form/Select/Select.test.tsx",
"src/components/Form/TextArea/TextArea.test.tsx",
"src/components/Form/internal/BaseControlInput.test.tsx",
"src/components/Icon/Icon.test.tsx",
"src/components/Link/AnchorLink/AnchorLink.test.tsx",
"src/components/Link/LinkOrSpan/LinkOrSpan.test.tsx",
"src/components/Link/RouterLink/RouterLink.test.tsx",
"src/components/Link/createLinkUrl.test.tsx",
"src/components/Markdown/Markdown.test.tsx",
"src/components/NavMenu/NavMenu.test.tsx",
"src/components/PageHeader/PageHeader.test.tsx",
"src/components/PageSelector/PageSelector.test.tsx",
"src/components/PageSwitcher/PageSwitcher.test.tsx",
"src/components/Panel/Panel.test.tsx",
"src/components/Popover/tether/models/geometry/rectangle.spec.ts",
"src/components/Popover/tether/services/geometry/actions/get-constrained-element.spec.ts",
"src/components/Tabs/Tabs.test.tsx",
"src/components/Tooltip/Tooltip.test.tsx",
"src/components/Tree/Tree.test.tsx",
"src/components/Typography/Code/Code.test.tsx",
"src/components/Typography/Heading/H1.test.tsx",
"src/components/Typography/Heading/H2.test.tsx",
"src/components/Typography/Heading/H3.test.tsx",
"src/components/Typography/Heading/H4.test.tsx",
"src/components/Typography/Heading/H5.test.tsx",
"src/components/Typography/Heading/H6.test.tsx",
"src/components/Typography/Label/Label.test.tsx",
"src/components/Typography/Text/Text.test.tsx",
"src/hooks/useObservable.test.ts",
"src/hooks/useTimeoutManager.test.ts",
"src/utils/linkClickHandler.test.tsx",
],
tsconfig = ":tsconfig",
deps = [
":node_modules/@sourcegraph/testing",
":wildcard_lib",
"//:node_modules/@mdi/js",
"//:node_modules/@storybook/react", #keep
"//:node_modules/@testing-library/react",
"//:node_modules/@testing-library/user-event",
"//:node_modules/@types/history",
"//:node_modules/@types/node",
"//:node_modules/@types/react",
"//:node_modules/@types/sinon",
"//:node_modules/expect",
"//:node_modules/history",
"//:node_modules/mdi-react",
"//:node_modules/react",
"//:node_modules/rxjs",
"//:node_modules/sinon",
],
)
npm_package(
name = "wildcard_pkg",
srcs = [
"package.json",
":module_styles", #keep
":wildcard_lib",
],
)
jest_test(
name = "test",
data = [
":wildcard_tests",
],
# TODO(bazel): enable when snapshots updated to support pre-compiled .js files
tags = ["manual"],
)

View File

@ -0,0 +1,6 @@
load("@aspect_rules_webpack//webpack:defs.bzl", "webpack_binary")
webpack_binary(
name = "webpack",
node_modules = "//:node_modules",
)

76
dev/babel.bzl Normal file
View File

@ -0,0 +1,76 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@npm//:@babel/cli/package_json.bzl", "bin")
def babel(name, srcs, module = None, **kwargs):
# rules_js runs in the execroot under the output tree in bazel-out/[arch]/bin
execroot = "../../.."
visibility = kwargs.pop("visibility", ["//visibility:public"])
source_map = kwargs.pop("source_map", True)
ts_srcs = []
outs = []
data = kwargs.pop("data", [])
deps = kwargs.pop("deps", [])
# Collect the srcs to compile and expected outputs
for src in srcs:
# JSON does not need to be compiled
if src.endswith(".json"):
data.append(src)
continue
# dts are only for type-checking and not to be compiled
if src.endswith(".d.ts"):
continue
if not (src.endswith(".ts") or src.endswith(".tsx")):
fail("babel example transpiler only supports source .ts[x] files, got: %s" % src)
ts_srcs.append(src)
# Predict the output paths where babel will write
js_out = src.replace(".tsx", ".js").replace(".ts", ".js")
outs.append(js_out)
if source_map:
outs.append(js_out + ".map")
# see https://babeljs.io/docs/en/babel-cli
args = [
native.package_name(),
"--config-file",
"{}/$(location {})".format(execroot, "//:babel_config"),
"--presets=@babel/preset-typescript",
"--source-maps",
"true" if source_map else "false",
"--extensions",
".ts,.tsx",
"--out-dir",
"{}/{}".format(".", native.package_name()),
]
env = {}
if module != None:
env["BABEL_MODULE"] = module
bin.babel(
name = "{}_lib".format(name),
progress_message = "Compiling {}:{}".format(native.package_name(), name),
srcs = ts_srcs + [
"//:babel_config",
"//:package_json",
],
outs = outs,
args = args,
env = env,
**kwargs
)
js_library(
name = name,
srcs = outs,
deps = deps,
data = data,
visibility = visibility,
)

View File

@ -1,26 +1,130 @@
load("@bazel_skylib//lib:partial.bzl", "partial")
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@aspect_rules_js//npm:defs.bzl", _npm_package = "npm_package")
load("@aspect_rules_ts//ts:defs.bzl", _ts_project = "ts_project")
load("@aspect_rules_jest//jest:defs.bzl", _jest_test = "jest_test")
load(":sass.bzl", _sass = "sass")
load(":babel.bzl", _babel = "babel")
# Experiment using raw babel instead of tsc.
# TODO(bazel): ts_project(tsc=babel) currently still runs tsc to carry
# .d.ts when going into an npm_package().
# For now use raw babel without any type-checking
USE_RAW_BABEL = True
sass = _sass
def ts_project(name, deps = [], **kwargs):
deps = deps + [
"//:node_modules/tslib",
]
"""Default arguments for ts_project."""
visibility = kwargs.pop("visibility", ["//visibility:public"])
# Add standard test libraries for the repo test frameworks
if kwargs.get("testonly", False):
deps = deps + [d for d in [
"//:node_modules/@types/jest",
"//:node_modules/@types/mocha",
"//:node_modules/@types/testing-library__jest-dom",
] if not d in deps]
if USE_RAW_BABEL:
_ts_project_babel_impl(name, deps = deps, visibility = visibility, **kwargs)
else:
_ts_project_tsc_impl(name, deps = deps, visibility = visibility, **kwargs)
# ts_project() as an alias to babel with no type-checking or dts
def _ts_project_babel_impl(name, **kwargs):
# no tsconfig with babel
kwargs.pop("tsconfig", None)
kwargs.pop("allow_js", None)
kwargs.pop("incremental", None)
kwargs.pop("composite", None)
kwargs.pop("declaration_map", None)
kwargs.pop("emit_declaration_only", None)
_babel(
name = name,
**kwargs
)
# ts_project() with full type-checking etc
def _ts_project_tsc_impl(name, visibility, **kwargs):
tsconfig = kwargs.pop("tsconfig", "//:tsconfig")
# Default arguments for ts_project.
_ts_project(
name = name,
deps = deps,
deps = kwargs.pop("deps", []),
# tsconfig options
tsconfig = "//:tsconfig",
composite = True,
declaration = True,
declaration_map = True,
resolve_json_module = True,
source_map = True,
# tsconfig options, default to the root
tsconfig = tsconfig,
composite = kwargs.pop("composite", True),
declaration = kwargs.pop("declaration", True),
declaration_map = kwargs.pop("declaration_map", True),
resolve_json_module = kwargs.pop("resolve_json_module", True),
source_map = kwargs.pop("source_map", True),
preserve_jsx = kwargs.pop("preserve_jsx", None),
visibility = visibility,
# use babel as the transpiler
transpiler = partial.make(
_babel,
module = kwargs.pop("module", None),
tags = kwargs.get("tags", []),
visibility = visibility,
testonly = kwargs.get("testonly", None),
),
supports_workers = False,
# Allow any other args
**kwargs
)
sass = _sass
def npm_package(name, srcs = [], **kwargs):
replace_prefixes = kwargs.pop("replace_prefixes", {})
package_type = kwargs.pop("type", "module")
# Modifications to package.json
# TODO(bazel): remove when package.json can be updated in source
srcs_no_pkg = [s for s in srcs if s != "package.json"]
if len(srcs) > len(srcs_no_pkg):
updated_pkg = "_%s_package" % name
updated_pkg_json = "%s.json" % updated_pkg
# remove references to .ts in package.json files
expand_template(
name = updated_pkg,
template = "package.json",
out = updated_pkg_json,
substitutions = {
"src/index.ts": "src/index.js",
"\"name\"": "\"type\": \"%s\",\n \"name\"" % package_type,
},
)
replace_prefixes[updated_pkg_json] = "package.json"
srcs = srcs_no_pkg + [updated_pkg_json]
_npm_package(
name = name,
srcs = srcs,
replace_prefixes = replace_prefixes,
# Default visiblity
visibility = kwargs.pop("visibility", ["//visibility:public"]),
# Allow any other args
**kwargs
)
def jest_test(name, data = [], **kwargs):
_jest_test(
name = name,
config = "//:jest_config",
snapshots = kwargs.pop("snapshots", True),
data = data + native.glob(["**/__fixtures__/**/*"]),
**kwargs
)

69
dev/mocha.bzl Normal file
View File

@ -0,0 +1,69 @@
load("@npm//:mocha/package_json.bzl", "bin")
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
NON_BUNDLED = [
# Dependencies loaded by mocha itself before the tests.
# Should be outside the test bundle to ensure a single copy is used
# mocha (launched by bazel) and the test bundle.
"mocha",
"puppeteer",
# Dependencies used by mocha setup scripts.
"abort-controller",
"node-fetch",
"console",
# Dependencies with bundling issues
"jsonc-parser"
]
# ... some of which are needed at runtime
NON_BUNDLED_DEPS = [
"//:node_modules/jsonc-parser",
"//:node_modules/puppeteer",
]
def mocha_test(name, tests, deps = [], args = [], data = [], env = {}, **kwargs):
bundle_name = "%s_bundle" % name
# Bundle the tests to remove the use of esm modules in tests
esbuild(
name = bundle_name,
entry_points = tests,
platform = "node",
target = "node12",
output_dir = True,
external = NON_BUNDLED,
sourcemap = "linked",
deps = deps,
config = {
"loader": {
# Packages such as fsevents require native .node binaries.
".node": "copy",
},
},
)
bin.mocha_test(
name = name,
args = [
"--config",
"$(location //:mocha_config)",
"$(location :%s)/**/*.test.js" % bundle_name,
] + args,
data = data + deps + [
":%s" % bundle_name,
"//:mocha_config",
] + NON_BUNDLED_DEPS,
env = dict(env, **{
# Add environment variable so that mocha writes its test xml
# to the location Bazel expects.
"MOCHA_FILE": "$$XML_OUTPUT_FILE",
# TODO(bazel): e2e test environment
"GH_TOKEN": "fake-token",
"TEST_USER_PASSWORD": "fake-password",
}),
tags = ["manual"],
**kwargs
)

15
dev/webpack.bzl Normal file
View File

@ -0,0 +1,15 @@
load("@aspect_rules_webpack//webpack:defs.bzl", _webpack_bundle = "webpack_bundle", _webpack_devserver = "webpack_devserver")
def webpack_bundle(name, **kwargs):
_webpack_bundle(
name = name,
webpack = "//dev:webpack",
**kwargs
)
def webpack_devserver(name, **kwargs):
_webpack_devserver(
name = name,
webpack = "//dev:webpack",
**kwargs
)

View File

@ -2,6 +2,23 @@
const path = require('path')
// TODO(bazel): drop when non-bazel removed.
const IS_BAZEL = !!(process.env.BAZEL_BINDIR || process.env.BAZEL_TEST)
const SRC_EXT = IS_BAZEL ? 'js' : 'ts'
const rootDir = IS_BAZEL ? process.cwd() : __dirname
function toPackagePath(pkgPath) {
// TODO(bazel): bazel runs tests using the pre-compiled npm packages from
// the pnpm workspace projects. the legacy non-bazel tests run on local ts
// source files which are compiled by jest and npm packages are mapped to
// the compiled or local js files.
if (IS_BAZEL) {
return pkgPath.replace('.ts', '').replace('.js', '')
}
return pkgPath
}
// Use the same locale for test runs so that snapshots generated using code that
// uses Intl or toLocaleString() are consistent.
//
@ -15,42 +32,54 @@ process.env.LANG = 'en_US.UTF-8'
const ESM_NPM_DEPS = [
'abortable-rx',
'@sourcegraph/comlink',
'@sourcegraph/.*',
'monaco-editor',
'monaco-yaml',
'@ampproject/.*',
'marked',
'date-fns',
'react-sticky-box',
'uuid',
'vscode-languageserver-types',
]
.join('|')
.replace(/\//g, '\\+')
].join('|')
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
// uses latest jsdom and exposes jsdom as a global,
// for example to change the URL in window.location
testEnvironment: __dirname + '/client/shared/dev/jest-environment.js',
testEnvironment: toPackagePath(path.join(rootDir, 'client/shared/dev/jest-environment.js')),
collectCoverage: !!process.env.CI,
collectCoverageFrom: ['<rootDir>/src/**/*.{ts,tsx}'],
collectCoverageFrom: [`<rootDir>/src/**/*.{${SRC_EXT},${SRC_EXT}x}`],
coverageDirectory: '<rootDir>/coverage',
coveragePathIgnorePatterns: [/\/node_modules\//.source, /\.(test|story)\.tsx?$/.source, /\.d\.ts$/.source],
coveragePathIgnorePatterns: [/\/node_modules\//.source, /\.(test|story)\.[jt]sx?$/.source, /\.d\.ts$/.source],
roots: ['<rootDir>/src'],
snapshotResolver: path.join(rootDir, 'jest.snapshot-resolver.js'),
transform: { '\\.[jt]sx?$': ['babel-jest', { root: __dirname }] },
transform: {
[IS_BAZEL ? '\\.js$' : '\\.[jt]sx?$']: [
'babel-jest',
{
root: rootDir,
configFile: path.join(rootDir, IS_BAZEL ? 'babel.config.jest.js' : 'babel.config.js'),
},
],
},
// Transform packages that do not distribute CommonJS packages (typically because they only distribute ES6
// modules). If you get an error from jest like "Jest encountered an unexpected token. ... SyntaxError:
// unexpected token import/export", then add it here. See
// https://github.com/facebook/create-react-app/issues/5241#issuecomment-426269242 for more information on why
// this is necessary.
// Include the pnpm-style rules_js.
// See pnpm notes at https://jestjs.io/docs/configuration#transformignorepatterns-arraystring
transformIgnorePatterns: [
// TODO(bazel): remove when @sourcegraph/shared is no longer compiled as commonjs. See client/common/BUILD.bazel
'@sourcegraph/shared',
// packages within the root pnpm/rules_js package store
`<rootDir>/node_modules/.(aspect_rules_js|pnpm)/(?!(${ESM_NPM_DEPS})@)`,
`<rootDir>/node_modules/.(aspect_rules_js|pnpm)/(?!(${ESM_NPM_DEPS.replace('/', '\\+')})@)`,
// files under a subdir: eg. '/packages/lib-a/'
`(../)+node_modules/.(aspect_rules_js|pnpm)/(?!(${ESM_NPM_DEPS})@)`,
`(../)+node_modules/.(aspect_rules_js|pnpm)/(?!(${ESM_NPM_DEPS.replace('/', '\\+')})@)`,
// packages nested within another
`node_modules/(?!.aspect_rules_js|.pnpm|${ESM_NPM_DEPS})`,
],
@ -72,25 +101,26 @@ const config = {
coverageReporters: ['json', 'lcov', 'text-summary'],
setupFiles: [
path.join(__dirname, 'client/shared/dev/mockDate.js'),
path.join(rootDir, 'client/shared/dev/mockDate.js'),
// Needed for reusing API functions that use fetch
// Neither NodeJS nor JSDOM have fetch + AbortController yet
require.resolve('abort-controller/polyfill'),
path.join(__dirname, 'client/shared/dev/fetch'),
path.join(__dirname, 'client/shared/dev/setLinkComponentForTest.ts'),
path.join(__dirname, 'client/shared/dev/mockDomRect.ts'),
path.join(__dirname, 'client/shared/dev/mockResizeObserver.ts'),
path.join(__dirname, 'client/shared/dev/mockUniqueId.ts'),
path.join(__dirname, 'client/shared/dev/mockSentryBrowser.ts'),
path.join(__dirname, 'client/shared/dev/mockMatchMedia.ts'),
],
path.join(rootDir, 'client/shared/dev/fetch'),
path.join(rootDir, 'client/shared/dev/setLinkComponentForTest.ts'),
path.join(rootDir, 'client/shared/dev/mockDomRect.ts'),
path.join(rootDir, 'client/shared/dev/mockResizeObserver.ts'),
path.join(rootDir, 'client/shared/dev/mockUniqueId.ts'),
path.join(rootDir, 'client/shared/dev/mockSentryBrowser.ts'),
path.join(rootDir, 'client/shared/dev/mockMatchMedia.ts'),
].map(toPackagePath),
setupFilesAfterEnv: [
require.resolve('core-js/stable'),
require.resolve('regenerator-runtime/runtime'),
require.resolve('@testing-library/jest-dom'),
path.join(__dirname, 'client/shared/dev/reactCleanup.ts'),
toPackagePath(path.join(rootDir, 'client/shared/dev/reactCleanup.ts')),
],
globalSetup: path.join(__dirname, 'client/shared/dev/jestGlobalSetup.js'),
globalSetup: toPackagePath(path.join(rootDir, 'client/shared/dev/jestGlobalSetup.js')),
globals: {
Uint8Array,
},

27
jest.snapshot-resolver.js Normal file
View File

@ -0,0 +1,27 @@
// @ts-check
const path = require('path')
// TODO(bazel): bazel runs tests on the pre-compiled .js files, non-bazel runs on .ts files.
// This snapshot resolver edits the pre-compiled .js to snapshots assuming a .tsx extension.
// This can be removed and snapshot files renamed to .js when non-bazel is removed.
// NOTE: this assumes all snapshot tests are in .tsx files, not .ts or .jsx and will not work for non-.tsx files.
const SNAPSHOT_EXTENSION = '.snap'
const TEST_EXTENSION = '.tsx'
module.exports = {
resolveSnapshotPath: testPath =>
path.join(
path.join(path.dirname(testPath), '__snapshots__'),
path.basename(testPath).replace('.js', TEST_EXTENSION) + SNAPSHOT_EXTENSION
),
resolveTestPath: snapshotPath =>
path.join(
path.dirname(path.dirname(snapshotPath)),
path.basename(snapshotPath, SNAPSHOT_EXTENSION).replace('.js', TEST_EXTENSION)
),
testPathForConsistencyCheck: path.posix.join('consistency_check', '__tests__', 'example.test.tsx'),
}

View File

@ -93,6 +93,7 @@
"devDependencies": {
"@atlassian/aui": "^7.10.3",
"@axe-core/puppeteer": "^4.4.2",
"@babel/cli": "^7.20.7",
"@babel/core": "^7.20.5",
"@babel/plugin-transform-typescript": "^7.20.2",
"@babel/preset-env": "^7.20.2",
@ -110,7 +111,6 @@
"@lhci/cli": "0.8.1",
"@mermaid-js/mermaid-cli": "^8.13.10",
"@octokit/rest": "^16.36.0",
"@peculiar/webcrypto": "^1.1.7",
"@percy/cli": "^1.16.0",
"@percy/puppeteer": "^2.0.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
@ -152,7 +152,6 @@
"@terminus-term/to-string-loader": "^1.1.7-beta.1",
"@testing-library/dom": "^8.13.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.4.0",
"@testing-library/react-hooks": "^8.0.0",
"@testing-library/user-event": "^13.5.0",
"@types/babel__core": "7.1.20",
@ -263,7 +262,6 @@
"identity-obj-proxy": "^3.0.0",
"jest": "^28.1.0",
"jest-canvas-mock": "^2.3.0",
"jest-environment-jsdom": "^28.1.0",
"jest-fetch-mock": "^3.0.3",
"jest-junit": "^13.0.0",
"jest-mock-extended": "^2.0.2-beta2",
@ -361,6 +359,7 @@
"@opentelemetry/sdk-trace-base": "1.9.1",
"@opentelemetry/sdk-trace-web": "^1.9.1",
"@opentelemetry/semantic-conventions": "^1.9.1",
"@peculiar/webcrypto": "^1.1.7",
"@reach/accordion": "^0.16.1",
"@reach/auto-id": "^0.16.0",
"@reach/combobox": "^0.16.5",
@ -372,6 +371,7 @@
"@sentry/browser": "^7.8.1",
"@sourcegraph/extension-api-classes": "^1.1.0",
"@storybook/addon-controls": "^6.5.14",
"@testing-library/react": "^13.4.0",
"@visx/annotation": "^2.10.0",
"@visx/axis": "^2.11.1",
"@visx/event": "2.6.0",
@ -419,6 +419,7 @@
"https-proxy-agent": "^5.0.1",
"is-absolute-url": "^3.0.3",
"iterare": "^1.2.1",
"jest-environment-jsdom": "^28.1.0",
"js-base64": "^3.7.2",
"js-cookie": "^2.2.1",
"js-yaml": "^4.1.0",
@ -429,6 +430,7 @@
"marked": "4.0.16",
"mdi-react": "^8.1.0",
"minimatch": "^3.0.4",
"mockdate": "^3.0.2",
"monaco-editor": "^0.24.0",
"monaco-yaml": "^3.2.1",
"nice-ticks": "^1.0.1",
@ -477,6 +479,20 @@
"zustand": "^3.6.9"
},
"packageManager": "pnpm@7.24.2",
"pnpm": {
"packageExtensions": {
"cpu-features": {
"dependencies": {
"node-gyp": "*"
}
},
"@percy/sdk-utils": {
"dependencies": {
"ws": "*"
}
}
}
},
"resolutions": {
"@types/webpack": "5",
"history": "4.5.1",

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,18 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("//dev:defs.bzl", "npm_package")
package(default_visibility = ["//client/shared:__pkg__"])
package(default_visibility = ["//visibility:public"])
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
],
)
js_library(
name = "json-schema-draft-07",
@ -71,3 +82,14 @@ go_library(
visibility = ["//visibility:public"],
deps = ["@com_github_sourcegraph_go_jsonschema//jsonschema"],
)
js_library(
name = "schema-json",
srcs = glob(["*.schema.json"]),
visibility = ["//visibility:public"],
)
npm_package(
name = "schema_pkg",
srcs = ["package.json"],
)

View File

@ -1,5 +0,0 @@
{
"extends": "./tsconfig.base.json",
"include": ["**/*"],
"exclude": []
}

View File

@ -0,0 +1,4 @@
filegroup(
name = "img",
srcs = glob(["**/*.*"]),
)