Closed suntong closed 6 years ago
Please have a look at https://github.com/zixia/hot-import/blob/master/examples/demo-js.ts, it should work without any problem.
After that, you will be able to compare the example with your code and find out which part caused your error.
Good luck!
Actually, I've duplicated it as mine, https://github.com/suntong/nodecl/blob/master/sbaa/cfg_hot/demo1.js
and yes, it works without any problem. However, it is from demo1.js to demo2.js that causes the problem, and as explained in OP, the problem happens at proxyModule
at hot-import.js:214:19
.
So what did you do/change in the demo2 from demo1?
I believe these too lines are making the big differences:
https://github.com/suntong/nodecl/blob/master/sbaa/cfg_hot/demo2.js#L12-L13
It seems you have to export a function
instead of an object
.
try to use a factory function to get your data:
const MODULE_CODE_1 = 'const config = {v: 3}; module.exports = () => return config'
const MODULE_CODE_2 = 'const config = {v: 5}; module.exports = () => config'
That works like a charm! Thanks a lot for your help!
BTW: if you change
- const v1 = hotMod()
+ const v1 = hotMod
in your code, you could also fix your problem before.
Ahh! Yes, I was wondering why I have to use a hotMod()
function call earlier, :-)
That really make it clear now. Thanks a lot for the follow up!
Please take a look at the file https://github.com/suntong/nodecl/blob/master/sbaa/cfg_hot/demo2.js
When I run it, I get
How to fix it? Thx!