You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 16, 2021. It is now read-only.
function AmpComponent() {
return <div className="amp-component"/>;
}
Is there a safe/universal/always-just-works/no-weird-dependencies way to distribute a npm package with the component.js that automatically installs the components.css stylesheet in the target document when AmpComponent is used?
Things to consider:
Client-side vs server-side rendering.
Lazy loading, tree shaking and bundling (e.g. what if AmpComponent is not used until later?)
Stylesheet ordering. The desire is to put this stylesheet as early as possible (before user stylesheet) to allow easy override in the user stylesheet.
Shadow vs light DOM. E.g. what if a component is used inside the shadow subtree?
Let's assume the most naive code setup with two modules:
/1/ component.css
/2/ component.js
Is there a safe/universal/always-just-works/no-weird-dependencies way to distribute a npm package with the
component.jsthat automatically installs thecomponents.cssstylesheet in the target document whenAmpComponentis used?Things to consider:
AmpComponentis not used until later?)