export default causes CommonJS bundles to include .default
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
Adding `export default` to the main code causes CommonJS bundles to include .default and returns an error if not:
```
C:\Users\davet\Documents\sudokutest\index.js:15
console.log("Empty: ", sudoku.findAllEmpty(grid));
^
TypeError: sudoku.findAllEmpty is not a function
at Object. (C:\Users\davet\Documents\sudokutest\index.js:15:31)
at Module._compile (node:internal/modules/cjs/loader:1565:14)
at Object..js (node:internal/modules/cjs/loader:1708:10)
at Module.load (node:internal/modules/cjs/loader:1318:32)
at Function._load (node:internal/modules/cjs/loader:1128:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
at node:internal/main/run_main_module:36:49
Node.js v22.12.0
```
With .default

Without .default

Contributor guide
Research direction
Reproduce the issue with the provided index.js CommonJS example under Node.js, then trace tsup's handling of export default in the CommonJS bundle. Done means the generated bundle exposes findAllEmpty directly, matching the no-.default example, without the reported TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100