// CommonJS
function module() {}
exports.x = module;
Output:
export default {x: {exports: void 0}};
The reason is that instrumentation passes module to Livepack's init function, and it adds it to globals as a module object.
This problem only applies to function declarations because they're hoisted to top of scope. const module, let module and class module would all be syntax errors, and var module would still leave the value of module unchanged at start of the file.
Could try to modify the source to prevent this, but probably better to patch Module.prototype.load to capture the module object there.
Input:
Output:
The reason is that instrumentation passes
module
to Livepack'sinit
function, and it adds it toglobals
as a module object.This problem only applies to function declarations because they're hoisted to top of scope.
const module
,let module
andclass module
would all be syntax errors, andvar module
would still leave the value ofmodule
unchanged at start of the file.Could try to modify the source to prevent this, but probably better to patch
Module.prototype.load
to capture the module object there.