Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Issue getting "this" context #1231

@SorsOps

Description

@SorsOps

See the following repo to reproduce https://github.com/SorsOps/corejs-reproducible-this

I used [email protected] for this instance

I've been investigating a weird inconsistency in figma plugins using core-js. When run in the developer vm, the following error would get thrown

figma_app.min.js.br:formatted:1782 TypeError: Cannot read properties of undefined (reading 'process')
    at ./node_modules/core-js/internals/engine-v8-version.js (engine-v8-version.js:4:1)
    at __webpack_require__ (compat get default export:2:1)
    at ./node_modules/core-js/internals/symbol-constructor-detection.js (symbol-constructor-detection.js:12:1)
    at __webpack_require__ (compat get default export:2:1)
    at ./node_modules/core-js/internals/use-symbol-as-uid.js (use-symbol-as-uid.js:6:1)
    at __webpack_require__ (compat get default export:2:1)
    at ./node_modules/core-js/internals/is-symbol.js (is-symbol.js:13:1)
    at __webpack_require__ (compat get default export:2:1)
    at ./node_modules/core-js/internals/to-primitive.js (to-primitive.js:13:1)
    at __webpack_require__ (compat get default export:2:1)

I'm using the developer VM checkbox when developing a figma plugin to test other inconsistencies in another project,

The above error seems to be related to this

When console logging each of the properties that core-js is checking for, I see that all are undefined in the developer VM. The exception is to just use the this context itself. I'm assuming attempting to access the this context doesn't work for all other platforms, but is it possible to add || this for the check in case all the proceeding attempts to access the global context fail?

When using the non developer VM, the first option, globalThis resolves and everything works fine

image

image

Additionally when changing the import to core-js to be core-js/stable (as opposed to core-js/stable/symbol I am using for the reproducible example) I also get the following error

figma_app.min.js.br:formatted:1782 TypeError: 'atob' is read-only
    at <anonymous> (PLUGIN_1_SOURCE:2265)
    at <anonymous> (PLUGIN_1_SOURCE:2900)
    at ./node_modules/core-js/modules/web.atob.js (PLUGIN_1_SOURCE:17041)
    at __webpack_require__ (PLUGIN_1_SOURCE:20008)
    at ./node_modules/core-js/stable/index.js (PLUGIN_1_SOURCE:19965)
    at __webpack_require__ (PLUGIN_1_SOURCE:20008)
    at <anonymous> (PLUGIN_1_SOURCE:20076)
    at <anonymous> (PLUGIN_1_SOURCE:20081)
    at <anonymous> (PLUGIN_1_SOURCE:20083)
    at call (native)
    at <eval> (PLUGIN_1_SOURCE:20087)

This cascades for more operations (like btoa, etc) where core-js is attempting to override the values.

When using an earlier version of [email protected] I did not get any of these errors, so this feels like a regression in behaviour. If its related to ensuring behaviour by overriding existing default lib functions like this, what would you suggest to return to the previous behaviour in the later versions of core-js

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions