fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

API extractor prevents usage of re-exports 💥

Open layershifter opened this issue 4 years ago • 22 comments

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

Rollup REPL.

layershifter avatar Nov 22 '21 09:11 layershifter

Blocked by https://github.com/microsoft/rushstack/issues/2780

Hotell avatar Nov 22 '21 14:11 Hotell

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/ -> 2021-11-22 at 15 37

Hotell avatar Nov 22 '21 14:11 Hotell

here is actual repro https://stackblitz.com/edit/rollup-tree-shaking-with-export-as-namespace?devtoolsheight=33&file=dist/bundle.min.js

Hotell avatar Nov 22 '21 14:11 Hotell

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.

layershifter avatar Nov 22 '21 15:11 layershifter

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.

layershifter avatar Nov 22 '21 16:11 layershifter

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.

msft-fluent-ui-bot avatar May 21 '22 19:05 msft-fluent-ui-bot

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.

msft-fluent-ui-bot avatar Nov 19 '22 10:11 msft-fluent-ui-bot

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.

chrisdholt avatar Apr 24 '24 18:04 chrisdholt

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

Hotell avatar Aug 13 '24 15:08 Hotell