Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(build): add rollup to bundle external deps #9

Merged
merged 1 commit into from
Aug 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"presets": [["es2015", {"modules": false}], "stage-2"],
"plugins": [
"transform-es2015-modules-umd",
],
"moduleId": "matchSorter",
"presets": ["stage-2"],
"env": {
"development": {
"presets": ["es2015"],
},
"rollup": {
"presets": [["es2015", {"modules": false}]],
},
"test": {
"plugins": [
"istanbul"
]
"presets": ["es2015"],
"plugins": ["istanbul"]
}
}
}
16 changes: 14 additions & 2 deletions package-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,20 @@ module.exports = {
},
},
build: {
description: 'delete the dist directory and run babel to build the files',
script: 'rimraf dist && babel --copy-files --out-dir dist --ignore *.test.js src',
description: 'delete the dist directory and run all builds',
default: 'rimraf dist && p-s -p build.main,build.umd,build.umd.min',
main: {
description: 'transpile all source with babel',
script: 'babel --copy-files --out-dir dist/cjs --ignore *.test.js src',
},
umd: {
description: 'run the build with rollup (uses rollup.config.js)',
script: 'cross-env rollup --config',
min: {
description: 'run the rollup build with sourcemaps',
script: 'cross-env MINIFY=true rollup --config --sourcemap',
},
},
},
lint: {
description: 'lint the entire project',
Expand Down
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "match-sorter",
"version": "0.0.0-semantically-released",
"description": "Simple, expected, and deterministic best-match sorting of an array in JavaScript",
"main": "dist/index.js",
"main": "dist/cjs/index.js",
"scripts": {
"start": "package-scripts",
"test": "package-scripts test"
Expand All @@ -16,24 +16,28 @@
"dependencies": {},
"devDependencies": {
"all-contributors-cli": "^3.0.0",
"ava": "^0.15.2",
"ava": "^0.16.0",
"babel-cli": "^6.7.7",
"babel-plugin-istanbul": "^1.0.3",
"babel-plugin-transform-es2015-modules-umd": "6.12.0",
"babel-plugin-istanbul": "2.0.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-stage-2": "^6.5.0",
"babel-register": "^6.7.2",
"codecov": "^1.0.1",
"commitizen": "^2.8.6",
"cross-env": "2.0.0",
"cross-env": "^2.0.0",
"cz-conventional-changelog": "^1.2.0",
"eslint": "^3.1.1",
"eslint-config-kentcdodds": "^10.0.1",
"ghooks": "^1.3.2",
"nyc": "^7.0.0",
"nyc": "8.1.0",
"opt-cli": "^1.4.2",
"p-s": "^2.3.0",
"rimraf": "^2.5.4",
"rollup": "0.34.10",
"rollup-plugin-babel": "2.6.1",
"rollup-plugin-commonjs": "3.3.1",
"rollup-plugin-node-resolve": "2.0.0",
"rollup-plugin-uglify": "1.0.1",
"semantic-release": "^4.3.5",
"validate-commit-msg": "^2.8.0"
},
Expand Down
22 changes: 22 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {rollup} from 'rollup' // eslint-disable-line
import rollupBabel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import nodeResolve from 'rollup-plugin-node-resolve'
import uglify from 'rollup-plugin-uglify'

process.env.BABEL_ENV = 'rollup' // so babel will be configured to not transpile modules
const filename = process.env.MINIFY ? 'match-sorter.min.js' : 'match-sorter.js'

export default {
entry: 'src/index.js',
dest: `dist/umd/${filename}`,
format: 'umd',
moduleName: 'matchSorter',
plugins: [
nodeResolve({jsnext: true, main: true}),
commonjs({include: 'node_modules/**'}),
rollupBabel({exclude: 'node_modules/**'}),
process.env.MINIFY ? uglify() : null,
].filter(i => !!i),
exports: 'named',
}