MoroccanOSS / react-stoon

react-stoon is a handy toolbox of reusable Components that allow you to reduce boilerplate by writing less js inside of your React Components.
MIT License
29 stars 10 forks source link

only Import components you need from react-stoon #2

Closed bigfanjs closed 6 years ago

bigfanjs commented 6 years ago

We know generalized imports blow bundle sizes and increase the script evaluation and compilation time. So, In this issue I am requesting a new feature which helps you specify only the components you need to import.

import Show from "react-stoon/Show";
import Repeat from "react-stoon/Repeat";

I think we still end up loading some useless code even with module bundlers like Webpack's best optimization tricks like taking down dead code using tree shaking before we load our code to the browser. But because most of EcmaScript latest features are now available natively in the some browsers. Some people may not even bother bundling up their code and directly start importing their modules.

<script type="module" src="./script.js"></script>

I thought I would issue this before I start working on it.

Amine-H commented 6 years ago

Hello, you are right, I'd like to comment on this, we could make each component in a separate module and load all of them into index.js

that way we could do either:

import { Show } from '@moroccan-oss/react-stoon';

and for who ever wants optimized builds:

import Show from '@moroccan-oss/react-stoon/Show';