Skip to content

Commit 717b75b

Browse files
TrySoundalexreardon
authored andcommitted
Reduce umd bundle size (atlassian#346)
1 parent 65500ae commit 717b75b

File tree

5 files changed

+62
-28
lines changed

5 files changed

+62
-28
lines changed

Diff for: .babelrc

+15-16
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@
22
"presets": [
33
"react",
44
"flow",
5-
["env", {
6-
"targets": {
7-
"browsers": [
8-
"ie >= 11",
9-
"last 1 Edge version",
10-
"last 1 Firefox version",
11-
"last 1 Chrome version",
12-
"last 1 Safari version",
13-
"last 1 iOS version",
14-
"last 1 Android version",
15-
"last 1 ChromeAndroid version"
16-
]
17-
}
18-
}]
5+
["env", { "modules": false, "loose": true }]
196
],
207
"plugins": [
218
"transform-runtime",
229
"transform-class-properties",
2310
"transform-object-rest-spread",
2411
"transform-export-extensions"
2512
],
26-
"comments": false
27-
}
13+
"comments": false,
14+
"env": {
15+
"cjs": {
16+
"plugins": [
17+
"transform-es2015-modules-commonjs"
18+
]
19+
},
20+
"test": {
21+
"plugins": [
22+
"transform-es2015-modules-commonjs"
23+
]
24+
}
25+
}
26+
}

Diff for: .browserlistrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ie >= 11
2+
last 1 Edge version
3+
last 1 Firefox version
4+
last 1 Chrome version
5+
last 1 Safari version
6+
last 1 iOS version
7+
last 1 Android version
8+
last 1 ChromeAndroid version

Diff for: package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"typecheck": "flow check",
2828
"build": "yarn run build:clean && yarn run build:lib && yarn run build:flow && yarn run build:dist",
2929
"build:clean": "rimraf lib && rimraf dist",
30-
"build:dist": "rollup -c && rollup -c --min",
31-
"build:lib": "babel src -d lib",
30+
"build:dist": "rollup -c && cross-env NODE_ENV=min rollup -c",
31+
"build:lib": "cross-env NODE_ENV=cjs babel src -d lib",
3232
"build:flow": "flow-copy-source --verbose src lib",
3333
"storybook": "start-storybook -p 9002",
3434
"build-storybook": "build-storybook -c .storybook -o site",
@@ -52,12 +52,14 @@
5252
"babel-cli": "^6.26.0",
5353
"babel-eslint": "^8.2.1",
5454
"babel-plugin-transform-class-properties": "^6.24.1",
55+
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
5556
"babel-plugin-transform-export-extensions": "^6.22.0",
5657
"babel-plugin-transform-object-rest-spread": "^6.26.0",
5758
"babel-plugin-transform-runtime": "^6.23.0",
5859
"babel-preset-env": "^1.6.1",
5960
"babel-preset-flow": "^6.23.0",
6061
"babel-preset-react": "^6.24.1",
62+
"cross-env": "^5.1.3",
6163
"enzyme": "^3.3.0",
6264
"enzyme-adapter-react-15": "^1.0.5",
6365
"eslint": "^4.15.0",

Diff for: rollup.config.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,35 @@ import uglify from 'rollup-plugin-uglify';
66
import babel from 'rollup-plugin-babel';
77
import replace from 'rollup-plugin-replace';
88
import strip from 'rollup-plugin-strip';
9-
import yargs from 'yargs';
109

11-
const args = yargs.argv;
10+
const min = process.env.NODE_ENV === 'min';
1211

1312
export default {
14-
input: './lib/index.js',
13+
input: './src/index.js',
1514
output: {
16-
file: `dist/react-beautiful-dnd${args.min ? '.min' : ''}.js`,
15+
file: `dist/react-beautiful-dnd${min ? '.min' : ''}.js`,
1716
format: 'umd',
1817
name: 'ReactBeautifulDnd',
1918
globals: { react: 'React' },
2019
},
2120
plugins: [
22-
babel({ exclude: 'node_modules/**', babelrc: false }),
23-
resolve(),
24-
commonjs(),
21+
babel({
22+
exclude: 'node_modules/**',
23+
runtimeHelpers: true,
24+
}),
25+
resolve({
26+
extensions: ['.js', '.jsx'],
27+
}),
28+
commonjs({
29+
include: 'node_modules/**',
30+
}),
2531
replace({
2632
'process.env.NODE_ENV': JSON.stringify('production'),
2733
}),
2834
strip({
2935
debugger: true,
3036
}),
31-
].concat(
32-
args.min ? uglify() : []
33-
),
37+
min ? uglify() : {},
38+
],
3439
external: ['react'],
3540
};

Diff for: yarn.lock

+20
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,15 @@ babel-plugin-transform-es2015-modules-commonjs@^6.23.0, babel-plugin-transform-e
11151115
babel-template "^6.24.1"
11161116
babel-types "^6.24.1"
11171117

1118+
babel-plugin-transform-es2015-modules-commonjs@^6.26.0:
1119+
version "6.26.0"
1120+
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz#0d8394029b7dc6abe1a97ef181e00758dd2e5d8a"
1121+
dependencies:
1122+
babel-plugin-transform-strict-mode "^6.24.1"
1123+
babel-runtime "^6.26.0"
1124+
babel-template "^6.26.0"
1125+
babel-types "^6.26.0"
1126+
11181127
babel-plugin-transform-es2015-modules-systemjs@^6.23.0:
11191128
version "6.24.1"
11201129
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23"
@@ -2113,6 +2122,13 @@ create-react-class@^15.6.0:
21132122
loose-envify "^1.3.1"
21142123
object-assign "^4.1.1"
21152124

2125+
cross-env@^5.1.3:
2126+
version "5.1.3"
2127+
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.1.3.tgz#f8ae18faac87692b0a8b4d2f7000d4ec3a85dfd7"
2128+
dependencies:
2129+
cross-spawn "^5.1.0"
2130+
is-windows "^1.0.0"
2131+
21162132
cross-spawn@^5.0.1, cross-spawn@^5.1.0:
21172133
version "5.1.0"
21182134
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
@@ -3828,6 +3844,10 @@ is-utf8@^0.2.0:
38283844
version "0.2.1"
38293845
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"
38303846

3847+
is-windows@^1.0.0:
3848+
version "1.0.2"
3849+
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
3850+
38313851
[email protected], isarray@^1.0.0, isarray@~1.0.0:
38323852
version "1.0.0"
38333853
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"

0 commit comments

Comments
 (0)