vuejs / vue-vapor

Vue Vapor is a variant of Vue that offers rendering without the Virtual DOM.
https://vapor-repl.netlify.app
MIT License
1.86k stars 89 forks source link

VaporLifecycleHooks is undefined #243

Closed xiaodong2008 closed 3 months ago

xiaodong2008 commented 3 months ago

packages/runtime-vapor/src/errorHandling.ts

import { VaporLifecycleHooks } from './apiLifecycle'

console.log(VaporLifecycleHooks) // undefined

export const ErrorTypeStrings: Record<ErrorTypes, string> = {
  [VaporLifecycleHooks.BEFORE_MOUNT]: 'beforeMount hook',
  [VaporLifecycleHooks.MOUNTED]: 'mounted hook',
  [VaporLifecycleHooks.BEFORE_UPDATE]: 'beforeUpdate hook',
  // ...

Error Output

 FAIL  packages/runtime-vapor/__tests__/errorHandling.spec.ts [ packages/runtime-vapor/__tests__/errorHandling.spec.ts ]
TypeError: Cannot read properties of undefined (reading 'BEFORE_MOUNT')
 ❯ packages/runtime-vapor/src/errorHandling.ts:49:24
     47| export const ErrorTypeStrings: Record<ErrorTypes, string> = {
     48|   // [VaporLifecycleHooks.SERVER_PREFETCH]: 'serverPrefetch hook',
     49|   [VaporLifecycleHooks.BEFORE_MOUNT]: 'beforeMount hook',
       |                        ^
     50|   [VaporLifecycleHooks.MOUNTED]: 'mounted hook',
     51|   [VaporLifecycleHooks.BEFORE_UPDATE]: 'beforeUpdate hook',
 ❯ packages/runtime-vapor/src/warning.ts:4:31
xiaodong2008 commented 3 months ago

I think this problem is caused by circular dependencies.

Report:

5) src/component.ts > src/apiCreateVaporApp.ts > src/apiInject.ts > src/warning.ts > src/errorHandling.ts > src/apiLifecycle.ts
6) src/errorHandling.ts > src/apiLifecycle.ts
7) src/warning.ts > src/errorHandling.ts > src/apiLifecycle.ts
8) src/component.ts > src/apiCreateVaporApp.ts > src/apiInject.ts > src/warning.ts > src/errorHandling.ts
9) src/warning.ts > src/errorHandling.ts