threepointone/glamor

break up glamor (even more)

Closed this issue ยท 8 comments

The core glamor package can be split up into even more, smaller, useful parts.

The first I would like to split out is the murmur hash implementation in hash.js. I'm not sure why this wasn't proposed by the styled-components crew, but they're using it in vendored form right now so publishing it as it's own package is useful.

The other part I would like to split out is sheet.js. This is mostly for testing purposes as it is a single, contained unit and it would seem that this file is the only reason we need to use Karma/cross-browser testing. It is also seemingly useful on it's own as a unified stylesheet implementation.

Here's the checklist for what I want to accomplish.

  • split out hash.js into glamor-hash
    • write basic test
  • #243 -- split out sheet.js into glamor-stylesheet and move the tests.
    • Ensure that all stylesheet functions are well-tested.
    • isolate Karma use to glamor-stylesheet and move the rest of the tests to Jest, which IMO will improve the DX of repeatedly running glamor's test suites (which I do fairly often at this point).
  • depend on inline-style-prefixer instead of vendoring it. (cc/ @threepointone do you have opinions on this specifically?)

I'm also happy to move these packages to typescript as I split them out. Not sure if @donaldpipowitch has made any progress on that transition yet. I plan to do the above checklist as separate PRs to be easily reviewable, etc. There should be no functionality changes to glamor as a result of this work.

cc/ @donaldpipowitch @otbe

I'm also happy to move these packages to typescript as I split them out. Not sure if @donaldpipowitch has made any progress on that transition yet.

Sadly not. Feel free to start with that. I hoped I'd find time to do that to learn more of Glamors core, but I couldn't find spare time :(

Changes sound reasonable! LGTM.

I'd recommend not doing this. Don't want to maintain apis for sheet/hash/prefixer, and we might change those implementations/apis in the future.

@threepointone I hear you on the additional maintenance burden, but it seems like we have some core pieces of general CSS-in-JS infrastructure here. Changing the APIs in the future seems like a semver problem right? (or am I missing something).

The prefixer part was more to depend on either an npm package or have a build step that compiles the inline package with the desired browser settings instead of having it vendored as source code.

Any chances on at least allowing prefix options? I'm getting gnarly rule generation from using calc and flex together.

@souporserious you could whack out the plugins and add your own prefixer

import {plugins} from 'glamor'
plugins.clear()

closing this issue, nothing really actionable here, but will consider ideas for immediate future.

Interesting ๐Ÿค” didn't know I could do that. Just want to make sure I understand correct, would I just clear all plugins and then add my own plugin that did the prefixing?

Yes correct. You might want to include the fallbacks plugin, that's pretty useful, but feel free to use any prefixer, or any others you'd like.

That's great!!! Will do, thank you! ๐Ÿ™Œ