nodejs / nodejs/cjs-module-lexer
Can't export when enumerable is "!0"
Open
Nobody has claimed this yet.
edge case
wontfix
- Dominant language
- JavaScript
- Stars
- 262
- Forks
- 31
- Avg merge
- 9d 2h
- Merged PRs (30d)
- 5
Description
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.

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;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at lexer.js around line 370, where enumerable values are recognized during CommonJS export analysis. Reproduce the provided input containing enumerable: true and enumerable: !0, then verify that both "a" and "b" are reported as named exports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100