Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

fairest
Full Stack JavaScript Techdegree Graduate 19,303 PointsWhy does a named import increase the Package size?
import React from 'react'; Package size = 8K import React, { Component } from 'react'; Package size = 8.1K
This feels counter intuitive.
3 Answers

Zimri Leijen
11,732 PointsIt seem to me like you import React completely, and in addition you import a module from react.
Try import { Component } from 'react';

fairest
Full Stack JavaScript Techdegree Graduate 19,303 Pointsimport { Component } from 'react';
Breaks the app. I don't see the advantage of using:
import React from 'react';
VS
import React, { Component } from 'react'
If it only saves you typing the React. part but increases your package size, it down't seem worth it.

James Crosslin
Full Stack JavaScript Techdegree Graduate 16,756 Pointstl;dr - development files aren't production files, and their size isn't reflective of the final product.
I think that this is a fundamental misunderstanding of your React dev environment vs your compiled final product. The create-react-app structure only has your dev files, and when it's time to move your product to production, you use
npm build
to compile those build files into a set of productions files. Those production files do not use all of those individual imports in your final build. Instead, the dev environment compiles your javascript, rendered html, and css, minifying and bundling them for you in the most efficient way possible (according to the environment's logic).