Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose injectStyleOnce #344

Open
majapw opened this issue Oct 3, 2018 · 2 comments
Open

Expose injectStyleOnce #344

majapw opened this issue Oct 3, 2018 · 2 comments

Comments

@majapw
Copy link
Contributor

majapw commented Oct 3, 2018

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!

@jlfwong
Copy link
Collaborator

jlfwong commented Oct 4, 2018

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.

@majapw
Copy link
Contributor Author

majapw commented Oct 22, 2018

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

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

No branches or pull requests

2 participants