Skip to content

Commit 505fcc9

Browse files
authored
Create umd build for react-json-tree (#447)
1 parent 9267ef4 commit 505fcc9

File tree

2 files changed

+68
-6
lines changed

2 files changed

+68
-6
lines changed

package.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
22
"name": "react-json-tree",
3-
"version": "0.11.1",
3+
"version": "0.11.2",
44
"description": "React JSON Viewer Component, Extracted from redux-devtools",
55
"main": "lib/index.js",
66
"scripts": {
77
"clean": "rimraf lib",
88
"build": "babel src --out-dir lib",
9+
"build:umd": "rimraf ./umd && webpack --progress --config webpack.config.umd.js",
10+
"build:umd:min": "webpack --env.minimize --progress --config webpack.config.umd.js",
911
"lint": "eslint --max-warnings=0 src test examples/src",
1012
"test":
1113
"npm run lint && NODE_ENV=test mocha --compilers js:babel-core/register --recursive",
@@ -14,13 +16,14 @@
1416
"test:cov":
1517
"babel-node ./node_modules/.bin/isparta cover ./node_modules/.bin/_mocha -- --recursive",
1618
"prepare": "npm run build",
17-
"prepublishOnly": "npm run test && npm run clean && npm run build",
19+
"prepublishOnly": "npm run test && npm run clean && npm run build && npm run build:umd && npm run build:umd:min",
1820
"start": "cd examples && npm start",
1921
"precommit": "lint-staged"
2022
},
2123
"files": [
2224
"lib",
23-
"src"
25+
"src",
26+
"umd"
2427
],
2528
"repository": {
2629
"type": "git",
@@ -31,7 +34,8 @@
3134
"contributors": [
3235
"Alexander Kuznetsov <[email protected]> (http://kuzya.org/)",
3336
"Dave Vedder <[email protected]> (http://www.eskimospy.com/)",
34-
"Daniele Zannotti <[email protected]> (http://www.github.com/dzannotti)"
37+
"Daniele Zannotti <[email protected]> (http://www.github.com/dzannotti)",
38+
"Mihail Diordiev <[email protected]> (https://github.com/zalmoxisus)"
3539
],
3640
"license": "MIT",
3741
"bugs": {
@@ -42,6 +46,7 @@
4246
"babel-cli": "^6.26.0",
4347
"babel-core": "^6.26.0",
4448
"babel-eslint": "^8.0.1",
49+
"babel-loader": "^7.1.5",
4550
"babel-plugin-transform-class-properties": "^6.24.1",
4651
"babel-plugin-transform-es3-member-expression-literals": "^6.22.0",
4752
"babel-plugin-transform-es3-property-literals": "^6.22.0",
@@ -68,8 +73,11 @@
6873
"react": "^16.0.0",
6974
"react-dom": "^16.0.0",
7075
"react-test-renderer": "^16.0.0",
71-
"rimraf": "^2.5.2"
72-
},
76+
"rimraf": "^2.5.2",
77+
"terser-webpack-plugin": "^1.2.1",
78+
"webpack": "^4.27.1",
79+
"webpack-cli": "^3.2.0"
80+
},
7381
"peerDependencies": {
7482
"react": "^15.0.0 || ^16.0.0",
7583
"react-dom": "^15.0.0 || ^16.0.0"

webpack.config.umd.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
const TerserPlugin = require('terser-webpack-plugin');
4+
5+
module.exports = (env = {}) => (
6+
{
7+
mode: 'production',
8+
entry: {
9+
app: ['./src/index.js']
10+
},
11+
output: {
12+
library: 'ReactJsonTree',
13+
libraryTarget: 'umd',
14+
path: path.resolve(__dirname, 'umd'),
15+
filename: env.minimize ? 'react-json-tree.min.js' : 'react-json-tree.js'
16+
},
17+
module: {
18+
rules: [
19+
{
20+
test: /\.js$/,
21+
loader: 'babel-loader',
22+
exclude: /node_modules/
23+
}
24+
]
25+
},
26+
externals: {
27+
react: {
28+
root: 'React',
29+
commonjs2: 'react',
30+
commonjs: 'react',
31+
amd: 'react'
32+
},
33+
'react-dom': {
34+
root: 'ReactDOM',
35+
commonjs2: 'react-dom',
36+
commonjs: 'react-dom',
37+
amd: 'react-dom'
38+
}
39+
},
40+
optimization: {
41+
minimize: !!env.minimize,
42+
minimizer: [
43+
new TerserPlugin({
44+
terserOptions: {
45+
safari10: true
46+
}
47+
})
48+
]
49+
},
50+
performance: {
51+
hints: false
52+
}
53+
}
54+
);

0 commit comments

Comments
 (0)