├── .eslintignore ├── src ├── examples │ ├── flow.js │ ├── jsx.jsx │ └── modern.js └── index.js ├── internals └── img │ ├── js.png │ ├── flow.png │ ├── jest.png │ ├── react.png │ ├── eslint.png │ ├── header.png │ └── rollup.png ├── jest.json ├── test └── examples │ ├── flow.test.js │ ├── jsx.test.js │ └── modern.test.js ├── renovate.json ├── .travis.yml ├── .gitignore ├── .eslintrc ├── .babelrc ├── .npmignore ├── .flowconfig ├── rollup.config.js ├── LICENSE ├── package.json └── README.md /.eslintignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/examples/flow.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | export default (a: number, b: number): number => (a + b); 4 | -------------------------------------------------------------------------------- /internals/img/js.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eunikitin/modern-package-boilerplate/HEAD/internals/img/js.png -------------------------------------------------------------------------------- /internals/img/flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eunikitin/modern-package-boilerplate/HEAD/internals/img/flow.png -------------------------------------------------------------------------------- /internals/img/jest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eunikitin/modern-package-boilerplate/HEAD/internals/img/jest.png -------------------------------------------------------------------------------- /internals/img/react.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eunikitin/modern-package-boilerplate/HEAD/internals/img/react.png -------------------------------------------------------------------------------- /internals/img/eslint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eunikitin/modern-package-boilerplate/HEAD/internals/img/eslint.png -------------------------------------------------------------------------------- /internals/img/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eunikitin/modern-package-boilerplate/HEAD/internals/img/header.png -------------------------------------------------------------------------------- /internals/img/rollup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eunikitin/modern-package-boilerplate/HEAD/internals/img/rollup.png -------------------------------------------------------------------------------- /src/examples/jsx.jsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | export default (props) => (
You know nothing, {props.name}
); 4 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import thankYou from 'examples/modern'; 2 | 3 | export const modern = thankYou; 4 | 5 | console.log(thankYou()); 6 | -------------------------------------------------------------------------------- /jest.json: -------------------------------------------------------------------------------- 1 | { 2 | "collectCoverage": true, 3 | "collectCoverageFrom": ["src/**"], 4 | "coverageReporters": ["json", "lcov", "text-summary", "html"] 5 | } -------------------------------------------------------------------------------- /test/examples/flow.test.js: -------------------------------------------------------------------------------- 1 | import flow from '../../src/examples/flow'; 2 | 3 | 4 | test('1 + 2 = 3', () => { 5 | expect(flow(1, 2)).toBe(3); 6 | }); 7 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ "config:base" ], 3 | "baseBranches": [ "dev" ], 4 | "automerge": true, 5 | "automergeType": "branch-push", 6 | "rebaseStalePrs": true, 7 | "recreateClosed": true 8 | } 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "lts/*" 4 | - "node" 5 | 6 | before_script: npm run lint 7 | script: npm run test 8 | after_success: npm run coveralls 9 | 10 | branches: 11 | only: 12 | - master -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IDE & OS specific 2 | .DS_Store 3 | .idea 4 | 5 | # Logs 6 | logs 7 | *.log 8 | 9 | # Dependencies 10 | node_modules 11 | 12 | # Coverage 13 | coverage 14 | 15 | # Types 16 | flow-typed/npm/* 17 | !flow-typed/npm/module_vx.x.x.js 18 | 19 | # Release 20 | lib 21 | 22 | 23 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "airbnb", 3 | "parser": "babel-eslint", 4 | 5 | "env": { 6 | "mocha": true 7 | }, 8 | 9 | "rules": { 10 | "linebreak-style": 0, 11 | "import/no-extraneous-dependencies": 0, 12 | "import/no-unresolved": 0, 13 | "import/prefer-default-export": 0, 14 | "import/extensions": 0, 15 | "no-multi-spaces": 0 16 | } 17 | } -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ "env", { "modules": false } ], 4 | "stage-0", 5 | "react", 6 | "flow" 7 | ], 8 | 9 | "env": { 10 | "test": { 11 | "presets": [ 12 | "env" 13 | ] 14 | } 15 | }, 16 | 17 | "plugins": [ 18 | ["module-resolver", { 19 | "root": ["./src"] 20 | }], 21 | "transform-runtime" 22 | ] 23 | } -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # IDE & OS specific 2 | .DS_Store 3 | .idea 4 | 5 | # Logs 6 | logs 7 | *.log 8 | 9 | # Dependencies 10 | node_modules 11 | 12 | # Coverage 13 | coverage 14 | 15 | # Types 16 | flow-typed/* 17 | 18 | # Sources, tests and builder files 19 | builder 20 | src 21 | test 22 | internals 23 | .flowconfig 24 | .babelrc 25 | .eslintignore 26 | .eslintrc 27 | .travis.yml 28 | jest.json 29 | renovate.json 30 | rollup.config.js -------------------------------------------------------------------------------- /test/examples/jsx.test.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import Enzyme, {shallow} from 'enzyme'; 3 | import Adapter from 'enzyme-adapter-react-16'; 4 | 5 | import jsx from '../../src/examples/jsx'; 6 | 7 | 8 | Enzyme.configure({ adapter: new Adapter() }); 9 | 10 | 11 | test('You know nothing, Jon Snow', () => { 12 | expect(shallow(jsx({ name: 'Jon Snow' })).html()).toEqual('
You know nothing, Jon Snow
'); 13 | }); 14 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | /node_modules/* 3 | /lib/.* 4 | /internals/.* 5 | /test/.* 6 | 7 | [include] 8 | 9 | [options] 10 | module.system.node.resolve_dirname=./src 11 | esproposal.class_static_fields=enable 12 | esproposal.class_instance_fields=enable 13 | esproposal.export_star_as=enable 14 | esproposal.decorators=ignore 15 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe 16 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue -------------------------------------------------------------------------------- /src/examples/modern.js: -------------------------------------------------------------------------------- 1 | 2 | export default () => ( 3 | '\n' + 4 | ' \x1b[42m\x1b[30m \n\x1b[0m' + 5 | ' \x1b[42m\x1b[30m Thank you for using this boilerplate! \n\x1b[0m' + 6 | ' \x1b[42m\x1b[30m \n\x1b[0m' + 7 | '\n' + 8 | ' Getting started\n\n' + 9 | ' 1. Clone the repo from github (https://github.com/eunikitin/modern-package-boilerplate.git)\n' + 10 | ' 2. Inside the repo directory run npm install && rm -r .git && git init\n' + 11 | ' 3. Update package.json with your information' + 12 | '\n' 13 | ); 14 | -------------------------------------------------------------------------------- /test/examples/modern.test.js: -------------------------------------------------------------------------------- 1 | import modern from '../../src/examples/modern'; 2 | 3 | const message = 4 | '\n' + 5 | ' \x1b[42m\x1b[30m \n\x1b[0m' + 6 | ' \x1b[42m\x1b[30m Thank you for using this boilerplate! \n\x1b[0m' + 7 | ' \x1b[42m\x1b[30m \n\x1b[0m' + 8 | '\n' + 9 | ' Getting started\n\n' + 10 | ' 1. Clone the repo from github (https://github.com/eunikitin/modern-package-boilerplate.git)\n' + 11 | ' 2. Inside the repo directory run npm install && rm -r .git && git init\n' + 12 | ' 3. Update package.json with your information' + 13 | '\n'; 14 | 15 | test('Message on package usage', () => { 16 | expect(modern()).toBe(message); 17 | }); 18 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import nodeResolve from 'rollup-plugin-node-resolve'; 2 | import babel from 'rollup-plugin-babel'; 3 | import replace from 'rollup-plugin-replace'; 4 | import commonjs from 'rollup-plugin-commonjs'; 5 | import uglify from 'rollup-plugin-uglify'; 6 | 7 | const env = process.env.NODE_ENV; 8 | 9 | const config = { 10 | input: 'src/index.js', 11 | external: ['react', 'react-dom'], 12 | output: { 13 | format: 'umd', 14 | name: 'npmPackageES6Boilerplate', 15 | }, 16 | 17 | plugins: [ 18 | nodeResolve(), 19 | babel({ 20 | exclude: '**/node_modules/**', 21 | runtimeHelpers: true, 22 | }), 23 | replace({ 24 | 'process.env.NODE_ENV': JSON.stringify(env), 25 | }), 26 | commonjs(), 27 | ], 28 | }; 29 | 30 | if (env === 'production') { 31 | config.plugins.push( 32 | uglify({ 33 | compress: { 34 | pure_getters: true, 35 | unsafe: true, 36 | unsafe_comps: true, 37 | warnings: false, 38 | }, 39 | }), 40 | ); 41 | } 42 | 43 | export default config; 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 - 2018 Eugene Nikitin 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "modern-package-boilerplate", 3 | "version": "2.3.4", 4 | "description": "Powerfull, flexible and easy-to-use boilerplate for creating modern npm packages. Features: rollup, babel, react (optional), flow (optional), jest, enzyme, eslint, travis-ci, coveralls, renovate", 5 | "keywords": [ 6 | "npm-package", 7 | "package", 8 | "npm", 9 | "boilerplate", 10 | "rollup", 11 | "babel", 12 | "react", 13 | "flow", 14 | "jest", 15 | "enzyme", 16 | "eslint", 17 | "travis", 18 | "travis-ci", 19 | "coveralls", 20 | "renovate" 21 | ], 22 | "license": "MIT", 23 | "author": "Eugene Nikitin", 24 | "homepage": "http://github.com/eunikitin/modern-package-boilerplate.git", 25 | "repository": { 26 | "type": "git", 27 | "url": "http://github.com/eunikitin/modern-package-boilerplate.git" 28 | }, 29 | "bugs": { 30 | "mail": "eu.nikitin@gmail.com", 31 | "url": "http://github.com/eunikitin/modern-package-boilerplate/issues" 32 | }, 33 | "main": "lib/index.js", 34 | "scripts": { 35 | "clean": "rimraf ./coverage ./lib", 36 | "dev": "cross-env NODE_ENV=development rollup -c -o lib/index.js", 37 | "build": "cross-env NODE_ENV=production rollup -c -o lib/index.js", 38 | "test": "cross-env NODE_ENV=test jest", 39 | "test:watch": "cross-env NODE_ENV=test jest --watch", 40 | "test:cover": "cross-env NODE_ENV=test jest --coverage", 41 | "coveralls": "npm run test:cover && cat ./coverage/lcov.info | coveralls", 42 | "flow": "flow", 43 | "flow-typed": "npm run clean && flow-typed install --overwrite || true", 44 | "lint": "eslint src", 45 | "prepublish": "npm run clean && npm run test && npm run flow && npm run lint && npm run build" 46 | }, 47 | "peerDependencies": { 48 | "react": "^15 || ^16", 49 | "react-dom": "^15 || ^16" 50 | }, 51 | "dependencies": { 52 | "babel-runtime": "^6.26.0" 53 | }, 54 | "devDependencies": { 55 | "babel-core": "6.26.0", 56 | "babel-eslint": "8.2.3", 57 | "babel-plugin-module-resolver": "3.1.1", 58 | "babel-plugin-transform-runtime": "^6.23.0", 59 | "babel-preset-env": "1.6.1", 60 | "babel-preset-flow": "6.23.0", 61 | "babel-preset-react": "6.24.1", 62 | "babel-preset-stage-0": "6.24.1", 63 | "coveralls": "3.0.0", 64 | "cross-env": "5.1.4", 65 | "enzyme": "3.3.0", 66 | "enzyme-adapter-react-16": "1.1.1", 67 | "eslint": "4.19.1", 68 | "eslint-config-airbnb": "16.1.0", 69 | "eslint-plugin-import": "2.11.0", 70 | "eslint-plugin-jsx-a11y": "6.0.3", 71 | "eslint-plugin-react": "7.7.0", 72 | "flow-bin": "0.70.0", 73 | "flow-typed": "2.4.0", 74 | "fs-file-tree": "1.0.6", 75 | "jest": "22.4.3", 76 | "react": "16.3.2", 77 | "react-dom": "16.3.2", 78 | "rimraf": "2.6.2", 79 | "rollup": "0.58.1", 80 | "rollup-plugin-babel": "3.0.3", 81 | "rollup-plugin-commonjs": "9.1.0", 82 | "rollup-plugin-node-resolve": "3.3.0", 83 | "rollup-plugin-replace": "2.0.0", 84 | "rollup-plugin-uglify": "3.0.0" 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Header 3 |

4 | 5 |

6 | Powerful, flexible and easy-to-use boilerplate for creating modern npm packages 7 |

8 | 9 |

10 | 11 | Babel 12 | 13 | 14 | Rollup 15 | 16 | 17 | React 18 | 19 | 20 | FlowJS 21 | 22 | 23 | Jest 24 | 25 | 26 | ESLint 27 | 28 |

29 | 30 |

31 | 32 | Build Status 33 | 34 | 35 | Coverage Status 36 | 37 | 38 | dependencies Status 39 | 40 | 41 | devDependencies Status 42 | 43 | 44 | peerDependencies Status 45 | 46 |

47 | 48 | # Features 49 | ## Key features 50 | * Bundle your library with [Rollup](https://github.com/rollup/rollup) 51 | * Write modern JavaScript with latest features of [Babel](https://babeljs.io/) 52 | * Create your own distributable [React](https://reactjs.org/) components (optional) 53 | * Check your types with [Flow](https://flow.org/) (optional) 54 | * Test and cover with [Jest](https://facebook.github.io/jest/) and [Enzyme](http://airbnb.io/enzyme/) 55 | * Lint with [ESLint](http://eslint.org/) ([air-bnb config](https://github.com/airbnb/javascript)) 56 | 57 | 58 | ## Minor features 59 | * Path aliases with babel [module-resolver](https://www.npmjs.com/package/babel-plugin-module-resolver) plugin 60 | * CI with [travis-ci.org](https://travis-ci.org/) 61 | * Coverage info with [coveralls.io](https://coveralls.io) 62 | * Track and update your dependencies with [renovateapp.com](https://renovateapp.com/) 63 | 64 | # Getting started 65 | 1. [Clone this repo from github](https://github.com/eunikitin/modern-package-boilerplate) 66 | 2. Inside the repo directory run `npm install && rm -r .git && git init` 67 | 2. Update package.json with your information 68 | --------------------------------------------------------------------------------