({}).constructor === Object is not working as expected, it should be true, but it's false if the code is run inside the plugin's code. As many libraries rely on that (bad practice) check, they don't fully work (such as aws sdk #56)
This is a local hack, but easy enough to reproduce. It can be tested with any plugin, as we can simply replace 2 lines (in dist if you don't want to rebuild).
this line
|
const iifeCode = `(function(exports){${newLine}${code}${newLine}}(module.exports));`; |
replace by the following 2 lines.
console.log('This is outside plugin:', new Object().constructor === Object, ({}).constructor === Object)
const iifeCode = `console.log('This is inside', new Object().constructor === Object, ({}).constructor === Object)`;
The output is
This is outside plugin: true true
This is inside true false
I spent some time trying to customize the context variables with no luck. Maybe someone with more expertise, I have no clue how the constructor of {} is defined in that child context we create.
Thanks!
({}).constructor === Objectis not working as expected, it should betrue, but it'sfalseif the code is run inside the plugin's code. As many libraries rely on that (bad practice) check, they don't fully work (such as aws sdk #56)This is a local hack, but easy enough to reproduce. It can be tested with any plugin, as we can simply replace 2 lines (in dist if you don't want to rebuild).
this line
live-plugin-manager/dist/src/PluginVm.js
Line 133 in a05d1fd
replace by the following 2 lines.
The output is
I spent some time trying to customize the context variables with no luck. Maybe someone with more expertise, I have no clue how the constructor of
{}is defined in that child context we create.Thanks!