microsoft / fluentui

Fluent UI web represents a collection of utilities, React components, and web components for building web applications.
https://react.fluentui.dev
Other
18.51k stars 2.73k forks source link

API extractor prevents usage of re-exports 💥 #20694

Open layershifter opened 2 years ago

layershifter commented 2 years ago

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 *.

Rollup REPL.

Hotell commented 2 years ago

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

Hotell commented 2 years ago

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 commented 2 years ago

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

layershifter commented 2 years ago

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 commented 2 years ago

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.

msft-fluent-ui-bot commented 2 years ago

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 commented 1 year ago

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.

microsoft-github-policy-service[bot] commented 1 year ago

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.

microsoft-github-policy-service[bot] commented 1 year ago

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.

microsoft-github-policy-service[bot] commented 1 year ago

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.

microsoft-github-policy-service[bot] commented 1 year ago

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.

microsoft-github-policy-service[bot] commented 1 year ago

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.

microsoft-github-policy-service[bot] commented 1 year ago

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.

microsoft-github-policy-service[bot] commented 1 year ago

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.

microsoft-github-policy-service[bot] commented 1 year ago

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.

microsoft-github-policy-service[bot] commented 1 year ago

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.

microsoft-github-policy-service[bot] commented 1 year ago

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.

microsoft-github-policy-service[bot] commented 1 year ago

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.

microsoft-github-policy-service[bot] commented 1 year ago

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.

microsoft-github-policy-service[bot] commented 8 months ago

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.

chrisdholt commented 6 months ago

Reopening as the Web Components have this issue still as well.

Hotell commented 2 months ago

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: