Skip to content

Combine UMD configs with rollup multiconfig and add size snapshot #678

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

Closed
wants to merge 4 commits into from
Closed
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
7 changes: 7 additions & 0 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"lib/daypicker.js": {
"bundled": 63454,
"minified": 28661,
"gzipped": 7798
}
}
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
"test": "jest",
"check": "npm run lint && npm run dtslint && npm run test",
"prerelease": "npm run check && npm run build",
"build": "rimraf lib && npm run build:node && npm run build:production && npm run build:development",
"build": "rimraf lib && npm run build:node && npm run build:umd",
"build:node": "cross-env NODE_ENV=cjs babel ./src -d ./lib/src --source-maps && npm run build:css",
"build:development": "cross-env NODE_ENV=development rollup -c",
"build:production": "cross-env NODE_ENV=production rollup -c",
"build:umd": "rollup -c",
"build:css": "postcss src/style.css --use autoprefixer -d lib/ --no-map"
},
"repository": {
Expand Down Expand Up @@ -94,7 +93,7 @@
"rimraf": "2.6.2",
"rollup": "^0.56.2",
"rollup-plugin-babel": "^3.0.3",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-size-snapshot": "^0.2.1",
"rollup-plugin-uglify": "^3.0.0",
"typescript": "2.7.2"
},
Expand Down
69 changes: 44 additions & 25 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,50 @@
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import uglify from 'rollup-plugin-uglify';
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';

const isProduction = process.env.NODE_ENV === 'production';
const input = './src/index.js';

export default {
input: './src/index.js',
output: {
file: `lib/daypicker${isProduction ? '.min' : ''}.js`,
sourcemap: true,
format: 'umd',
name: 'DayPicker',
globals: {
react: 'React',
},
},
external: ['react'],
const getBabelOptions = () => ({
plugins: [
babel({
plugins: [
'external-helpers',
['transform-react-remove-prop-types', { removeImport: true }],
],
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
isProduction ? uglify() : {},
'external-helpers',
['transform-react-remove-prop-types', { removeImport: true }],
],
};
});

export default [
{
input,
output: {
file: 'lib/daypicker.js',
sourcemap: true,
format: 'umd',
name: 'DayPicker',
globals: {
react: 'React',
},
},
external: ['react'],
plugins: [
babel(getBabelOptions()),
sizeSnapshot(),
],
},

{
input,
output: {
file: 'lib/daypicker.min.js',
sourcemap: true,
format: 'umd',
name: 'DayPicker',
globals: {
react: 'React',
},
},
external: ['react'],
plugins: [
babel(getBabelOptions()),
uglify(),
],
},
];
68 changes: 40 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,10 @@ builtin-modules@^1.0.0, builtin-modules@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"

bytes@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048"

cache-base@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2"
Expand Down Expand Up @@ -1307,7 +1311,7 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0:
escape-string-regexp "^1.0.5"
supports-color "^4.0.0"

chalk@^2.3.1:
chalk@^2.3.1, chalk@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65"
dependencies:
Expand Down Expand Up @@ -1469,6 +1473,10 @@ commander@~2.13.0:
version "2.13.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c"

commander@~2.14.1:
version "2.14.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa"

component-emitter@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6"
Expand Down Expand Up @@ -1779,6 +1787,10 @@ [email protected]:
tslint "^5.4.2"
typescript next

duplexer@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"

ecc-jsbn@~0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
Expand Down Expand Up @@ -2078,10 +2090,6 @@ estree-walker@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.2.1.tgz#bdafe8095383d8414d5dc2ecf4c9173b6db9412e"

estree-walker@^0.3.0:
version "0.3.1"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.3.1.tgz#e6b1a51cf7292524e7237c312e5fe6660c1ce1aa"

esutils@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b"
Expand Down Expand Up @@ -2195,6 +2203,10 @@ fast-deep-equal@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff"

fast-deep-equal@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614"

fast-diff@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154"
Expand Down Expand Up @@ -2540,6 +2552,13 @@ growly@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"

gzip-size@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-4.1.0.tgz#8ae096257eabe7d69c45be2b67c448124ffb517c"
dependencies:
duplexer "^0.1.1"
pify "^3.0.0"

handlebars@^4.0.3:
version "4.0.10"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f"
Expand Down Expand Up @@ -3690,12 +3709,6 @@ lru-cache@^4.0.1:
pseudomap "^1.0.2"
yallist "^2.1.2"

magic-string@^0.22.4:
version "0.22.4"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.22.4.tgz#31039b4e40366395618c1d6cf8193c53917475ff"
dependencies:
vlq "^0.2.1"

[email protected]:
version "1.0.11"
resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.11.tgz#e01a5c9109f2af79660e4e8b9587790184f5a96c"
Expand Down Expand Up @@ -4770,13 +4783,16 @@ rollup-plugin-babel@^3.0.3:
dependencies:
rollup-pluginutils "^1.5.0"

rollup-plugin-replace@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-replace/-/rollup-plugin-replace-2.0.0.tgz#19074089c8ed57184b8cc64e967a03d095119277"
rollup-plugin-size-snapshot@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-size-snapshot/-/rollup-plugin-size-snapshot-0.2.1.tgz#f4d95ec11b6b6a291eeb93c87023ed4955942f9c"
dependencies:
magic-string "^0.22.4"
minimatch "^3.0.2"
rollup-pluginutils "^2.0.1"
bytes "^3.0.0"
chalk "^2.3.2"
fast-deep-equal "^1.1.0"
gzip-size "^4.1.0"
jest-diff "^22.4.0"
uglify-es "^3.3.9"

rollup-plugin-uglify@^3.0.0:
version "3.0.0"
Expand All @@ -4791,13 +4807,6 @@ rollup-pluginutils@^1.5.0:
estree-walker "^0.2.1"
minimatch "^3.0.2"

rollup-pluginutils@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.0.1.tgz#7ec95b3573f6543a46a6461bd9a7c544525d0fc0"
dependencies:
estree-walker "^0.3.0"
micromatch "^2.3.11"

rollup@^0.56.2:
version "0.56.5"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.56.5.tgz#40fe3cf0cd1659d469baad11f4d5b6336c14ce84"
Expand Down Expand Up @@ -5340,6 +5349,13 @@ uglify-es@^3.3.7:
commander "~2.13.0"
source-map "~0.6.1"

uglify-es@^3.3.9:
version "3.3.10"
resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.10.tgz#8b0b7992cebe20edc26de1bf325cef797b8f3fa5"
dependencies:
commander "~2.14.1"
source-map "~0.6.1"

uglify-js@^2.6:
version "2.8.29"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd"
Expand Down Expand Up @@ -5441,10 +5457,6 @@ [email protected]:
core-util-is "1.0.2"
extsprintf "^1.2.0"

vlq@^0.2.1:
version "0.2.3"
resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.3.tgz#8f3e4328cf63b1540c0d67e1b2778386f8975b26"

walker@~1.0.5:
version "1.0.7"
resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.7.tgz#2f7f9b8fd10d677262b18a884e28d19618e028fb"
Expand Down