fluentui
fluentui copied to clipboard
API extractor prevents usage of re-exports 💥
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
Blocked by https://github.com/microsoft/rushstack/issues/2780
not sure if rollup repl uses terser ( or any kind of mangler ) ? I tried terser REPL and it tree-shakes as expected
↓↓↓↓
https://try.terser.org/ ->

here is actual repro https://stackblitz.com/edit/rollup-tree-shaking-with-export-as-namespace?devtoolsheight=33&file=dist/bundle.min.js
not sure if rollup repl uses terser ( or any kind of mangler ) ? I tried terser REPL and it tree-shakes as expected
@Hotell it's not and you're right, with Terser on top it works. However, Webpack and Rollup are able to handle imports scenario without invoking Terser.
I updated the issue to clarify it.
Blocked by microsoft/rushstack#2780
Not sure if it's a relevant issue, for me this looks closer to the problem https://github.com/microsoft/rushstack/issues/2842.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.
Still require assistance? Please, create a new issue with up-to date details.
Reopening as the Web Components have this issue still as well.
seems this fix landed in api-extractor - we need to bump to latest version ( after/with migration to particular typescript version ),
follows https://github.com/microsoft/fluentui/issues/31857
UPDATE:
- It landed in this version https://github.com/microsoft/rushstack/blob/main/apps/api-extractor/CHANGELOG.md#7470
- this will land in our repo with migration to TS 5.4.2 (https://unpkg.com/browse/@microsoft/[email protected]/package.json) cc @mainframev