Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Unable to overwrite globals. #10

@reggi

Description

@reggi

Here's an example where I'm requiring a file ./global.js Array.marker a property of a global variable is not being updated.

// file eval ./example.js
var _eval = require('eval')
var code = [
  'Array.marker = true',
  "require('./global.js')",
  'console.log(Array.marker)' // => true
].join('\n')

var fileName = __dirname + '/example.js'

_eval(code, fileName, {}, {
  'require': require
})
// file eval ./global.js
var hi = function () {
  Array.marker = false
}
module.exports = hi()

Is there any way to make it so that the required module edits the global value for Array.marker?

Note, I'm replacing requireLike with require. So we can see that it's not requireLike that is causing the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions