mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-16 14:10:52 +01:00
- Add post-build script to fix Temporal Dead Zone error in generated code - Remove debug logging from stores and composables - Simplify init-logger plugin to essential error handling - Fix circular store dependency in useUiStore 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Post-build script to fix the Vite 7.x TDZ error in __vite__mapDeps
|
|
* This script patches the generated JavaScript files after the build
|
|
*/
|
|
|
|
import { readdir, readFile, writeFile } from 'node:fs/promises'
|
|
import { join } from 'node:path'
|
|
|
|
const NUXT_DIR = join(process.cwd(), '.output/public/_nuxt')
|
|
|
|
async function fixFile(filePath) {
|
|
const content = await readFile(filePath, 'utf-8')
|
|
const fixedContent = content.replace(
|
|
/const __vite__mapDeps=\(i,m=__vite__mapDeps,/g,
|
|
'let __vite__mapDeps;__vite__mapDeps=(i,m=__vite__mapDeps,'
|
|
)
|
|
|
|
if (fixedContent !== content) {
|
|
await writeFile(filePath, fixedContent, 'utf-8')
|
|
console.log(`✓ Fixed TDZ error in ${filePath.split('/').pop()}`)
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
async function main() {
|
|
try {
|
|
const files = await readdir(NUXT_DIR)
|
|
const jsFiles = files.filter((f) => f.endsWith('.js'))
|
|
|
|
let fixedCount = 0
|
|
for (const file of jsFiles) {
|
|
const filePath = join(NUXT_DIR, file)
|
|
const fixed = await fixFile(filePath)
|
|
if (fixed) fixedCount++
|
|
}
|
|
|
|
if (fixedCount > 0) {
|
|
console.log(`\n✓ Fixed __vite__mapDeps TDZ error in ${fixedCount} file(s)`)
|
|
} else {
|
|
console.log('\n✓ No __vite__mapDeps TDZ errors found')
|
|
}
|
|
} catch (error) {
|
|
console.error('Error fixing __vite__mapDeps:', error)
|
|
process.exit(1)
|
|
}
|
|
}
|
|
|
|
main()
|