Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: global object conflicting property descriptors #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mdevils
Copy link

@mdevils mdevils commented Dec 2, 2024

In the modern versions of node.js many globals are defined as properties with accessors, providing them using globals parameter just throws an exception.

Here is an example reproduction code:

const importedFromString = await importFromString('export const result = typeof Buffer;', {
    globals: { Buffer },
});

Here is the error I'm getting:

TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>

The problem is that createGlobalObject() function extracts property descriptors from the current global and adds value to it and then adds that property descriptor to the generated global. Problem with it is that value cannot co-exist with get / set method as described here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#set

@mdevils
Copy link
Author

mdevils commented Jan 20, 2025

@exuanbo is this project still active?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant