A hosted NPM registry allows us to store and share reusable chunks of code (components).
Developers will need to:
// Local development
npm login
// CI/CD pipeline
// Set NPM_TOKEN in the CI environment vars
dependencies:
pre:
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
npm installCOMPONENT USE IN PRACTICE
Easily pull in a breaking news banner for your application that:
import BreakingNews from '@cnnprivate/breaking-news';
import FetchData from 'modules/fetch-data';
import '!style-loader!css-loader!@cnnprivate/breaking-news/dist/main.css'
function BreakingNewsContainer({ uri, interval }) {
return (
<FetchData
uri={uri}
interval={interval}
>
{(error, data) => <BreakingNews {...data} />}
</FetchData>
);
}Consuming applications are responsible for state and data management. Components simply accept data as a "prop" and perform the necessary business logic under the hood.
We are working on better approaches for CSS support, theme-ability, and hooks (e.g. analytics / application state updates).