microsoft / microsoft/fluentui
API extractor prevents usage of re-exports 💥
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 20.3k
- Forks
- 2.9k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 46
Description
In I am trying to re-export functions in #20628:
// 🚨 breaks build
export * as shorthands from './shorthands/index';
But it's impossible, see #18906. I modified code to use import/export as suggested:
// 🚨 still breaks build
import * as shorthands from "./shorthands/index";
export { shorthands };
Error is similar to #19360, but it seems that problem is different as it breaks on @fluentuiu/react-make-styles that contains re-export:
ERR! [10:48:59 AM] ■ Extracting Public API surface from 'packages\react-make-styles\lib\index.d.ts'
ERR! Analysis will use the bundled TypeScript version 4.1.5
ERR! [10:48:59 AM] x Error detected while running '_wrapFunction'
ERR! [10:48:59 AM] x ------------------------------------
ERR! [10:49:00 AM] x Error: Internal Error: The ""packages/make-styles/lib/shorthands/index"" symbol has a ts.SyntaxKind.SourceFile declaration which is not (yet?) supported by API Extractor
ERR!
ERR! You have encountered a software defect. Please consider reporting the issue to the maintainers of this
application.
Only code below passes build:
import { margin, padding } from "./shorthands/index";
export const shorthands = { margin, padding };
But it breaks tree shaking for bundlers as shorthands is an object now and any usage of shorthands.* will include all functions to bundle *.
- * if Terser is not used, but it will be used in any setup
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.
Research direction
Reproduce the API Extractor failure from packages/react-make-styles/lib/index.d.ts, focusing on the re-export through packages/make-styles/lib/shorthands/index and the @fluentuiu/react-make-styles build. Compare the failing namespace re-exports with the working explicit-export example and the related issues #18906 and #19360. Done means the intended re-export passes API Extractor without requiring an object workaround that harms tree shaking.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100