Skip to content

Commit 35a1ca6

Browse files
authored
Merge pull request #35 from lowcoding/feat/v1.9.0
✨ feat: bundle using esbuild
2 parents 5160dcf + bd6365e commit 35a1ca6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1803
-3738
lines changed

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
registry = https://registry.npm.taobao.org
1+
registry = https://registry.npmmirror.com/

.vscode/settings.json

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
"files.exclude": {
4-
"build": false // set this to true to hide the "out" folder with the compiled JS files
5-
},
6-
"search.exclude": {
7-
"build": true // set this to false to include "out" folder in search results
8-
},
9-
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10-
"typescript.tsc.autoDetect": "off"
3+
"editor.formatOnSave": true,
4+
"editor.defaultFormatter": "esbenp.prettier-vscode",
5+
"editor.codeActionsOnSave": {
6+
"source.fixAll.eslint": "explicit",
7+
"source.fixAll.stylelint": "explicit"
8+
},
9+
"stylelint.validate": [
10+
"css",
11+
"less",
12+
"scss",
13+
"vue"
14+
],
15+
"[scss]": {
16+
"editor.defaultFormatter": "esbenp.prettier-vscode"
17+
},
18+
"[vue]": {
19+
"editor.defaultFormatter": "esbenp.prettier-vscode"
20+
},
21+
"[typescript]": {
22+
"editor.defaultFormatter": "esbenp.prettier-vscode"
23+
},
24+
"files.exclude": {
25+
"build": false // set this to true to hide the "out" folder with the compiled JS files
26+
},
27+
"search.exclude": {
28+
"build": true // set this to false to include "out" folder in search results
29+
},
30+
"typescript.tsdk": "node_modules/typescript/lib",
1131
}

