feat:构建工具改为esbuild
This commit is contained in:
parent
3cae8572e8
commit
2a8ff295b2
16
esbuild.config.js
Normal file
16
esbuild.config.js
Normal file
@ -0,0 +1,16 @@
|
||||
// esbuild.config.js
|
||||
const { build } = require('esbuild');
|
||||
|
||||
build({
|
||||
entryPoints: ['src/extension.ts'],
|
||||
bundle: true,
|
||||
platform: 'node',
|
||||
format: 'cjs',
|
||||
outfile: 'dist/extension.cjs.js',
|
||||
sourcemap: true,
|
||||
external: ['vscode'], // 只排除 vscode,其他依赖全部打包进来
|
||||
target: ['node18'], // 你可以根据实际 node 版本调整
|
||||
loader: {
|
||||
'.json': 'json'
|
||||
}
|
||||
}).catch(() => process.exit(1));
|
4497
package-lock.json
generated
4497
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@ -19,8 +19,7 @@
|
||||
"Other"
|
||||
],
|
||||
"activationEvents": [],
|
||||
"type": "module",
|
||||
"main": "./dist/extension.js",
|
||||
"main": "./dist/extension.cjs.js",
|
||||
"icon": "icons/openmcp.png",
|
||||
"contributes": {
|
||||
"configuration": {
|
||||
@ -223,9 +222,9 @@
|
||||
"scripts": {
|
||||
"setup": "npm i && npm run prepare:ocr",
|
||||
"serve": "turbo serve",
|
||||
"build": "turbo build && tsc -p ./",
|
||||
"build": "turbo build && tsc -p ./ && node esbuild.config.js",
|
||||
"build:plugin": "npm run build && tsc && vsce package",
|
||||
"vscode:prepublish": "rollup --config rollup.config.js",
|
||||
"vscode:prepublish": "node esbuild.config.js",
|
||||
"compile": "tsc -p ./",
|
||||
"watch": "tsc -watch -p ./",
|
||||
"pretest": "npm run build",
|
||||
@ -237,11 +236,17 @@
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.12.1",
|
||||
"@seald-io/nedb": "^4.1.1",
|
||||
"@types/node-fetch": "^2.6.4",
|
||||
"abort-controller": "^3.0.0",
|
||||
"agentkeepalive": "^4.2.1",
|
||||
"axios": "^1.9.0",
|
||||
"bson": "^6.8.0",
|
||||
"form-data-encoder": "^1.7.2",
|
||||
"formdata-node": "^4.3.2",
|
||||
"https-proxy-agent": "^7.0.6",
|
||||
"openai": "^5.0.1",
|
||||
"pako": "^2.1.0",
|
||||
"pkce-challenge": "^5.0.0",
|
||||
"tesseract.js": "^6.0.1",
|
||||
"tslib": "^2.8.1",
|
||||
"uuid": "^11.1.0",
|
||||
@ -261,6 +266,7 @@
|
||||
"@vscode/test-cli": "^0.0.11",
|
||||
"@vscode/test-electron": "^2.5.2",
|
||||
"copy-webpack-plugin": "^13.0.0",
|
||||
"esbuild": "^0.25.5",
|
||||
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
||||
"null-loader": "^4.0.1",
|
||||
"rollup": "^4.43.0",
|
||||
|
@ -1,23 +0,0 @@
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
import json from '@rollup/plugin-json';
|
||||
|
||||
export default {
|
||||
input: 'src/extension.ts',
|
||||
output: {
|
||||
file: 'dist/extension.js',
|
||||
format: 'es',
|
||||
sourcemap: true
|
||||
},
|
||||
plugins: [
|
||||
json(),
|
||||
resolve({ browser: true }), // 支持 node_modules 解析
|
||||
commonjs(), // 转换 CommonJS 模块
|
||||
typescript() // 处理 TypeScript
|
||||
],
|
||||
external: ['vscode'], // 排除 VSCode 内置模块
|
||||
onwarn(warning, warn) {
|
||||
if (warning.code !== 'SOURCEMAP_ERROR') warn(warning);
|
||||
}
|
||||
};
|
@ -24,15 +24,7 @@ const serverPath = join(devHome, 'servers');
|
||||
const envPath = join(__dirname, '..', '.env');
|
||||
|
||||
const logger = pino({
|
||||
transport: {
|
||||
target: 'pino-pretty',
|
||||
options: {
|
||||
colorize: true,
|
||||
levelFirst: true,
|
||||
translateTime: 'SYS:yyyy-mm-dd HH:MM:ss',
|
||||
ignore: 'pid,hostname',
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export type MessageHandler = (message: VSCodeMessage) => void;
|
||||
|
@ -7,15 +7,7 @@ import { pino } from 'pino';
|
||||
|
||||
// 保留现有 logger 配置
|
||||
const logger = pino({
|
||||
transport: {
|
||||
target: 'pino-pretty',
|
||||
options: {
|
||||
colorize: true,
|
||||
levelFirst: true,
|
||||
translateTime: 'SYS:yyyy-mm-dd HH:MM:ss',
|
||||
ignore: 'pid,hostname',
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function getFilePath(options: {
|
||||
|
@ -20,15 +20,7 @@ export interface VSCodeMessage {
|
||||
}
|
||||
|
||||
const logger = pino.default({
|
||||
transport: {
|
||||
target: 'pino-pretty',
|
||||
options: {
|
||||
colorize: true,
|
||||
levelFirst: true,
|
||||
translateTime: 'SYS:yyyy-mm-dd HH:MM:ss',
|
||||
ignore: 'pid,hostname',
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export type MessageHandler = (message: VSCodeMessage) => void;
|
||||
|
32
src/test/e2e/runTest.ts
Normal file
32
src/test/e2e/runTest.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import * as path from 'path';
|
||||
|
||||
import { runTests } from '@vscode/test-electron';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
// 将 import.meta.url 转换为文件路径
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
// The folder containing the Extension Manifest package.json
|
||||
// Passed to `--extensionDevelopmentPath`
|
||||
const extensionDevelopmentPath = path.resolve(__dirname, '../../../');
|
||||
console.log('Extension Path:', extensionDevelopmentPath); // 添加日志验证路径
|
||||
// The path to the extension test script
|
||||
// Passed to --extensionTestsPath
|
||||
const extensionTestsPath = path.resolve(__dirname, './suite/index.js');
|
||||
|
||||
// Download VS Code, unzip it and run the integration test
|
||||
await runTests({
|
||||
extensionDevelopmentPath: extensionDevelopmentPath,
|
||||
extensionTestsPath: extensionTestsPath,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Failed to run tests');
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
15
src/test/e2e/suite/extension.test.ts
Normal file
15
src/test/e2e/suite/extension.test.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import * as assert from 'assert';
|
||||
|
||||
// You can import and use all API from the 'vscode' module
|
||||
// as well as import your extension to test it
|
||||
import * as vscode from 'vscode';
|
||||
// import * as myExtension from '../../extension';
|
||||
|
||||
suite('Extension Test Suite', () => {
|
||||
// vscode.window.showInformationMessage('Start all tests.');
|
||||
console.log("Running sample test")
|
||||
test('Sample test', () => {
|
||||
assert.strictEqual([1, 2, 3].indexOf(5), -1);
|
||||
assert.strictEqual([1, 2, 3].indexOf(0), -1);
|
||||
});
|
||||
});
|
43
src/test/e2e/suite/index.ts
Normal file
43
src/test/e2e/suite/index.ts
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
import * as path from 'path';
|
||||
import Mocha from 'mocha';
|
||||
import {glob} from 'glob';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
|
||||
export function run(): Promise<void> {
|
||||
// Create the mocha test
|
||||
const mocha = new Mocha({
|
||||
ui: 'tdd'
|
||||
});
|
||||
|
||||
const testsRoot = path.resolve(__dirname, '..');
|
||||
|
||||
return new Promise((c, e) => {
|
||||
glob('**/**.test.js', { cwd: testsRoot }).then((files: string[]) => {
|
||||
// Add files to the test suite
|
||||
console.log('Test files found:', files); // Log the found test files
|
||||
files.forEach((f: string) => mocha.addFile(path.resolve(testsRoot, f)));
|
||||
|
||||
try {
|
||||
// Run the mocha test
|
||||
console.log("Running test:", files)
|
||||
mocha.run(failures => {
|
||||
if (failures > 0) {
|
||||
e(new Error(`${failures} tests failed.`));
|
||||
} else {
|
||||
c();
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
e(err);
|
||||
}
|
||||
}).catch(err => {
|
||||
e(err);
|
||||
});
|
||||
});
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES6",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"target": "ES2020",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
@ -12,6 +12,7 @@
|
||||
"importHelpers": false,
|
||||
"noEmitHelpers": false,
|
||||
"experimentalDecorators": true,
|
||||
"sourceMap": true,
|
||||
// 允许访问 openmcp-sdk 目录
|
||||
"paths": {
|
||||
"@openmcp-sdk/*": [
|
||||
|
Loading…
x
Reference in New Issue
Block a user