Why Function("return this")() is undefined?

Bug here

if code.js of figma plugin includes Function(return this)(), its value is undefined?

It seems like a bug ONLY since 2022.7.14 :thinking:

this is my code (removed extraneous code)

  let freeSelf = typeof self === 'object' && self && self.Object === Object && self;
  let root = freeGlobal_default || freeSelf || Function('return this')();

  console.log('Function("return this")()', Function('return this')(), Function); // console here

  let root_default = root;
  let Symbol2 = root_default.Symbol; // oops, bug here

Reproducible code

Add these two lines of code to the webpack-react plugin demo to reproduce.

Solve this problem by removing developer VM option.

Is there a better workaround for this? Iā€™d like to use developer VM but cannot due to this bug. Some packages like lodash need global or this to be defined

Sorry Irvin, I do not have a better solution for it.