Typings: allow including only used components in app bundle
See original GitHub issueWhen I use
import Button from 'semantic-ui-react/elements/Button/Button'
instead of
import { Button } from 'semantic-ui-react';
I can save almost half of the project’s bundle.js file.
See example of Button and Accordion definition in https://github.com/PavelPZ/design/blob/master/index.d.ts. which allows this optimization.
APP Code:
import React from 'react';
import ReactDOM from 'react-dom';
//OPTIMIZED VARIANT, bundle contains only Button code
import Button from 'semantic-ui-react/elements/Button/Button';
import ButtonContent from 'semantic-ui-react/elements/Button/ButtonContent';
//STANDARD VARIANT, bundle contains all Semantic UI code
//import { Button, ButtonContent } from 'semantic-ui-react'; //STANDARD VARIANT
export const init = () => {
ReactDOM.render(<Button primary><ButtonContent>Button</ButtonContent></Button>, document.getElementById('content'));
};
Minified bundle size (containing APP Code, react.js, lodash.js and classnames.js):
OPTIMIZED VARIANT: 326kB STANDARD VARIANT: 592kB
Used JSPM package manager with Rollup Optimization.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Build and test your Android App Bundle
Android App Bundles are the recommended way to build, publish, and distribute your app across multiple device configurations.
Read more >Code-Splitting - React
Most React apps will have their files “bundled” using tools like Webpack, Rollup or Browserify. Bundling is the process of following imported files...
Read more >Sharing React Components across Multiple Applications
Sharing React components between multiple applications. Reuse components in your ReactJS projects to speed development and keep the design ...
Read more >Improving JavaScript Bundle Performance With Code-Splitting
Page components are neatly split into separate packages and are loaded on-demand as the user navigates between the pages.
Read more >Can't import CSS/SCSS modules. TypeScript says "Cannot ...
Just add the file typings.d.ts containing: declare module "*.module ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Option 2 it is, PRs welcome!
Hm, as I see this was fixed in #1098. Closing for housekeeping.