Skip to content

Commit 4c502c3

Browse files
web: Active CodeWhisperer in Web Mode (#4444)
* browser: try activate codewhisperer on startup This activates CW but there are still compilation errors. We are trying to just get it to activate without throwing an error, and this will be done in the following commits Signed-off-by: nkomonen <[email protected]> * browser: patch os.version() This method does not exist in the browserfied version of os, so we patch it with an arbitrary version Signed-off-by: nkomonen <[email protected]> --------- Signed-off-by: nkomonen <[email protected]>
1 parent 42548d0 commit 4c502c3

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

packages/toolkit/src/extension.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import { activate as activateEc2 } from './ec2/activation'
3232
import { activate as activateSam } from './shared/sam/activation'
3333
import { activate as activateS3 } from './s3/activation'
3434
import * as awsFiletypes from './shared/awsFiletypes'
35-
import { activate as activateCodeWhisperer, shutdown as codewhispererShutdown } from './codewhisperer/activation'
3635
import { activate as activateApiGateway } from './apigateway/activation'
3736
import { activate as activateStepFunctions } from './stepFunctions/activation'
3837
import { activate as activateSsmDocument } from './ssmDocument/activation'
@@ -133,8 +132,6 @@ export async function activate(context: vscode.ExtensionContext) {
133132
remoteInvokeOutputChannel: globals.invokeOutputChannel,
134133
})
135134

136-
await activateCodeWhisperer(extContext)
137-
138135
await activateAppRunner(extContext)
139136

140137
await activateApiGateway({
@@ -230,7 +227,6 @@ export async function activate(context: vscode.ExtensionContext) {
230227

231228
export async function deactivate() {
232229
await deactivateShared()
233-
await codewhispererShutdown()
234230
await globals.resourceManager.dispose()
235231
}
236232

packages/toolkit/src/extensionShared.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { documentationUrl, githubCreateIssueUrl, githubUrl } from './shared/cons
1818
import { getIdeProperties, aboutToolkit, isCloud9 } from './shared/extensionUtilities'
1919
import { telemetry } from './shared/telemetry/telemetry'
2020
import { openUrl } from './shared/utilities/vsCodeUtils'
21+
import { activate as activateCodeWhisperer, shutdown as codewhispererShutdown } from './codewhisperer/activation'
2122

2223
import { activate as activateLogger } from './shared/logger/activation'
2324
import { initializeComputeRegion } from './shared/extensionUtilities'
@@ -134,13 +135,15 @@ export async function activateShared(
134135
credentialsStore: globals.loginManager.store,
135136
}
136137

138+
await activateCodeWhisperer(extContext)
139+
137140
return extContext
138141
}
139142

140143
/** Deactivation code that is shared between nodejs and browser implementations */
141144
export async function deactivateShared() {
142145
await globals.telemetry.shutdown()
143-
// await codewhispererShutdown()
146+
await codewhispererShutdown()
144147
}
145148
/**
146149
* Registers generic commands used by both browser and node versions of the toolkit.

packages/toolkit/src/extensionWeb.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { setInBrowser } from './common/browserUtils'
88
import { getLogger } from './shared/logger'
99
import { activateShared, deactivateShared } from './extensionShared'
1010
import { RegionProvider, defaultRegion } from './shared/regions/regionProvider'
11+
import os from 'os'
1112

1213
export async function activate(context: vscode.ExtensionContext) {
1314
setInBrowser(true) // THIS MUST ALWAYS BE FIRST
@@ -17,6 +18,8 @@ export async function activate(context: vscode.ExtensionContext) {
1718
)
1819

1920
try {
21+
patchOsVersion()
22+
2023
// IMPORTANT: Any new activation code should be done in the function below unless
2124
// it is browser specific activation code.
2225
await activateShared(context, () => {
@@ -34,6 +37,14 @@ export async function activate(context: vscode.ExtensionContext) {
3437
}
3538
}
3639

40+
/**
41+
* The browserfied version of os does not have a `version()` method,
42+
* so we patch it.
43+
*/
44+
function patchOsVersion() {
45+
;(os.version as any) = () => '1.0.0'
46+
}
47+
3748
export async function deactivate() {
3849
await deactivateShared()
3950
}

packages/webpack.browser.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const webConfig = {
4747
fs: false,
4848
crypto: require.resolve('crypto-browserify'),
4949
'fs-extra': false,
50+
perf_hooks: false, // should be using globalThis.performance instead
5051

5152
// *** If one of these modules actually gets used an error will be raised ***
5253
// You may see something like: "TypeError: path_ignored_0.join is not a function"

0 commit comments

Comments
 (0)