nodejs / nodejs/cjs-module-lexer
Export not detected
Open
Nobody has claimed this yet.
bug
- Dominant language
- JavaScript
- Stars
- 262
- Forks
- 31
- Avg merge
- 9d 2h
- Merged PRs (30d)
- 5
Description
⚠️ This is not real-world code. It's technically a bug, but no real program will notice it. Feel free to close this issue!
Consider this non-strict mode code: (GitHub's syntax highlighting is broken)
function fn() {
yield / "/ //" /*
}
/*/
}
module.exports.foo = 2;
// */
The tokens are:
[function] [Identifier: fn] [paren left] [paren left] [brace left]
[Identifier: yield] [division] [String: "/ //"] [Comment: \n}\n/ ]
[brace right]
[Identifier: module] [dot] [Identifier: exports] [dot] [Identifier: foo] [equal] [Number: 2] [semicolon]
However, cjs-module-lexer returns { exports: [], reexports: [] }.
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 by running the provided non-strict JavaScript snippet through cjs-module-lexer and inspect how it tokenizes the yield, regular expression, and comment sequence. Done means the lexer detects foo in module.exports rather than returning empty exports and reexports results, with regression coverage for this input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100