Expose `injectStyleOnce`
majapw opened this issue · 2 comments
I have a need to inject some global CSS at the root separate from the component-based pipeline. Right now, I'm duplicating a lot of the code in injectStyleOnce
(https://www.github.com/Khan/aphrodite/blob/master/src/inject.js#L181-197), but it'd be nice to support this usecase out of the box and export the function with the built package, a la flushToStyleTag
.
See https://github.com/Khan/aphrodite/blob/master/dist/aphrodite.umd.js#L2072-L2079 for the current exports.
Thanks!
I'm no longer a maintainer of this codebase, so please don't take my opinion with too much weight.
I have a strong belief that keeping a minimum API surface area is valuable because of the ability it affords library authors to change implementation details. So if I were still a maintainer of this codebase, I'd be hesitant to increase the API surface by exposing an implementation detail for other use.
An alternative strategy for doing this kind of thing that imposes a different kind of burden would be to create a library which exposes this, have aphrodite depend upon it, and have your project depend upon the inject-style
package (or whatever it was called). That would allow aphrodite to switch away from this strategy without breaking API compatibility.
I think a minimal API surface area makes sense, but I think that it also may make sense to expose injectStyleOnce as part of that. If I am using Aphrodite, chances are likely that any global styles I want to introduce should use the Aphrodite styling interface (inject into the data-aphrodite
blob for instance) and to accomplish this while supporting server-rendering and creating the tag if it's not there and so forth requires a ton of code duplication of Aphrodite's internals. I think it would make sense to expose this method for this usecase (but I'm open to other suggestions).
to: @lencioni