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

scalable-react-boilerplate

v1.1.0

Published

A highly scalable React starter project

Downloads

9

Readme

Scalable Boilerplate Logo

Scalable React Boilerplate

npm version](https://badge.fury.io/js/scalable-react-boilerplate) Code Ship Codacy grade

The boilerplate aims to follow best practices for building highly scalable and reusable apps and component libraries with React and cutting edge JavaScript.

You can read more about the organizational strategy used in this app in this Medium post.

We incorporate an ESLint configuration and follow strictly the AirBnb JS & JSX style guides.

What is Feature First?

In most projects and frameworks, files are organized in a File type first fashion. For example, your tests exist in a test folder, your styles in a styles folder. This boilerplate takes a different approach.

We encourage encapsulation of features by asking that you organize each feature into a separate folder (feature-first). In React, this means that your containers and components exist in their own folders, along with literally every other file that pertains to that one component. Your actions, reducers, tests, styles, and everything else are all internal to the component they represent. By decoupling your features from the rest of your app, you set yourself up to reuse your UI components in future projects. You can thank us later!

This may be confusing at first, but we've set you up with a few examples and code generation tools. Give it a try! We promise you will enjoy it.

Example App

An example application built using this architecture us linked below.

Docker Support

Coming soon the app will support Docker, which will contain a configured web server to make deployment of this boilerplate simple! You can take a look at this branch for more details.

Documentation

Getting Started

To try the example application out or to use the project, follow the instructions below.

  1. Clone repo

    git clone https://github.com/RyanCCollins/scalable-react-boilerplate.git

  2. Install dependencies

    npm run setup

  3. Run development server

    npm run start

    Your app will be served at: http://0.0.0.0:1337/

Deployment

A demo ExpressJS setup is included with the app. The express server will serve up the production minified bundle.js, index.html and any other assets that are located in the /server/public folder.

Running npm run serve:bundle will set your environment to production and serve these files via Express. Also, a Procfile is included, which will run the Express server on Heroku when you push your code.

NOTE: the deployment script, npm run deploy, will place all your generated assets in the server/public folder, where they can be served in production.

File Structure

  • Some files left out for brevity. Please reference the files in the Scalable React Boilerplate project for an example of the file structure. The application will ultimately be in use in a production web application project and more info will be posted here when we have production level examples.
.
├── README.md
├── LICENSE
├── index.html
├── package.json
├── webpack.config.js
├── app/
|   ├── fonts
|   ├── images
|   ├── src
|   |   ├── components
|   |   |   ├── FeatureFirstComponent
|   |   |   |   ├── index.js
|   |   |   |   ├── index.module.scss
|   |   |   |   └── tests
|   |   |   |   |   └── index.test.js
|   |   |   ├── App.jsx
|   |   |   ├── Main.js
|   |   |   └── index.js
|   |   ├── containers
|   |   |   ├── FeatureFirstContainer
|   |   |   |   ├── tests
|   |   |   |   |   ├── actions.test.js
|   |   |   |   |   ├── index.test.js
|   |   |   |   |   └── reducer.test.js
|   |   |   |   ├── actions.js
|   |   |   |   ├── constants.js
|   |   |   |   ├── index.js
|   |   |   |   ├── index.module.scss
|   |   |   |   └── reducer
|   |   |   └── index.js
|   |   ├── pages
|   |   ├── store
|   |   ├── utils
|   |   └── index.js
|   └── styles
├── .eslintignore
├── .eslintrc
├── .gitattributes
└── .gitignore

Scripts

  • npm run setup

    • Installs the application's dependencies
  • npm run test

    • Runs unit tests
  • npm run test:watch

    • Watches for changes to run unit tests
  • npm run build

    • Bundles the application
  • npm run dev

    • Starts webpack development server
  • npm run lint

    • Runs the linter
  • npm run deploy

    • Creates the production ready files within the /server/public folder
  • npm run clean

    • Removes the bundled code and the production ready files
  • npm run serve:bundle

    • Serve production assets from the /server/public folder.

Generators

The boilerplate contains generators for easy project scaffolding. At the moment, the generator has the following scaffold generating commands built in:

  • Container npm run generate:container
    • Name: the name of the container, i.e. Awesome, which converts to: AwesomeContainer
    • Connected / Not connected ES6 Class containers (higher order)
    • SCSS Modules
    • Reducers, actions and constants
    • Tests for all of the above
    • README.md file that documents the container
  • Component npm run generate:component
    • Name: the name of the component, i.e. Button
    • Stateless functional components (recommended)
    • ES6 class components
    • SCSS modules
    • Tests for all of the above
    • README.md file that documents the component
  • Page npm run generate:page
    • Name: The name of the route, i.e. Home, which gets converted to HomePage
    • Route: the route that corresponds to the page

To run the generators with a list of options, run

npm run generate

Follow the on screen prompts to select the options you wish to use.

For convenience, you can bypass the initial selection and scaffold out containers, components and pages by running

npm run generate:<type_of_component>

where <type_of_component> is one of: component, container or page.

The generators use the same feature-first file organization as the rest of the project, encapsulating components within their own folder.

Gotchas

In order to get the import / export to work, the generator does some pattern matching of the comments in the files to place the new imports. Just don't delete the comments within the root level index.js file in each directory and things will work fine!

From app/src/container/index.js or app/src/component/index.js

// ... Other components here
import MyComponent from 'MyComponent';

export {
  // ... Other components here
  MyComponent
}

Configuring your own generators

For information on how to build your own generators with relative ease, please go to the Plop Microgenerator homepage for detailed instructions.

Testing

Included in the setup is a test suite that will run your tests in the browser using Karma. A number of testing utilities are included, including

  • Expect (Plus Expect-JSX)
  • Mocha
  • Chai (JSX and Immutable)
  • Enzyme
  • Karma (including multiple Karma plugins)

You can see examples for testing of React Components, Redux Action Creators and Reducers in the repository here. Please follow the convention of naming tests with a .test.js postfix, or else the test suite will not recognize your tests.

To run tests, you will run

npm run test

which will pick up any file with the .test.js postfix and run it through Karma / Mocha, printing a report to the commandline.

Technologies / Libraries

Timeline / TODOS

  • [x] Write README file
  • [x] Write component tests using Enzyme
  • [x] Implement a Rails like component generator
  • [x] Add README.md files to each component
  • [x] Add Grommet as an optional starter component library
  • [x] Add Webpack stats plugin
  • [x] Dogfood the project and iterate on suggestions
  • [x] Setup production server configuration
  • [ ] Add Jest as testing utility
  • [ ] Create Docker container & automation scripts
  • [ ] Write wiki / other documentation

Acknowledgements

Udacity Alumni Loves React

This boilerplate began its life as a fork of the React Redux Simple Starter project and was setup as a starter project for the Udacity Alumni Web application open-source project.

It was created by several of the members of the Udacity Alumni product infrastructure team, including:

Many thanks to the team behind React Boilerplate, especially @maxstbr for setting a standard for the level of quality we in the React community can all learn from. Many of the ideas used here were reverse engineered from the same project.