komposable / komponent

An opinionated way of organizing front-end code in Ruby on Rails, based on components
http://komponent.io
MIT License
427 stars 31 forks source link

Add an javascript index file in component #80

Closed florentferry closed 6 years ago

florentferry commented 6 years ago

In order to use import 'button'; instead of import 'button/button';, we should add an index.js in component folder which only do import of button.js.

Spone commented 6 years ago

I'm not sure about this.

It allows for a cleaner import syntax, but we have to have an (nearly empty) index.js in each component. We already have about 4-5 files in most components, I think we have to make sure we don't add too much files.

Maybe we could name the JS file index.js instead of button.js (for a component is named button) instead? But then the issue is that we have a lot of files with the same name (index.js) and it's a mess when you have a lot of them opened in your editor.

florentferry commented 6 years ago

When using collection of components packaged into a npm module, its more concise to just import component with the name of the component instead of component_name/component_name. But we can delayed the feature, and discuss about it.

Spone commented 6 years ago

Yes, I understand the idea, but I think the drawback (adding an index.js file to each component) is bigger than the advantage (being able to import component_name instead of component_name).

Isn't there another way to achieve this?

florentferry commented 6 years ago

I am closing this issue, feel free to reopen to discuss more about usage of an index.js file instead of explicit naming.