Skip to content

Commit 9ea0440

Browse files
committed
feature(q): generalize webpack configs, add browser entry for amazonq
Webpack configs can now be used by subprojects, with overrides. Also cleans up some npm scripts for amazonq, and cleans up the root tsconfig.json a little.
1 parent a8a6d6b commit 9ea0440

16 files changed

+216
-126
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,16 @@
5656
"@vscode/test-electron": "^2.3.8",
5757
"@vscode/test-web": "^0.0.50",
5858
"@vscode/vsce": "^2.19.0",
59+
"@types/webpack-env": "^1.18.1",
5960
"prettier": "^2.8.8",
6061
"prettier-plugin-sh": "^0.12.8",
6162
"pretty-quick": "^3.1.3",
6263
"husky": "^9.0.7",
6364
"typescript": "^5.0.4",
64-
"ts-node": "^10.9.1"
65+
"ts-node": "^10.9.1",
66+
"webpack": "^5.83.0",
67+
"webpack-cli": "^5.1.4",
68+
"webpack-dev-server": "^4.15.1"
6569
},
6670
"dependencies": {
6771
"vscode-nls": "^5.2.0",

packages/amazonq/package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@
4040
"onStartupFinished",
4141
"onUri"
4242
],
43-
"main": "./dist/src/main.js",
43+
"main": "./dist/src/extension",
44+
"browser": "./dist/src/extensionWeb",
4445
"scripts": {
46+
"vscode:prepublish": "npm run clean && npm run compile && webpack --mode production",
4547
"clean": "ts-node ../../scripts/clean.ts dist/",
46-
"compile": "tsc -p ./",
47-
"testCompile": "npm run compile",
48+
"compile": "npm run clean && tsc -p ./ && webpack --mode development",
49+
"testCompile": "tsc -p ./",
4850
"watch": "npm run clean && tsc -watch -p ./",
49-
"serve": "echo 1"
51+
"serve": "webpack serve --config-name vue-hmr --mode development",
52+
"package": "ts-node ../../scripts/package.ts"
5053
},
5154
"dependencies": {},
5255
"devDependencies": {},

packages/amazonq/src/extension.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
*/
55

66
import * as vscode from 'vscode'
7+
import { activateShared } from './extensionShared'
78

89
export async function activate(context: vscode.ExtensionContext) {
9-
void vscode.window.showInformationMessage(
10-
'Amazon Q + CodeWhisperer: This extension is under development and offers no features at this time.'
11-
)
10+
await activateShared()
1211
}
1312

1413
export async function deactivate() {}
15-
16-
export const awsQActivate = activate
17-
export const awsQDeactivate = deactivate
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import * as vscode from 'vscode'
7+
8+
export async function activateShared() {
9+
void vscode.window.showInformationMessage(
10+
'Amazon Q + CodeWhisperer: This extension is under development and offers no features at this time.'
11+
)
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import * as vscode from 'vscode'
7+
import { activateShared } from './extensionShared'
8+
9+
export async function activate(context: vscode.ExtensionContext) {
10+
await activateShared()
11+
}
12+
13+
export async function deactivate() {}

packages/amazonq/src/main.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/**
7+
* This config exists separately so it can be invoked from the webpack CLI.
8+
*/
9+
10+
const browserConfig = {
11+
...require('../webpack.browser.config'),
12+
entry: {
13+
'src/extensionWeb': './src/extensionWeb.ts',
14+
},
15+
}
16+
17+
module.exports = browserConfig

packages/amazonq/webpack.config.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/**
7+
* This is the final webpack config that collects all webpack configs.
8+
*/
9+
10+
const baseConfig = require('../webpack.base.config')
11+
const baseVueConfig = require('../webpack.vue.config')
12+
const baseBrowserConfig = require('./webpack.browser.config')
13+
14+
const config = {
15+
...baseConfig,
16+
entry: {
17+
'src/extension': './src/extension.ts',
18+
},
19+
}
20+
21+
const vueConfigs = baseVueConfig.configs.map(c => {
22+
// Inject entry point into all configs.
23+
return {
24+
...c,
25+
entry: {
26+
...baseVueConfig.utils.createVueEntries(),
27+
//'src/amazonq/webview/ui/amazonq-ui': './src/amazonq/webview/ui/main.ts',
28+
},
29+
}
30+
})
31+
32+
// baseBrowserConfigs is set up in another file.
33+
const browserConfig = { ...baseBrowserConfig }
34+
35+
module.exports = [config, ...vueConfigs, browserConfig]

packages/toolkit/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4297,7 +4297,6 @@
42974297
"@types/sinonjs__fake-timers": "^8.1.2",
42984298
"@types/tcp-port-used": "^1.0.1",
42994299
"@types/uuid": "^9.0.1",
4300-
"@types/webpack-env": "^1.18.1",
43014300
"@types/whatwg-url": "^11.0.4",
43024301
"@types/xml2js": "^0.4.11",
43034302
"@typescript-eslint/eslint-plugin": "^5.59.0",
@@ -4324,9 +4323,6 @@
43244323
"vue-loader": "^17.2.2",
43254324
"vue-style-loader": "^4.1.3",
43264325
"webfont": "^11.2.26",
4327-
"webpack": "^5.83.0",
4328-
"webpack-cli": "^5.1.4",
4329-
"webpack-dev-server": "^4.15.1",
43304326
"typescript": "^5.0.4",
43314327
"ts-node": "^10.9.1"
43324328
},

0 commit comments

Comments
 (0)