Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dario-piotrowicz/cjs-module-lexer-reexports-repro
https://github.com/dario-piotrowicz/cjs-module-lexer-reexports-repro
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dario-piotrowicz/cjs-module-lexer-reexports-repro
- Owner: dario-piotrowicz
- Created: 2024-08-07T22:45:03.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-07T23:25:02.000Z (3 months ago)
- Last Synced: 2024-08-08T02:14:32.244Z (3 months ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cjs-module-lexer-reexports-repro
This repo simply shows the fact that `cjs-module-lexer` can produce unhelpful reexport results.
Specifically, the lexer [resets the reexport set](https://github.com/nodejs/node/blob/2bcf9995d28758584f34382bc402995f268d1b64/deps/cjs-module-lexer/lexer.js#L913) causing only the last instance of `module.exports = require(...)` to be considered.
For example parsing the below code:
```js
if (true) {
module.exports = require("./a.cjs");
} else {
module.exports = require("./b.cjs");
}
```yields `{ exports: [], reexports: [ './b.cjs' ] }`, completely loosing the information that the module is also trying to re-export from `'./a.cjs'`
## Reproduction steps
```
npm i
``````
npm start
```