[api-extractor] Unable to analyze the export "Seq" when bundling immutable v5
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 58/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- node.js, typescript
- Domain
- build-system, tooling
Research direction
Start with API Extractor's ExportAnalyzer._getExportOfAstModule and reproduce the failure using immutable@5.1.5, TypeScript 5.7.3, and the entry declaration described in the issue. Compare how Seq and its nested namespaces are resolved against immutable@4.x; done means the bundled .d.ts rollup succeeds and inlines immutable's declarations without the internal export-analysis error.
Written by the indexing model from the issue text.
Description
Summary
@microsoft/api-extractor crashes with an internal error when immutable (v5) is listed in bundledPackages. The crash happens during analysis of the Seq export and is reproducible against an unmodified immutable@5.1.5 install.
This blocks distributing a self-contained .d.ts rollup for any consumer that re-exports types from immutable v5. The same project bundled immutable@4.x without issue, so the regression is on the Immutable v5 declaration shape.
Repro steps
-
npm i immutable@5.1.5 @microsoft/api-extractor@7.58.7 typescript@5.7.3 -
Create an entry
.d.tsthat re-exports something from immutable, e.g.:import type { List } from 'immutable' export declare function getList(): List<string> -
In
api-extractor.jsonset"bundledPackages": ["immutable"]. -
Run
api-extractor run --local --diagnostics.
Expected result: API Extractor inlines Immutable's declarations into the rollup, as it does for immutable@4.x.
Actual result:
ERROR: Internal Error: Unable to analyze the export "Seq" in node_modules/immutable/dist/immutable.d.ts
You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.
Error: API Extractor failed with exit code 1
Details
The Immutable v5 declaration uses the same overall shape as v4 (declare namespace Immutable { … } export = Immutable; export as namespace Immutable;), but Seq and its nested namespaces (Seq.Keyed, Seq.Indexed, Seq.Set) are declared in a way that ExportAnalyzer._getExportOfAstModule can't resolve.
Workaround we ended up using: remove immutable from bundledPackages, let API Extractor emit import … from 'immutable', then post-process the rollup with a small script that inlines the namespace and rewrites the renamed imports (Immutable_2, Map_3, Set_2, …) to local aliases of the inlined namespace. Happy to share if it helps reproduce.
Related to (but distinct from) #2220, #1972, #5507, #5694. Those all surface the same generic "Unable to analyze the export" error from different triggers.
Standard questions
| Question | Answer |
|---|---|
@microsoft/api-extractor version? |
7.58.7 |
| Operating system? | macOS (also reproduces in Linux CI) |
| API Extractor scenario? | rollups (.d.ts) |
| Would you consider contributing a PR? | No (unfamiliar with ExportAnalyzer internals) |
| TypeScript compiler version? | 5.7.3 |
Node.js version (node -v)? |
v24.13.0 |
- Dominant language
- TypeScript
- Stars
- 6.5k
- Forks
- 708
- Avg merge
- 5d 19h
- Merged PRs (30d)
- 48
Contributor guide
No contributing guide indexed for this repository
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.
More from microsoft/rushstack
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
All issues in microsoft/rushstack
Similar issues
-
clawsweeper:linked-pr-open clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:message-loss issue-rating: 🦞 diamond lobster maturity:stable P2
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#616 ·
-
ZCode 3.14.3 に対応する Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
supermomonga/zcode-acp#24 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
growthbook/growthbook#7100 ·
-
triage
Difficulty 1/5 1-3 hours Newbie friendliness 88/100