.vscodeignore

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,7 @@ vsc-extension-quickstart.md
1515
**/*.ts
1616
*.lock
1717
*.vsix
18-
webpack.config.js
18+
.lowcoderc
19+
esbuild.js
1920

20-
node_modules
21-
!node_modules/prettier
22-
!node_modules/copy-paste
23-
!node_modules/iconv-lite
24-
!node_modules/safer-buffer
25-
!node_modules/typescript-json-schema
26-
!node_modules/glob
27-
!node_modules/fs.realpath
28-
!node_modules/minimatch
29-
!node_modules/brace-expansion
30-
!node_modules/concat-map
31-
!node_modules/balanced-match
32-
!node_modules/inherits
33-
!node_modules/path-is-absolute
34-
!node_modules/inflight
35-
!node_modules/wrappy
36-
!node_modules/once
37-
!node_modules/json-stable-stringify
38-
!node_modules/typescript
21+
node_modules

esbuild.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const path = require('path');
2+
const fs = require('fs-extra');
3+
const { build } = require('esbuild');
4+
5+
fs.removeSync(path.join(__dirname, 'build'));
6+
const entryFile = path.join(__dirname, 'src', 'extension.ts');
7+
build({
8+
entryPoints: [entryFile],
9+
bundle: true,
10+
minify: true,
11+
// only needed if you have dependencies
12+
external: ['vscode'],
13+
platform: 'node',
14+
format: 'cjs',
15+
outfile: path.join(__dirname, 'build', 'extension.js'),
16+
write: true,
17+
logLevel: 'error',
18+
});

package.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
"displayName": "lowcode",
44
"description": "lowcode tool, support ChatGPT and other LLM",
55
"author": "wjkang <ruoxieme@gmail.com>",
6-
"version": "1.8.9",
6+
"version": "1.9.0",
77
"icon": "asset/icon.png",
88
"publisher": "wjkang",
99
"repository": "https://github.com/lowcoding/lowcode-vscode",
1010
"main": "./build/extension.js",
1111
"scripts": {
1212
"vscode:prepublish": "yarn run compile",
13-
"compile": "webpack --mode production",
13+
"compile": "node ./esbuild.js",
1414
"compile:tsc": "tsc -p ./",
1515
"dev": "yarn --cwd \"webview-react\" dev",
1616
"build": "yarn --cwd \"webview-react\" build",
1717
"lint": "eslint src --ext ts",
18-
"watch": "webpack --mode development",
1918
"pretest": "yarn run compile:tsc",
2019
"test:js": "node ./build/test/runTest.js",
2120
"test": "node ./build/test/runTest.js"
@@ -271,7 +270,6 @@
271270
}
272271
},
273272
"devDependencies": {
274-
"@types/copy-paste": "^1.1.30",
275273
"@types/debug": "^4.1.5",
276274
"@types/ejs": "^3.0.4",
277275
"@types/fs-extra": "^9.0.1",
@@ -294,15 +292,13 @@
294292
"prettier": "^2.2.1",
295293
"ts-loader": "^8.0.3",
296294
"typescript": "^4.3.5",
297-
"vscode-test": "^1.3.0",
298-
"webpack": "^4.44.1",
299-
"webpack-cli": "^3.3.12"
295+
"vscode-test": "^1.3.0"
300296
},
301297
"dependencies": {
302298
"axios": "^0.19.2",
303-
"copy-paste": "^1.3.0",
304299
"directory-tree": "^2.2.4",
305300
"ejs": "^3.1.3",
301+
"esbuild": "^0.24.2",
306302
"execa": "^4.0.3",
307303
"fs-extra": "^9.0.1",
308304
"generate-schema": "^2.6.0",

src/commands/addSnippet.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
import * as vscode from 'vscode';
1+
import vscode from 'vscode';
22
import { getClipboardText, getSelectedText } from '../utils/editor';
33
import { showWebView } from '../webview';
44

55
export const createOrShowWebview = (context: vscode.ExtensionContext) => {
66
context.subscriptions.push(
7-
vscode.commands.registerTextEditorCommand('lowcode.addSnippet', () => {
8-
const content = getSelectedText() || getClipboardText();
9-
showWebView({
10-
key: 'main',
11-
task: { task: 'addSnippets', data: { content } },
12-
});
13-
}),
7+
vscode.commands.registerTextEditorCommand(
8+
'lowcode.addSnippet',
9+
async () => {
10+
const content = getSelectedText() || (await getClipboardText());
11+
showWebView({
12+
key: 'main',
13+
task: { task: 'addSnippets', data: { content } },
14+
});
15+
},
16+
),
1417
vscode.commands.registerCommand('lowcode.addPromptTemplate', () => {
1518
showWebView({
1619
key: 'main',

src/commands/chatGPT.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as vscode from 'vscode';
1+
import vscode from 'vscode';
22
import { commands } from '../utils/env';
33
import { hideChatGPTView, showChatGPTView } from '../webview';
44
import { getClipboardText, getSelectedText } from '../utils/editor';
@@ -19,11 +19,11 @@ export const registerChatGPTCommand = (context: vscode.ExtensionContext) => {
1919
'lowcode',
2020
);
2121
}),
22-
vscode.commands.registerCommand('lowcode.askChatGPT', () => {
22+
vscode.commands.registerCommand('lowcode.askChatGPT', async () => {
2323
showChatGPTView({
2424
task: {
2525
task: 'askChatGPT',
26-
data: getSelectedText() || getClipboardText(),
26+
data: getSelectedText() || (await getClipboardText()),
2727
},
2828
});
2929
}),
@@ -49,7 +49,7 @@ export const registerChatGPTCommand = (context: vscode.ExtensionContext) => {
4949
const template = templateList.find((s) => s.name === templateResult);
5050
const model = {
5151
rawSelectedText: getSelectedText() || '',
52-
rawClipboardText: getClipboardText() || '',
52+
rawClipboardText: await getClipboardText(),
5353
};
5454
const code = compileEjs(
5555
template?.commandPrompt || template!.preview.chatGPT?.commandPrompt!,

src/commands/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as vscode from 'vscode';
1+
import vscode from 'vscode';
22
import { commands } from '../utils/env';
33
import { hideChatGPTView, showChatGPTView, showWebView } from '../webview';
44

src/commands/createOrShowWebview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as vscode from 'vscode';
1+
import vscode from 'vscode';
22
import { formatPath } from '../utils/platform';
33
import { showWebView } from '../webview';
44

src/commands/generateCode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as vscode from 'vscode';
1+
import vscode from 'vscode';
22
import { genCodeByYapi } from '../genCode/genCodeByYapi';
33
import { genCodeByJson } from '../genCode/genCodeByJson';
44
import { genCodeByTypescript } from '../genCode/genCodeByTypescript';
@@ -12,7 +12,7 @@ export const generateCode = (context: vscode.ExtensionContext) => {
1212
vscode.commands.registerTextEditorCommand(
1313
'lowcode.generateCode',
1414
async () => {
15-
const rawClipboardText = getClipboardText();
15+
const rawClipboardText = await getClipboardText();
1616
let clipboardText = rawClipboardText.trim();
1717

1818
clipboardText = JSON.stringify(jsonParse(clipboardText));

0 commit comments

Comments
 (0)