Skip to content

Commit

Permalink
Add UMD bundles (#1178)
Browse files Browse the repository at this point in the history
They are useful to use in browser and at least now we may see how big
this lib is.
  • Loading branch information
TrySound authored and jquense committed Jan 16, 2019
1 parent dcc6ae6 commit 16bc190
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 5 deletions.
9 changes: 8 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"presets": ["jason"]
"presets": ["jason"],
"env": {
"esm": {
"presets": [
["jason", { "modules": false }]
]
}
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
lib/
dist/

# Logs
logs
Expand Down Expand Up @@ -32,4 +33,4 @@ node_modules
.idea

# Mac OS X
.DS_Store
.DS_Store
12 changes: 12 additions & 0 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"./dist/react-big-calendar.js": {
"bundled": 470107,
"minified": 152579,
"gzipped": 42233
},
"./dist/react-big-calendar.min.js": {
"bundled": 439313,
"minified": 142681,
"gzipped": 39554
}
}
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"style": "lib/css/react-big-calendar.css",
"files": [
"lib/",
"dist/",
"LICENSE",
"README.md",
"CHANGELOG.md"
Expand All @@ -29,7 +30,9 @@
"less-dnd": "npm run l src/addons/dragAndDrop/styles.less ./lib/addons/dragAndDrop/styles.css",
"assets": "cpy src/less/* lib/less && npm run assets-addons",
"assets-addons": "cpy addons/**/*.less ../lib/ --cwd=src --parents",
"build": "npm run clean && babel src --out-dir lib && npm run assets && npm run less",
"build:umd": "BABEL_ENV=esm yarn rollup -c",
"build:cjs": "babel src --out-dir lib",
"build": "yarn clean && yarn build:cjs && yarn build:umd && yarn assets && yarn less",
"build:examples": "npm run clean:examples && webpack --config examples/webpack.config.js",
"examples": "npm run clean:examples && webpack-dev-server --config examples/webpack.config.js --mode development",
"lint": "eslint src test",
Expand Down Expand Up @@ -97,6 +100,13 @@
"react-dom": "^16.6.1",
"react-tackle-box": "^2.1.0",
"rimraf": "^2.4.2",
"rollup": "^1.1.0",
"rollup-plugin-babel": "^4.3.0",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-size-snapshot": "^0.8.0",
"rollup-plugin-terser": "^4.0.2",
"webpack": "^4.25.1",
"webpack-atoms": "^8.0.0",
"webpack-cli": "^3.1.2",
Expand Down
61 changes: 61 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import nodeResolve from 'rollup-plugin-node-resolve'
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import replace from 'rollup-plugin-replace'
import { sizeSnapshot } from 'rollup-plugin-size-snapshot'
import { terser } from 'rollup-plugin-terser'

const input = './src/index.js'
const name = 'ReactBigCalendar'
const globals = {
react: 'React',
'react-dom': 'ReactDOM',
}

const babelOptions = {
exclude: /node_modules/,
runtimeHelpers: true,
}

const commonjsOptions = {
include: /node_modules/,
}

export default [
{
input,
output: {
file: './dist/react-big-calendar.js',
format: 'umd',
name,
globals,
},
external: Object.keys(globals),
plugins: [
nodeResolve(),
babel(babelOptions),
commonjs(commonjsOptions),
replace({ 'process.env.NODE_ENV': JSON.stringify('development') }),
sizeSnapshot(),
],
},

{
input,
output: {
file: './dist/react-big-calendar.min.js',
format: 'umd',
name,
globals,
},
external: Object.keys(globals),
plugins: [
nodeResolve(),
babel(babelOptions),
commonjs(commonjsOptions),
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }),
sizeSnapshot(),
terser(),
],
},
]
Loading

0 comments on commit 16bc190

Please sign in to comment.