GithubHelp home page GithubHelp logo

Individual imports about react-powerplug HOT 9 CLOSED

renatorib avatar renatorib commented on May 14, 2024
Individual imports

from react-powerplug.

Comments (9)

Andarist avatar Andarist commented on May 14, 2024 1

I can only confirm that generally speaking flat bundling (what rollup does) is better than having a directory structure - it allows for easier tree-shakeability webpack (upcoming webpack@4 might get better at this, but anyway many, many users still use webpack 2 or 3).

There is no reason to allow for package/submodule imports (also setting this up in proper way is quite difficult and there is no tool - that im aware of - at the moment which does it automatically). I see a room for package/flavour though (i.e. unistore/react, unistore/preact), but this library is a set of utilities and as such IMHO it should be accessible from a single entry point.

Having a proper tree-shaking tooling will make proposed import Hover from 'react-powerplug/Hover' and import { Hover } from 'react-powerplug equivalent - exact same code should land in your final bundle.

from react-powerplug.

renatorib avatar renatorib commented on May 14, 2024

Thanks again 😄

For now it's possible to import this way

import Hover from 'react-powerplug/lib/components/Hover'

To make import of react-powerplug/Hover possible, we will need to change the folder structure, OR add some config to rollup that I don't know, but we can search about.

from react-powerplug.

souporserious avatar souporserious commented on May 14, 2024

Oh awesome! That's wonderful 👏 I'll look into it and see if we can make them a litter easier to write, but this works great for now. Thanks for the quick reply!

from react-powerplug.

renatorib avatar renatorib commented on May 14, 2024

You're welcome!

I will leave this issue open, so anyone can help too.

from react-powerplug.

TrySound avatar TrySound commented on May 14, 2024

I would not rely on folder structure. It's bad pattern and tree shaking improvements in the last months can prevent us from it.

from react-powerplug.

renatorib avatar renatorib commented on May 14, 2024

You are right @TrySound.
Do you have some suggestions?

from react-powerplug.

TrySound avatar TrySound commented on May 14, 2024

I tried both rollup and webpack and they both treeshake good. The only side effect now is State component, but it's base component, it always will be if library is used.

from react-powerplug.

TrySound avatar TrySound commented on May 14, 2024

State treeshaking will be available after babel/babel#6963 merge

from react-powerplug.

renatorib avatar renatorib commented on May 14, 2024

Thanks for your explanation @Andarist!

I'll close this issue since v1 will not have a export default (#31), which will help with tree shaking.

from react-powerplug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.