Skip to content

Commit 843c5e4

Browse files
committed
Migrate webpack config to TypeScript and update related build scripts
1 parent f4691ad commit 843c5e4

4 files changed

Lines changed: 41 additions & 29 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat",
44
"description": "Free AI coding in chatbots (CWC)",
5-
"version": "1.825.0",
5+
"version": "1.826.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "rimraf out && npm run compile",
9-
"compile": "webpack --config ./webpack.config.js --mode production",
10-
"watch": "webpack --config ./webpack.config.js --watch --mode development",
9+
"compile": "webpack --config ./webpack.config.ts --mode production",
10+
"watch": "webpack --config ./webpack.config.ts --watch --mode development",
1111
"lint": "eslint src --ext ts,tsx",
1212
"lint:fix": "eslint src --ext ts,tsx --fix",
1313
"test": "jest",
@@ -1983,6 +1983,7 @@
19831983
"sass-embedded": "^1.89.2",
19841984
"sass-loader": "^12.6.0",
19851985
"style-loader": "^3.3.4",
1986+
"ts-node": "^10.9.2",
19861987
"ts-loader": "^9.5.2",
19871988
"typed-css-modules": "^0.9.1",
19881989
"webpack": "^5.99.9",

‎apps/editor/src/commands/apply-chat-response-command/response-processor.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ import { FileInPreview } from '@shared/types/file-in-preview'
2424
import { update_undo_button_state } from './utils/state-manager'
2525
import { check_for_conflict_markers } from './utils/file-checks'
2626
import { handle_conflict_markers } from './handlers/conflict-markers-handler'
27-
import {
28-
handle_truncated_edit,
29-
is_truncation_line
30-
} from './handlers/truncated-handler'
27+
import { handle_truncated_edit } from './handlers/truncated-handler'
3128
import { WorkspaceProvider } from '@/context/providers/workspace/workspace-provider'
3229
import { natural_sort } from '@/utils/natural-sort'
30+
import { is_truncation_line } from './utils/edit-formats/truncations'
3331

3432
export type PreviewData = {
3533
original_states: OriginalFileState[]
Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
const path = require('path')
2-
const crypto = require('crypto')
3-
const CopyWebpackPlugin = require('copy-webpack-plugin')
4-
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
5-
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
1+
import * as path from 'path'
2+
import * as crypto from 'crypto'
3+
import * as webpack from 'webpack'
4+
import CopyWebpackPlugin from 'copy-webpack-plugin'
5+
import { CleanWebpackPlugin } from 'clean-webpack-plugin'
6+
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
67

7-
/**
8-
* @type {import('webpack').Configuration[]}
9-
*/
10-
const config = [
8+
const config: ((env: any, argv: any) => webpack.Configuration)[] = [
119
// Extension Configuration (Node.js environment)
12-
(env, argv) => {
13-
const is_production = argv.mode == 'production'
10+
(env: any, argv: any): webpack.Configuration => {
11+
const is_production = argv.mode === 'production'
1412
return {
1513
name: 'extension',
1614
mode: is_production ? 'production' : 'development',
@@ -25,7 +23,7 @@ const config = [
2523
libraryTarget: 'commonjs2',
2624
devtoolModuleFilenameTemplate: '../[resource-path]'
2725
},
28-
devtool: is_production ? false : 'eval-source-map', // Use 'eval-source-map' for faster dev builds and good debugging
26+
devtool: is_production ? false : 'eval-source-map',
2927
cache: {
3028
type: 'filesystem',
3129
buildDependencies: {
@@ -74,7 +72,12 @@ const config = [
7472
.toString()
7573
.split('\n')
7674
.slice(12)
77-
.filter((line) => !['> [!TIP]', '> [!IMPORTANT]', '> [!NOTE]'].includes(line.trim()))
75+
.filter(
76+
(line) =>
77+
!['> [!TIP]', '> [!IMPORTANT]', '> [!NOTE]'].includes(
78+
line.trim()
79+
)
80+
)
7881
.join('\n')
7982
}
8083
}
@@ -85,8 +88,8 @@ const config = [
8588
}
8689
},
8790
// View Configuration (Web environment)
88-
(env, argv) => {
89-
const isProduction = argv.mode == 'production'
91+
(env: any, argv: any): webpack.Configuration => {
92+
const isProduction = argv.mode === 'production'
9093
return {
9194
name: 'view',
9295
mode: isProduction ? 'production' : 'development',
@@ -103,7 +106,7 @@ const config = [
103106
performance: {
104107
hints: false
105108
},
106-
devtool: isProduction ? false : 'eval-source-map', // Use 'eval-source-map' for dev
109+
devtool: isProduction ? false : 'eval-source-map',
107110
cache: {
108111
type: 'filesystem',
109112
buildDependencies: {
@@ -132,12 +135,16 @@ const config = [
132135
loader: 'css-loader',
133136
options: {
134137
modules: {
135-
getLocalIdent: (context, _, localName) => {
138+
getLocalIdent: (
139+
context: webpack.LoaderContext<any>,
140+
_: any,
141+
localName: string
142+
) => {
136143
const filename = context.resourcePath
137144
const isModule = /\.module\.(scss|css)$/i.test(filename)
138145
if (isModule) {
139146
const moduleName = path
140-
.basename(filename)
147+
.basename(filename as string)
141148
.replace(/\.module\.(scss|css)$/i, '')
142149
const hash = crypto
143150
.createHash('md5')
@@ -157,7 +164,10 @@ const config = [
157164
loader: 'sass-loader',
158165
options: {
159166
additionalData: `@use "${path
160-
.resolve(__dirname, '../../packages/ui/src/styles/foundation')
167+
.resolve(
168+
__dirname,
169+
'../../packages/ui/src/styles/foundation'
170+
)
161171
.replace(/\\/g, '/')}" as *;`
162172
}
163173
}
@@ -193,11 +203,11 @@ const config = [
193203
plugins: [
194204
new MiniCssExtractPlugin({
195205
filename: '[name].css'
196-
})
197-
],
206+
}) as unknown as webpack.WebpackPluginInstance
207+
] as webpack.WebpackPluginInstance[],
198208
stats: 'errors-only'
199209
}
200210
}
201211
]
202212

203-
module.exports = config
213+
export default config

‎pnpm-lock.yaml‎

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

0 commit comments

Comments
 (0)