npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

page-creator-components

v1.8.1

Published

Boilerplate for publishing modern React modules with Rollup

Downloads

2

Readme

page-creator-components

Boilerplate for publishing modern React modules with Rollup and example usage via create-react-app.

NPM JavaScript Style Guide

Intro

Note: Modern means modern as of November, 2017.. I'm sure everything will change in a month... :joy: :joy:

Introductory blog post.

The purpose of this boilerplate is to make publishing your own React components as simple as possible.

Features

There are some existing React library boilerplates, but none of them fulfilled the following goals which we set out to accomplish:

  • Support all modern JS language features for component development out of the box
  • Build process to convert source to umd and es module formats for publishing to npm
  • Comes with an example app using a standard create-react-app, serving 2 purposes
    • Local, hot-reload server for developing your module
    • Easily publishable to github pages so users can quickly play with your module (or surge.sh or now.sh)
  • Use Rollup for build process and Babel for transpilation
    • See the blog post for an explanation of Rollup vs Webpack
  • Allow the use of npm modules within your library, either as dependencies or peer-dependencies
  • Support importing CSS in your components (with css modules enabled by default)
    • Note that CSS support will be a noop if you're using css-in-js
  • Testing with Jest, using react-scripts from create-react-app
  • Thorough documentation written by someone who cares :heart_eyes:

Walkthrough

Check out the accompanying blog post which gives more in-depth explanations on how to create an example component using this boilerplate.

On this page, we'll give a quick rundown of the essential steps.

Getting Started

The first step is to clone this repo and rename / replace all boilerplate names to match your custom module. In this example, we'll be creating a module named react-poop-emoji.

# clone and rename base boilerplate repo
git clone https://github.com/transitive-bullshit/page-creator-components.git
mv page-creator-components react-poop-emoji
cd react-poop-emoji
rm -rf .git
# replace boilerplate placeholders with your module-specific values
# NOTE: feel free to use your favorite find & replace method instead of sed
mv README.template.md README.md
sed -i 's/page-creator-components/react-poop-emoji/g' *.{json,md} src/*.js example/*.json example/src/*.js example/public/*.{html,json}
sed -i 's/transitive-bullshit/your-github-username/g' package.json example/package.json

Local Development

Now you're ready to run a local version of rollup that will watch your src/ component and automatically recompile it into dist/ whenever you make changes.

# run example to start developing your new component against
npm link # the link commands are important for local development
npm install # disregard any warnings about missing peer dependencies
npm start # runs rollup with watch flag

We'll also be running our example/ create-react-app that's linked to the local version of your react-poop-emoji module.

# (in another tab)
cd example
npm link react-poop-emoji
npm install
npm start # runs create-react-app dev server

Now, anytime you make a change to your component in src/ or to the example app's example/src, create-react-app will live-reload your local dev server so you can iterate on your component in real-time.

NPM Stuffs

The only difference when publishing your component to npm is to make sure you add any npm modules you want as peer dependencies to the external array in rollup.config.js. Then publish as per usual.

# note this will build `commonjs` and `es`versions of your module to dist/
npm publish

Github Pages

Deploying the example to github pages is simple. We create a production build of our example create-react-app that showcases your library and then run gh-pages to deploy the resulting bundle. This can be done as follows:

npm run deploy

Note that it's important for your example/package.json to have the correct homepage property set, as create-react-app uses this value as a prefix for resolving static asset URLs.

Example Module

Here is an example react module created from this guide: react-background-slideshow, a sexy tiled background slideshow for React. It comes with an example create-react-app hosted on github pages and should give you a good idea of the type of module you’ll be able to create starting from this boilerplate.

License

MIT © Travis Fischer