Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.
6 changes: 0 additions & 6 deletions client/browser/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,12 @@ ts_project(
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/scripts/afterInstallPage.main.tsx",
"src/browser-extension/scripts/backgroundPage.main.ts",
"src/browser-extension/scripts/contentPage.main.ts",
"src/browser-extension/scripts/optionsPage.main.tsx",
Expand Down Expand Up @@ -206,7 +204,6 @@ ts_project(
"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",
Expand Down Expand Up @@ -262,7 +259,6 @@ ts_project(
"//:node_modules/utility-types",
"//:node_modules/uuid",
"//:node_modules/vitest",
"//:node_modules/webext-domain-permission-toggle",
"//:node_modules/webextension-polyfill", #keep
],
)
Expand Down Expand Up @@ -367,7 +363,6 @@ esbuild(
"src/browser-extension/scripts/backgroundPage.main.js",
"src/browser-extension/scripts/contentPage.main.js",
"src/browser-extension/scripts/optionsPage.main.js",
"src/browser-extension/scripts/afterInstallPage.main.js",
"src/native-integration/nativeIntegration.main.js",
"src/native-integration/phabricator/phabricatorNativeIntegration.main.js",
"src/app.css",
Expand Down Expand Up @@ -406,7 +401,6 @@ copy_to_directory(
ts_project(
name = "stories",
srcs = [
"src/browser-extension/after-install-page/AfterInstallPageContent.story.tsx",
"src/browser-extension/options-menu/OptionsPage.story.tsx",
"src/shared/components/HoverOverlay.story.tsx",
],
Expand Down
10 changes: 8 additions & 2 deletions client/browser/config/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export function esbuildBuildOptions(mode: 'dev' | 'prod', extraPlugins: esbuild.
path.resolve(browserSourcePath, 'browser-extension/scripts/backgroundPage.main.ts'),
path.resolve(browserSourcePath, 'browser-extension/scripts/contentPage.main.ts'),
path.resolve(browserSourcePath, 'browser-extension/scripts/optionsPage.main.tsx'),
path.resolve(browserSourcePath, 'browser-extension/scripts/afterInstallPage.main.tsx'),

// Common native integration entry point (Gitlab, Bitbucket)
path.resolve(browserSourcePath, 'native-integration/nativeIntegration.main.ts'),
Expand All @@ -39,9 +38,11 @@ export function esbuildBuildOptions(mode: 'dev' | 'prod', extraPlugins: esbuild.
plugins: [stylePlugin, ...extraPlugins],
define: {
'process.env.NODE_ENV': JSON.stringify(mode === 'dev' ? 'development' : 'production'),
'process.env.NODE_DEBUG': 'false',
'process.env.BUNDLE_UID': JSON.stringify(generateBundleUID()),
},
bundle: true,
treeShaking: true,
minify: false,
logLevel: 'error',
jsx: 'automatic',
Expand All @@ -50,7 +51,12 @@ export function esbuildBuildOptions(mode: 'dev' | 'prod', extraPlugins: esbuild.
entryNames: '[ext]/[name].bundle',
target: 'esnext',
sourcemap: true,
alias: { path: 'path-browserify' },
alias: { path: 'path-browserify', lodash: 'lodash-es' },
banner: {
// HACK: lodash has a `Function("return this")`, which Firefox's CSP protection
// complains about. This ensures we do not encounter it.
js: 'globalThis.global = globalThis;',
},
loader: {
'.svg': 'text',
},
Expand Down
21 changes: 16 additions & 5 deletions client/browser/scripts/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import fs from 'fs'
import path from 'path'

import { omit, cloneDeep, curry } from 'lodash'
import { cloneDeep, curry, omit } from 'lodash'
import shelljs from 'shelljs'
import signale from 'signale'
import utcVersion from 'utc-version'
Expand Down Expand Up @@ -175,7 +175,7 @@ function writeManifest(environment: BuildEnvironment, browser: Browser, writeDir
if (EXTENSION_PERMISSIONS_ALL_URLS) {
manifest.permissions!.push('<all_urls>')
/** Set key to make extension id deterministic */
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

// @ts-ignore
manifest.key = manifestSpec.dev.key
signale.info('Adding <all_urls> to permissions because of env var setting')
Expand All @@ -194,9 +194,20 @@ function writeManifest(environment: BuildEnvironment, browser: Browser, writeDir
}
}

// Add the inline extensions to web accessible resources
manifest.web_accessible_resources = manifest.web_accessible_resources || []
manifest.web_accessible_resources.push('extensions/*')
// Firefox doesn't support service workers, so we need a workaround. See
// https://github.com/mozilla/web-ext/issues/2532.
if (browser === 'firefox') {
manifest.background!.scripts = [manifest.background!.service_worker]
delete manifest.background!.service_worker
}

if (browser === 'firefox') {
manifest.browser_specific_settings = {
gecko: {
id: 'sourcegraph-for-firefox@sourcegraph.com',
},
}
}

delete manifest.$schema

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading