Skip to content

Commit

Permalink
Reduce umd bundle size (atlassian#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound authored and alexreardon committed Feb 28, 2018
1 parent 65500ae commit 717b75b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 28 deletions.
31 changes: 15 additions & 16 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
"presets": [
"react",
"flow",
["env", {
"targets": {
"browsers": [
"ie >= 11",
"last 1 Edge version",
"last 1 Firefox version",
"last 1 Chrome version",
"last 1 Safari version",
"last 1 iOS version",
"last 1 Android version",
"last 1 ChromeAndroid version"
]
}
}]
["env", { "modules": false, "loose": true }]
],
"plugins": [
"transform-runtime",
"transform-class-properties",
"transform-object-rest-spread",
"transform-export-extensions"
],
"comments": false
}
"comments": false,
"env": {
"cjs": {
"plugins": [
"transform-es2015-modules-commonjs"
]
},
"test": {
"plugins": [
"transform-es2015-modules-commonjs"
]
}
}
}
8 changes: 8 additions & 0 deletions .browserlistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ie >= 11
last 1 Edge version
last 1 Firefox version
last 1 Chrome version
last 1 Safari version
last 1 iOS version
last 1 Android version
last 1 ChromeAndroid version
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"typecheck": "flow check",
"build": "yarn run build:clean && yarn run build:lib && yarn run build:flow && yarn run build:dist",
"build:clean": "rimraf lib && rimraf dist",
"build:dist": "rollup -c && rollup -c --min",
"build:lib": "babel src -d lib",
"build:dist": "rollup -c && cross-env NODE_ENV=min rollup -c",
"build:lib": "cross-env NODE_ENV=cjs babel src -d lib",
"build:flow": "flow-copy-source --verbose src lib",
"storybook": "start-storybook -p 9002",
"build-storybook": "build-storybook -c .storybook -o site",
Expand All @@ -52,12 +52,14 @@
"babel-cli": "^6.26.0",
"babel-eslint": "^8.2.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"cross-env": "^5.1.3",
"enzyme": "^3.3.0",
"enzyme-adapter-react-15": "^1.0.5",
"eslint": "^4.15.0",
Expand Down
25 changes: 15 additions & 10 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,35 @@ import uglify from 'rollup-plugin-uglify';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import strip from 'rollup-plugin-strip';
import yargs from 'yargs';

const args = yargs.argv;
const min = process.env.NODE_ENV === 'min';

export default {
input: './lib/index.js',
input: './src/index.js',
output: {
file: `dist/react-beautiful-dnd${args.min ? '.min' : ''}.js`,
file: `dist/react-beautiful-dnd${min ? '.min' : ''}.js`,
format: 'umd',
name: 'ReactBeautifulDnd',
globals: { react: 'React' },
},
plugins: [
babel({ exclude: 'node_modules/**', babelrc: false }),
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**',
runtimeHelpers: true,
}),
resolve({
extensions: ['.js', '.jsx'],
}),
commonjs({
include: 'node_modules/**',
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
strip({
debugger: true,
}),
].concat(
args.min ? uglify() : []
),
min ? uglify() : {},
],
external: ['react'],
};
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,15 @@ babel-plugin-transform-es2015-modules-commonjs@^6.23.0, babel-plugin-transform-e
babel-template "^6.24.1"
babel-types "^6.24.1"

babel-plugin-transform-es2015-modules-commonjs@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz#0d8394029b7dc6abe1a97ef181e00758dd2e5d8a"
dependencies:
babel-plugin-transform-strict-mode "^6.24.1"
babel-runtime "^6.26.0"
babel-template "^6.26.0"
babel-types "^6.26.0"

babel-plugin-transform-es2015-modules-systemjs@^6.23.0:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23"
Expand Down Expand Up @@ -2113,6 +2122,13 @@ create-react-class@^15.6.0:
loose-envify "^1.3.1"
object-assign "^4.1.1"

cross-env@^5.1.3:
version "5.1.3"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.1.3.tgz#f8ae18faac87692b0a8b4d2f7000d4ec3a85dfd7"
dependencies:
cross-spawn "^5.1.0"
is-windows "^1.0.0"

cross-spawn@^5.0.1, cross-spawn@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
Expand Down Expand Up @@ -3828,6 +3844,10 @@ is-utf8@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"

is-windows@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"

[email protected], isarray@^1.0.0, isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
Expand Down

0 comments on commit 717b75b

Please sign in to comment.