Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request: accommodate file imports #6

Open
preflight opened this issue Jun 18, 2016 · 1 comment
Open

request: accommodate file imports #6

preflight opened this issue Jun 18, 2016 · 1 comment

Comments

@preflight
Copy link

preflight commented Jun 18, 2016

I found that by targeting specific Stonecutter source files in my imports, I saved around 220 KB in my (webpack) bundle -- a little more than 80% (pre-minified) compared to importing without direct paths. Everything still functions perfectly:

// before
import { CSSGrid, layout, easings } from 'react-stonecutter';

// after
import CSSGrid from 'react-stonecutter/src/components/CSSGrid';
import simple from 'react-stonecutter/src/layouts/simple';
import { expoOut } from 'react-stonecutter/src/utils/easings';

To do this, though, I had to reconfigure webpack for .jsx files, add the /src path for compilation, and enable a few Babel loaders that I wasn't already using.

It would be great if the /lib directory could also include compiled versions of the modules in /src. You can see an example of this in the Redux source; see /src/applyMiddleware.js compared to /lib/applyMiddleware.js.

I would contribute this myself but am unfamiliar with the Gulp/Weback build config you're using. Otherwise I'm happy to pitch in where possible if you think this is worthwhile.

@dantrain
Copy link
Owner

Hi, thanks for finding these savings! I'll take a look at how Redux approaches this as you suggest and see what I can do.

I'm looking forward to tree-shaking in Webpack 2, should make things less fiddly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants