Skip to content

Module.wrap override breaks shadowing for globals #4

@zyrolasting

Description

@zyrolasting

Create a src.js with the following.

let console = 1;

node src.js runs without error because function-level shadowing of globals is permitted. That program would break with SyntaxError: Identifier 'require' has already been declared if you replace console with require.

lya breaks with the the same error for console due to its Module.wrap override, regardless if it uses var or let as a variable declarator. This is because it injects known global identifiers into the same module function's scope.

Is there a note somewhere that tells users that they cannot shadow any global identifiers used by Lya in this way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions