Description
🐛 bug report
Description of the problem
I noticed that HMR doesn't work for CxJS based templates. The update fails with error
Cannot set property computable of #<Object> which has only a getter
.
I reproduced the issue with vanilla template too and you can see it in the attached sandbox.
This issue is easily reproducible with CxJS, but the problem might not be CxJS specific.
On every change, for unknown reason, the module node_modules/cx/dist/ui.js
gets re-evaluated. On second run, the exports
object passed to the evaluate function is non-empty and the function fails. You can easily see that if you add a breakpoint in that module.
The file re-exports the computable
function from another module like this:
export { computable } from "cx/data";
This gets translated into
exports.computable = undefined;
var _data2 = require("./data");
Object.defineProperty(exports, "computable", {
enumerable: true,
get: function () {
return _data2.computable;
}
});
On second run, it fails on the first line.
I tried to replicate the issue without using the cx package, but, for local files, exports is an empty object on each run. I guess that files in node_modules and src files are treated differently for some reason. I'm not sure how to fix this on my own and I really hate that yarn install fails on Windows. Any help would be highly appreciated.
How has this issue affected you? What are you trying to accomplish?
HMR shuld work for CxJS based sandboxes.
Link to sandbox: 94qq4l97ly
Your Environment
Software | Name/Version |
---|---|
Сodesandbox | Lastest |
Browser | Chrome |
Operating System | Windows 10 |