-
Notifications
You must be signed in to change notification settings - Fork 8
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
Runtime dependency injection #12
Comments
What's your boundary of a "module" here? Is it a component or just CSS? If I was to rephrase, I'd suggest that you'd want to be able to export: import React from 'react'
import X from 'my-css-in-js-lib'
const Y = X.styledComponentsStyle
export default () => (
<Y className={X.classNameGenerated} />
) without needing to include all of I'm assuming you're exporting a React component here, if not then potentially wrapping up a module as a Web Component? |
I was thinking low level CSS, no opinions about component binding. The API might surface class names or inline style objects, but your package would bind it to a component, if at all. |
Can we avoid the need for runtime injection? If module exports styles in a standard format, runtime used by the user should be able to pick it up and render, no? Maybe I don't quite understand the use case @markdalgleish has in mind… |
What about nested dependencies? What if a module 4 levels deep wants to render some CSS? |
I just reread this issue. So the question is how can a UI lib be published with styles in ISTF format and be able to render them using a CSSinJS library chosen by the consumer. Without having opinions on the rendering process. |
That is a tough one. If we have only static CSS, that would mean library just has to accept classes hashes. In our case we already agreed we want to support dynamic capabilities of CSSinJS, which is the most important property of CSSinJS, it becomes much harder. Lets assume we are publishing a material-ui library built with SC. I assume we are able to convert CSS strings and replace them with ISTF inline, right where they are. Still it means that in order to render a button from this library I still need to bundle SC. It would be of course a SC version without CSS parser bundled, but still a quite heavy weight library. Thoughts @philpl ? |
I guess when someone is publishing to npm, should be carefully consider what to use, for e.g. if styled-components then no-parser version or something. Mb we need some minimal spec for API which can be relied upon when publishing to NPM. So that it can be easily replaced when needed. |
Through coupling of styles with components, SC and similar libs are harder to support in a universal way. |
As a module author, I want a standard CSS-in-JS format to allow me to provide my styles agnostic of whatever runtime or UI library the parent app is using.
As a module consumer, I want to be able to collect all the styles provided in my dependency tree and pass them to my runtime of choice.
IMO this is essential if we want to allow people to publish CSS-in-JS without punishing them for picking the wrong library.
Does this sound like a good idea? Do we have any thoughts on how best to achieve this?
The text was updated successfully, but these errors were encountered: