huan / hot-import

Hot Module Replacement (HMR) for Node.js
https://npmjs.com/package/hot-import
Apache License 2.0
25 stars 2 forks source link

Hotimport will occur error when update the code #7

Open lijiarui opened 6 years ago

lijiarui commented 6 years ago

Reproduce

  1. In file a.ts I using the following code

    if (!hotMod || !hotMod.connector) {
    hotMod = await hotImport('../bot-logic')
    console.log('####### connector init inside on image', hotMod)
    }
    
    hotMod.connector.processMessage(message.room() || message.from(), message.from(), '#faceExist' + md5List)

../bot-logic code as follows

export const connector = new WechatyConnector()
  1. When I change code in a.ts, it will throw error

    ####### connector init inside on image undefined
    TypeError: Cannot read property 'connector' of undefined
    at Wechaty.<anonymous> (/Users/jiaruili/git/rui/wechaty-blinder/src/listeners/message.ts:265:9)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/jiaruili/git/rui/wechaty-blinder/src/listeners/message.ts:4:58)
    at <anonymous>
    21:15:20 WARN Contact parse() got empty rawObj!
  2. When I restart the code, the error will disappear, if I change code in a.ts again, I will get the following error again.

huan commented 6 years ago

Sorry, I want to help but what you provide is not a minimum executable code.