Skip to content

Commit 32723e7

Browse files
committed
reduce bundle size and add prop-types to dep
1 parent c656450 commit 32723e7

File tree

4 files changed

+38
-57
lines changed

4 files changed

+38
-57
lines changed

.size-snapshot.json

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
{
2-
"dist/react-popper-tooltip.js": {
3-
"bundled": 16587,
4-
"minified": 7824,
5-
"gzipped": 2402
2+
"dist/index.js": {
3+
"bundled": 6280,
4+
"minified": 6280,
5+
"gzipped": 1974
66
},
7-
"dist/react-popper-tooltip.min.js": {
8-
"bundled": 7824,
9-
"minified": 7824,
10-
"gzipped": 2402
7+
"lib/cjs/index.js": {
8+
"bundled": 11982,
9+
"minified": 6536,
10+
"gzipped": 1904
1111
},
12-
"lib/index.cjs.js": {
13-
"bundled": 12754,
14-
"minified": 7979,
15-
"gzipped": 1986
16-
},
17-
"lib/index.esm.js": {
18-
"bundled": 12342,
19-
"minified": 7648,
20-
"gzipped": 1923,
12+
"lib/esm/index.js": {
13+
"bundled": 11940,
14+
"minified": 6518,
15+
"gzipped": 1906,
2116
"treeshaked": {
2217
"rollup": {
23-
"code": 6202,
24-
"import_statements": 697
18+
"code": 6028,
19+
"import_statements": 361
2520
},
2621
"webpack": {
27-
"code": 7775
22+
"code": 7329
2823
}
2924
}
3025
}

babel.config.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ module.exports = {
33
[
44
'@babel/env',
55
{
6-
modules: false
6+
modules: false,
7+
loose: true
78
}
89
],
9-
['@babel/react']
10+
'@babel/react'
1011
],
11-
plugins: [
12-
'@babel/plugin-proposal-class-properties',
13-
'transform-react-remove-prop-types'
14-
]
12+
plugins: [['@babel/proposal-class-properties', { loose: true }]]
1513
};

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"type": "git",
88
"url": "https://github.com/mohsinulhaq/react-popper-tooltip"
99
},
10-
"browser": "dist/react-popper-tooltip.min.js",
11-
"main": "lib/index.cjs.js",
12-
"module": "lib/index.esm.js",
10+
"browser": "lib/cjs/index.js",
11+
"module": "lib/esm/index.js",
12+
"unpkg": "dist/index.js",
1313
"style": "dist/styles.css",
1414
"typings": "typings/react-popper-tooltip.d.ts",
1515
"files": [
@@ -19,7 +19,7 @@
1919
],
2020
"scripts": {
2121
"build": "rimraf dist lib && rollup -c && cp src/styles.css dist",
22-
"prepublishOnly": "yarn lint && yarn build && yarn docs:deploy",
22+
"prepublishOnly": "yarn lint && yarn build",
2323
"docs": "docz dev",
2424
"docs:build": "docz build",
2525
"docs:deploy": "yarn docs:build && cp .docz/dist/index.html .docz/dist/404.html && gh-pages -d .docz/dist",
@@ -101,6 +101,7 @@
101101
},
102102
"dependencies": {
103103
"@babel/runtime": "^7.0.0",
104+
"prop-types": "^15.6.2",
104105
"react-popper": "^1.0.2"
105106
},
106107
"devDependencies": {
@@ -111,7 +112,6 @@
111112
"@babel/preset-env": "^7.1.0",
112113
"@babel/preset-react": "^7.0.0",
113114
"babel-eslint": "^9.0.0",
114-
"babel-plugin-transform-react-remove-prop-types": "^0.4.18",
115115
"docz": "^0.11.2",
116116
"docz-plugin-css": "^0.11.0",
117117
"eslint": "^5.6.0",
@@ -122,7 +122,6 @@
122122
"gh-pages": "^2.0.0",
123123
"pre-commit": "^1.2.2",
124124
"prettier": "^1.14.3",
125-
"prop-types": "^15.6.2",
126125
"react": "^16.5.2",
127126
"react-dom": "^16.5.2",
128127
"rimraf": "^2.6.2",
@@ -132,5 +131,6 @@
132131
"rollup-plugin-node-resolve": "^3.4.0",
133132
"rollup-plugin-size-snapshot": "^0.7.0",
134133
"rollup-plugin-terser": "^3.0.0"
135-
}
134+
},
135+
"sideEffects": false
136136
}

rollup.config.js

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ export default [
2525
input,
2626
output: {
2727
name,
28-
file: 'dist/react-popper-tooltip.js',
28+
file: 'dist/index.js',
2929
format: 'iife',
30-
globals
30+
globals,
31+
interop: false
3132
},
3233
external: Object.keys(globals),
3334
plugins: [
@@ -39,40 +40,27 @@ export default [
3940
include: 'node_modules/**'
4041
}),
4142
babel(getBabelOptions()),
43+
terser(),
4244
sizeSnapshot()
4345
]
4446
},
4547
{
4648
input,
4749
output: {
48-
name,
49-
file: 'dist/react-popper-tooltip.min.js',
50-
format: 'iife',
51-
globals
50+
file: pkg.browser,
51+
format: 'cjs',
52+
interop: false
5253
},
53-
external: Object.keys(globals),
54-
plugins: [
55-
resolve({
56-
browser: true,
57-
modulesOnly: true
58-
}),
59-
commonjs({
60-
include: 'node_modules/**'
61-
}),
62-
babel(getBabelOptions()),
63-
terser(),
64-
sizeSnapshot()
65-
]
66-
},
67-
{
68-
input,
69-
output: { file: pkg.main, format: 'cjs' },
7054
external,
7155
plugins: [babel(getBabelOptions({ useESModules: false })), sizeSnapshot()]
7256
},
7357
{
7458
input,
75-
output: { file: pkg.module, format: 'esm' },
59+
output: {
60+
file: pkg.module,
61+
format: 'esm',
62+
interop: false
63+
},
7664
external,
7765
plugins: [babel(getBabelOptions()), sizeSnapshot()]
7866
}

0 commit comments

Comments
 (0)