Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Allow importing built-in glamorous components #123

Closed
souporserious opened this issue May 23, 2017 · 2 comments · Fixed by #131
Closed

Allow importing built-in glamorous components #123

souporserious opened this issue May 23, 2017 · 2 comments · Fixed by #131

Comments

@souporserious
Copy link

I think it would be awesome to allow something like import { Div, Span } from 'glamorous'. It's not a huge deal to just pull it off below, but I get questions about this and was wondering if there is a possible solution.

It seems that we will need some type of pre-build or babel-transform to accomplish this, I'm not really familiar in this area, but I'm willing to help out wherever I might be able to.

@kentcdodds
Copy link
Contributor

Thanks for the issue @souporserious!
Yep, I think a pre-build is the best way to do this. I'm thinking that we could just insert it at the bottom of the glamorous.es.js file because only tree-shaking-capable tools should pick that one up and those things will get tree-shaken so we don't need to worry about adding a bunch of extra bloat to the final bundle which is great.

So my thought is it'll be something like:

export const Div = glamorous.Div
export const Span = glamorous.Span
// ... etc

To make this work, we could just add a && node other/concat-exports.js where we'd read in the list of DOM elements from dom-elements.js and generate the string.

Should hopefully be fairly straightforward. Anyone wanna work on this?

@marzelin
Copy link
Collaborator

@kentcdodds I'm on it.

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

Successfully merging a pull request may close this issue.

3 participants