question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typings: allow including only used components in app bundle

See original GitHub issue

When 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:closed
  • Created 7 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
levithomasoncommented, Dec 30, 2016

Option 2 it is, PRs welcome!

0reactions
layershiftercommented, Jan 10, 2017

Hm, as I see this was fixed in #1098. Closing for housekeeping.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found