Files
weixin-plugin-test/scripts/build-weixin-plugin.sh
zyh 754f67d433 fix: 修复微信插件编译错误并添加缺失依赖
- 添加 zod 和 silk-wasm 依赖
- 修复 clearStaleAccountsForUserId 导入错误(函数不存在)
- 修复 TypeScript cause 属性类型问题
- 修复 channel.ts 中的模块导入问题
- 更新 weixinGateway.ts 添加 .js 扩展名支持 ES 模块
- 更新编译脚本使用 bundler 模式

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-30 07:41:05 +00:00

102 lines
2.0 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 微信插件 TypeScript 编译脚本
# 用于快速编译 weixin-plugin 目录下的 TypeScript 文件
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
WEIXIN_PLUGIN_DIR="$PROJECT_ROOT/weixin-plugin"
echo "微信插件编译脚本"
echo "================"
echo ""
# 检查依赖
echo "1. 检查依赖..."
if ! command -v npx &> /dev/null; then
echo " ✗ npx 未找到"
echo " 请确保 Node.js 和 npm 已正确安装"
exit 1
fi
echo " ✓ npx 已找到"
# 检查是否安装了 typescript
if ! npm list typescript &> /dev/null; then
echo " 正在安装 typescript..."
npm install
fi
echo " ✓ typescript 已准备就绪"
echo ""
# 创建临时 tsconfig
echo "2. 创建编译配置..."
cat > "$WEIXIN_PLUGIN_DIR/tsconfig.json" << 'EOF'
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"lib": ["ES2020"],
"moduleResolution": "bundler",
"esModuleInterop": true,
"skipLibCheck": true,
"strict": false,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./dist",
"rootDir": ".",
"declaration": false,
"sourceMap": false
},
"include": [
"**/*.ts"
],
"exclude": [
"node_modules",
"dist"
]
}
EOF
echo " ✓ tsconfig.json 已创建"
echo ""
# 编译
echo "3. 开始编译..."
echo ""
cd "$WEIXIN_PLUGIN_DIR"
# 使用 tsc 编译
npx tsc
echo ""
echo " ✓ 编译完成"
echo ""
# 检查输出
echo "4. 检查输出文件..."
JS_COUNT=$(find dist -name "*.js" -type f 2>/dev/null | wc -l)
echo " 生成了 $JS_COUNT 个 JavaScript 文件"
if [ "$JS_COUNT" -eq 0 ]; then
echo " ✗ 编译可能失败dist 目录为空"
exit 1
fi
echo ""
echo "================"
echo "编译成功!"
echo ""
echo "编译后的文件位于: $WEIXIN_PLUGIN_DIR/dist/"
echo ""
echo "你现在可以运行测试脚本了:"
echo " npm run test:simple"