Coder Social home page Coder Social logo

universal-npm-starter's Introduction

universal-npm-starter

Build Status Libraries.io for GitHub Coverage Status NPM version NPM downloads MIT License

Sauce Test Status

Boilerplate for a NPM package for the node and browser

Introduction

Replace this with your package's details!

Starter Intro

This is a boilerplate npm module that can be used to create a universal JavaScript module for node and browser runtimes. It uses rollup to bundle ES2015 code.

The implementation in this boilerplate generates a module thats is distributed perfectly symmetrically, meaning the exact same code is bundled for and executed in node and the browser.

This toolchain can also generate an asymmetrical package with runtime-specific bundles. This involves a few steps:

  • modifying the the rollup config
  • updating package.json with a browser property
  • creating browser and node entry files
  • maintaining API contracts between all entry files

See we-js-logger for an example of an asymmetrical package.

Usage

Clone this repo and replace the code in the src/ and test/ directories with your module. Make it your own. PRs are always welcome :)

Testing

Tests are run via mocha in node, and via karma, webpack and mocha for browsers (PhantomJS by default, but Karma is quite configurable).

This package is also preconfigured for Travis and Sauce Labs. To enable this:

  1. Setup travis-ci for your repository
  2. Add SAUCE_USER_NAME and SAUCE_ACCESS_TOKEN keys to the travis job

Examples

This boilerplate was developed while creating a few modules at WeWork:

Development

  1. Checkout this repo
  2. Run yarn
  3. Make changes in a feature branch and open a PR to master

In lieu of a formal style guide, please:

  • follow the conventions present in the codebase
  • respect the linter
  • keep tests green
  • maintain test coverage

Installing an EditorConfig plugin is also nice.

npm scripts

Target Behavior
yarn test Runs tests in browser and node runtimes
yarn tdd Runs tests, bundles and re-runs on file changes
yarn test:coverage Runs tests and outputs a code coverage report to /coverage
yarn test:ci Runs tests, outputs code coverage
yarn lint (Run as a git pre-commit hook) Runs eslint
yarn docs Generates API.md from JSDoc comments in /src
yarn security-scan (Run as a git pre-push hook) Checks npm dependencies for security vulnerabilities
yarn release <version> Generates a changelog, updates package version, tags and pushes via np. This should only be run on an up-to-date master by a maintainer of this package.

Version can be a semver level: `patch

yarn run will list all npm scripts

universal-npm-starter's People

Contributors

greenkeeper[bot] avatar mattjstar avatar nason avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.