Skip to content

Commit

Permalink
Use rollup to create an UMD module build
Browse files Browse the repository at this point in the history
Closes #1
  • Loading branch information
raphinesse committed Apr 11, 2018
1 parent 144c71c commit 546de6e
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
.source.*
.nyc_output/
dist/
167 changes: 167 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
"description": "Fetch DB entries in batches to improve performance while respecting IPC size constraints",
"license": "MIT",
"author": "Raphael von der Grün",
"main": "dexie-batch.js",
"main": "dist/dexie-batch.js",
"module": "dist/dexie-batch.mjs",
"repository": "raphinesse/dexie-batch",
"scripts": {
"build": "rollup -c",
"format": "prettier --ignore-path .gitignore --write '**/*.js'",
"prepublishOnly": "npm run build",
"test": "xo && nyc ava"
},
"xo": {
Expand All @@ -20,11 +23,17 @@
"singleQuote": true,
"trailingComma": "es5"
},
"files": [
"dist"
],
"devDependencies": {
"ava": "^0.25.0",
"dexie": "^2.0.1",
"fake-indexeddb": "^2.0.3",
"nyc": "^11.6.0",
"rollup": "^0.57.1",
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-node-resolve": "^3.3.0",
"xo": "^0.20.3"
},
"peerDependencies": {
Expand Down
36 changes: 36 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'

const pkg = require('./package')

const banner = (_ => {
const id = `${pkg.name} v${pkg.version}`
const homepage = 'github.com/' + pkg.repository
const license = `${pkg.license} License`
return `/*! ${id} | ${homepage} | ${license} */`
})()

function outputConfig(config) {
const defaultConfig = {
sourcemap: true,
banner,
}
return Object.assign(defaultConfig, config)
}

export default {
input: 'dexie-batch.js',
output: [
// Browser-friendly UMD build
outputConfig({
file: pkg.main,
name: 'DexieBatch',
format: 'umd',
globals: { dexie: 'Dexie' },
}),
// ECMAScript module build
outputConfig({ file: pkg.module, format: 'es' }),
],
external: ['dexie'],
plugins: [resolve(), commonjs()],
}

0 comments on commit 546de6e

Please sign in to comment.