Skip to content

__name is not in scope if a class is stringified. #1438

@yoshikiohshima

Description

@yoshikiohshima

Related to #1437, a function in code:

class Foo {
    foo() {
        let add = (e) => console.log(e);
       add("x");
   }
}

becomes:

var Foo = class {
  foo() {
    let add = /* @__PURE__ */ __name((e) => console.log(e), "add");
    add("x");
  }
};

when bundled with --bundle --keep-names --format=esm options.

However, __name function is not in the scope when the class is stringified by toString() and then eval()'ed again. An anonymous function like add above does not need to have .name property if it did not have one in code.

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