[General] - Using modules does not exclude unused components as expected
See original GitHub issueI guess something is wrong with the rollup.config.js
file. When doing:
import { Button } from 'react-md';
it looks like the full library is still being imported. The bundle size does not change even when more components are imported.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:16 (12 by maintainers)
Top Results From Across the Web
cannot determine the module for component angular 5
This is working when I build with Angular 4 and getting error with Angular 5. With Angular 5 "ng serve" is working perfectly....
Read more >Tree-shaking in real world: what could go wrong? - Medium
The general idea is that any unused code without side-effects (i.e. modifying external variables or global state, polyfilling and stuff like ...
Read more >Go Modules Reference - The Go Programming Language
Introduction. Modules are how Go manages dependencies. This document is a detailed reference manual for Go's module system. For an introduction to creating ......
Read more >API - esbuild
This API call is used by the command-line interface if no input files are provided and the --bundle flag is not present. In...
Read more >Angular Modules and NgModule - Complete Guide
This would happen in the case where the component is not used internally inside the module. Could we still import the component directly?...
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 Free
Top 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
yes @stickfigure. That trick with the
babel-plugin-transform-imports
and of course a good code splitting. In my case, in development my bundle size was ~8.5 MB due to source maps. Besides those large bundles I had some app modules inside them so every time I saved a file the bundle was compiled.ls -lh node_modules/react-md/es/react-md.js
gives me-rw-r--r-- 1 hisa staff 1.4M Dec 4 13:47 node_modules/react-md/es/react-md.js
I think the react-md build should be an index file that exports each of the components and not a bundle containing all the lib’s modules.
A library with tree-shaking working ok is
"react-router": "^3.2.0",
.results in a smaller bundle size than
With the tricks mentioned my vendor-base.js bundle is now 5.91MB … it is the largest in my output but it only contains vendor code so it doesn’t need to be updated each time a save a file in my app.
alas I can’t figure out how to get it to work with my own setup, but in case anyone else is using hisapy’s setup i put together a (i think) complete version of that switch statement: