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.

Minimize the bundle size

See original GitHub issue

Hello.

I found out react-konva always imports whole konva package. It highly increases webpack bundle size. Is it possible to require only necessary sources?

Thank you.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
matthewoatescommented, Nov 28, 2016

Modules should be separated, and those individual modules should require only what they depend on. I’m doing some preliminary testing with this library and if it works well with my codebase I can take a stab at this.

4reactions
bini1988commented, Jun 25, 2018

To solve this I created the file custom-konva.js with content:

/**
 * In webpack config should be defined:
 *  alias: {
 *    "konva": path.resolve(ROOT, "./custom-konva.js"),
 *  },
 */
var Konva = require("./node_modules/konva/src/Core");

require("./node_modules/konva/src/Animation");
require("./node_modules/konva/src/Tween");
require("./node_modules/konva/src/DragAndDrop");

require("./node_modules/konva/src/shapes/Circle");
require("./node_modules/konva/src/shapes/Line");
require("./node_modules/konva/src/shapes/Path");
require("./node_modules/konva/src/shapes/Rect");
require("./node_modules/konva/src/shapes/Text");

module.exports = Konva;

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 ways to reduce webpack bundle size - Jakob Lind
3 ways to reduce webpack bundle size · Easy: Run webpack in production mode · Medium: use an analyzer tool such as webpack-bundle-analyzer...
Read more >
Possible ways to reduce your webpack bundle size - Medium
Here are some cool ways you can reduce your webpack bundle size: ... This will significantly reduce your bundle size. How do I...
Read more >
Minimizing bundle size - Material UI - MUI
Learn more about the tools you can leverage to reduce the bundle size. Bundle size matters. The bundle size of MUI is taken...
Read more >
Minimizing Webpack bundle size - Anvil
Learn how to minimize your Webpack bundle size by following these best practices, ensuring an optimal user experience.
Read more >
Reduce your React Applications Bundle Size by 75% with ...
One of the most impactful techniques to reduce the bundle size of a React application is compression. compression is a process in which...
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