Skip to content

Commit e5fcb1e

Browse files
authored
fix(esbuild): 修复引入外部依赖时pnpm构建异常的问题 (#25)
* fix: 移除 activationEvents 空数组 - 删除 package.json 里的 "activationEvents": [] 。 由于vscode为所有命令生成激活事件 * fix(esbuild): 修复引入外部依赖时pnpm构建异常的问题 - 修改了 DataCollector 类中获取用户设置和工作区设置的方式,直接返回字符串内容 - 更新了 SettingsExport 接口,将 user 和 workspace 的类型改为 string
1 parent d176746 commit e5fcb1e

File tree

4 files changed

+14
-23
lines changed

4 files changed

+14
-23
lines changed

package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-syncing",
33
"displayName": "vscode-syncing",
44
"description": "vscode-syncing extension",
5-
"version": "0.2.2",
5+
"version": "0.2.3",
66
"publisher": "sunerpy",
77
"icon": "resources/logo.png",
88
"engines": {
@@ -124,12 +124,13 @@
124124
"prepare": "husky",
125125
"lint": "eslint src",
126126
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"",
127-
"vscode:prepublish": "pnpm run package",
127+
"vscode:prepublish": "npm run esbuild-base -- --minify",
128+
"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node",
128129
"compile": "pnpm run check-types && pnpm run lint && node esbuild.js",
129130
"watch": "npm-run-all -p watch:*",
130131
"watch:esbuild": "node esbuild.js --watch",
131132
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
132-
"package": "pnpm run check-types && pnpm run lint && node esbuild.js --production",
133+
"package": "pnpm run vscode:prepublish",
133134
"package:vsix": "pnpm run package && pnpm vsce package --no-dependencies",
134135
"compile-tests": "tsc -p . --outDir out",
135136
"watch-tests": "tsc -p . -w --outDir out",
@@ -167,8 +168,5 @@
167168
"prettier": "3.6.2",
168169
"typescript": "^5.8.3"
169170
},
170-
"packageManager": "[email protected]+sha512.f549b8a52c9d2b8536762f99c0722205efc5af913e77835dbccc3b0b0b2ca9e7dc8022b78062c17291c48e88749c70ce88eb5a74f1fa8c4bf5e18bb46c8bd83a",
171-
"dependencies": {
172-
"jsonc-parser": "^3.3.1"
173-
}
174-
}
171+
"packageManager": "[email protected]+sha512.f549b8a52c9d2b8536762f99c0722205efc5af913e77835dbccc3b0b0b2ca9e7dc8022b78062c17291c48e88749c70ce88eb5a74f1fa8c4bf5e18bb46c8bd83a"
172+
}

pnpm-lock.yaml

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

src/dataCollector.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
getPlatform,
1818
} from './utils/vscodeEnvironment';
1919
import { VSCodeEdition, Platform } from './types/vscodeEdition';
20-
import * as jsonc from 'jsonc-parser';
2120

2221
export class DataCollector {
2322
public readonly vscodeEdition: VSCodeEdition;
@@ -107,13 +106,13 @@ export class DataCollector {
107106
// 获取用户设置
108107
const userSettings = this.getUserSettings();
109108
if (userSettings) {
110-
settings.user = userSettings;
109+
(settings as any).user = userSettings;
111110
}
112111

113112
// 获取工作区设置
114113
const workspaceSettings = this.getWorkspaceSettings();
115114
if (workspaceSettings) {
116-
settings.workspace = workspaceSettings;
115+
(settings as any).workspace = workspaceSettings;
117116
}
118117

119118
return settings;
@@ -215,12 +214,11 @@ export class DataCollector {
215214
return snippets;
216215
}
217216

218-
private getUserSettings(): Record<string, unknown> | null {
217+
private getUserSettings(): string | null {
219218
try {
220219
const settingsPath = this.getUserSettingsPath();
221220
if (fs.existsSync(settingsPath)) {
222-
const content = fs.readFileSync(settingsPath, 'utf8');
223-
return jsonc.parse(content);
221+
return fs.readFileSync(settingsPath, 'utf8');
224222
}
225223
} catch (error) {
226224
if (this.outputChannel) {
@@ -230,14 +228,13 @@ export class DataCollector {
230228
return null;
231229
}
232230

233-
private getWorkspaceSettings(): Record<string, unknown> | null {
231+
private getWorkspaceSettings(): string | null {
234232
try {
235233
if (vscode.workspace.workspaceFolders) {
236234
const workspaceFolder = vscode.workspace.workspaceFolders[0];
237235
const settingsPath = path.join(workspaceFolder.uri.fsPath, '.vscode', 'settings.json');
238236
if (fs.existsSync(settingsPath)) {
239-
const content = fs.readFileSync(settingsPath, 'utf8');
240-
return jsonc.parse(content);
237+
return fs.readFileSync(settingsPath, 'utf8');
241238
}
242239
}
243240
} catch (error) {

src/types/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export interface ExtensionsExport {
2424
}
2525

2626
export interface SettingsExport {
27-
user?: Record<string, unknown>;
28-
workspace?: Record<string, unknown>;
27+
user?: string;
28+
workspace?: string;
2929
}
3030

3131
export interface ThemeInfo {

0 commit comments

Comments
 (0)