53 lines
1.9 KiB
JavaScript
53 lines
1.9 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
// 测试runtime.js文件的处理
|
|
async function testRuntimeFile() {
|
|
console.log('🧪 Testing runtime.js file processing');
|
|
console.log('=====================================');
|
|
|
|
const runtimePath = path.join(__dirname, '../../dist/common/runtime.js');
|
|
|
|
if (!fs.existsSync(runtimePath)) {
|
|
console.log('❌ runtime.js file not found');
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const originalCode = fs.readFileSync(runtimePath, 'utf8');
|
|
console.log(`📄 Original file size: ${originalCode.length} characters`);
|
|
|
|
// 检查语法错误
|
|
const lines = originalCode.split('\n');
|
|
let foundError = false;
|
|
|
|
for (let i = 0; i < lines.length; i++) {
|
|
const line = lines[i].trim();
|
|
if (line.includes('p[s][0]') && !line.includes('p[s][0];')) {
|
|
console.log(`⚠️ Syntax error at line ${i + 1}: ${line.substring(0, 50)}...`);
|
|
foundError = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (foundError) {
|
|
console.log('🔧 Syntax error detected - file should be skipped');
|
|
} else {
|
|
console.log('✅ No obvious syntax errors found');
|
|
}
|
|
|
|
// 尝试本地处理
|
|
const cleanedCode = originalCode.replace(/console\.(log|error|warn|info|debug|assert|trace|table|group|groupEnd|time|timeEnd)\s*\([^;]*?\);?\s*/g, '');
|
|
console.log(`🧹 Cleaned file size: ${cleanedCode.length} characters`);
|
|
console.log(`📉 Size reduction: ${originalCode.length - cleanedCode.length} characters`);
|
|
|
|
console.log('\n✅ Runtime.js test completed successfully!');
|
|
|
|
} catch (error) {
|
|
console.error('❌ Error processing runtime.js:', error.message);
|
|
}
|
|
}
|
|
|
|
testRuntimeFile(); |