Skip to content

Can't export when enumerable is "!0" #64

@zhoukekestar

Description

@zhoukekestar

Input File:

Object.defineProperty(exports, 'a', {
  enumerable: true,
  value: 'a'
});

Object.defineProperty(exports, 'b', {
  enumerable: !0,
  value: 'b'
});

Expected Result: ["a", "b"]
Actual Result: ["a"]

We can get this case when we use uglifyjs to minify our source code.
image

The Error is occured in https://github.com/guybedford/cjs-module-lexer/blob/a96e7b52b99d39fee25d69f356905161d14a15ed/lexer.js#L370

Here is a simple solution:

          if (source.startsWith('true', pos)) {
            pos += 4;
          } else if (source.startsWith('!0', pos)) {
            pos += 2;
          } else {
            break;
          }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions