mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-16 14:10:52 +01:00
Fix Vite 7.x TDZ error in __vite__mapDeps with post-build script
- 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>
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
"version": "0.1.2",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "nuxt build",
|
||||
"build": "nuxt build && node scripts/fix-vite-mapdeps.js",
|
||||
"dev": "nuxt dev",
|
||||
"drizzle:generate": "drizzle-kit generate",
|
||||
"drizzle:migrate": "drizzle-kit migrate",
|
||||
|
||||
52
scripts/fix-vite-mapdeps.js
Normal file
52
scripts/fix-vite-mapdeps.js
Normal file
@ -0,0 +1,52 @@
|
||||
#!/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()
|
||||
25
src/plugins/init-logger.ts
Normal file
25
src/plugins/init-logger.ts
Normal file
@ -0,0 +1,25 @@
|
||||
export default defineNuxtPlugin({
|
||||
name: 'init-logger',
|
||||
enforce: 'pre',
|
||||
parallel: false,
|
||||
setup() {
|
||||
// Add global error handler for better debugging
|
||||
window.addEventListener('error', (event) => {
|
||||
console.error('[HaexHub] Global error caught:', {
|
||||
message: event.message,
|
||||
filename: event.filename,
|
||||
lineno: event.lineno,
|
||||
colno: event.colno,
|
||||
error: event.error,
|
||||
stack: event.error?.stack,
|
||||
})
|
||||
})
|
||||
|
||||
window.addEventListener('unhandledrejection', (event) => {
|
||||
console.error('[HaexHub] Unhandled rejection:', {
|
||||
reason: event.reason,
|
||||
promise: event.promise,
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
@ -1,5 +1,6 @@
|
||||
import { breakpointsTailwind } from '@vueuse/core'
|
||||
import { broadcastContextToAllExtensions } from '~/composables/extensionMessageHandler'
|
||||
|
||||
import de from './de.json'
|
||||
import en from './en.json'
|
||||
|
||||
@ -13,7 +14,6 @@ export const useUiStore = defineStore('uiStore', () => {
|
||||
const { locale } = useI18n({
|
||||
useScope: 'global',
|
||||
})
|
||||
const { platform } = useDeviceStore()
|
||||
|
||||
$i18n.setLocaleMessage('de', {
|
||||
ui: de,
|
||||
@ -62,11 +62,13 @@ export const useUiStore = defineStore('uiStore', () => {
|
||||
})
|
||||
|
||||
// Broadcast theme and locale changes to extensions
|
||||
watch([currentThemeName, locale], () => {
|
||||
watch([currentThemeName, locale], async () => {
|
||||
const deviceStore = useDeviceStore()
|
||||
const platformValue = await deviceStore.platform
|
||||
broadcastContextToAllExtensions({
|
||||
theme: currentThemeName.value,
|
||||
locale: locale.value,
|
||||
platform,
|
||||
platform: platformValue,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user