-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Environment Information
- Package version(s):
"@fluentui/react-northstar": "0.48.0" - Browser and OS versions: All
Please provide a reproduction of the bug in a codepen:
Create a simple app with the following files:
index.tsx
import React from "react";
import ReactDOM from "react-dom";
import App from "./components/App";
ReactDOM.render(<App />, document.getElementById("root"));
components/App.tsx
import React from "react";
import { Provider, themes, Button } from '@fluentui/react-northstar';
const App = () => (
<Provider theme={themes.teams}>
<Button content="Hello from FluentUI" />
</Provider>
);
export default App;
Build it with webpack (or Parcel2) in production mode (which enables tree-shaking and minification), and you'll see a 1.3-1.4MB increase in bundle size over a simple Hello World react app that doesn't use @fluentui/react-northstar.
Here's a visualization of the minified, tree-shaken bundle from webpack, using source-map-explorer:
You can see a repro for the issue in the fluentui-button branch of this repository. Run yarn build:webpack (to see webpack bundle output), yarn build:parcel (to see parcel2 bundle output).
This is related to issue #2113, #2324, and #2324 on the legacy repo. Those are still marked as "open", and I don't see any issues or PRs addressing it in the new repo.
Actual behavior:
The bundle size increase of using a single button component is really, really big (1.3-1.4 MB). It looks like it's importing just about every component and icon into the bundle, even though the app uses no icons and only a single button component.
Expected behavior:
The bundle size increase should be "pay-to-play" - the more components/icons that I leverage, the more space it takes, and it should start small.
Priorities and help requested:
Are you willing to submit a PR to fix? Happy to help brainstorm but I don't think I have the time to fashion a full PR.
Requested priority: Medium (before a v1 release, would think it's important to get this under control).
