nodejs / nodejs/cjs-module-lexer
Incompatibility with TypeScript (edge case)
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
I have a very simple TypeScript file:
export { default as bar } from './bar'
When transpiled with tsc (4.8) and esModuleInterop set to true the transpiled code will somehow look like this:
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.bar = void 0;
var bar_1 = require("./bar");
Object.defineProperty(exports, "bar", { enumerable: true, get: function () { return __importDefault(bar_1).default; } });
In this case, the lexer seems to be ignoring the bar export.
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
Reproduce the report using the TypeScript 4.8 output shown in the issue, then inspect how the lexer handles the require("./bar") call and its Object.defineProperty getter. Done means the named bar export is recognized for this transpiled pattern and the existing lexer behavior remains covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100