Skip to content

Commit 84189d9

Browse files
committed
build: fix rollup setup
Let Rollup do tree-shaking to minimize needed deps and reduce codesize.
1 parent 38d983d commit 84189d9

File tree

22 files changed

+926
-848
lines changed

22 files changed

+926
-848
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"serve:graph2d": "lerna run serve --stream --scope @vue2vis/graph2d",
1111
"serve:network": "lerna run serve --stream --scope @vue2vis/network",
1212
"serve:timeline": "lerna run serve --stream --scope @vue2vis/timeline",
13-
"clean": "lerna exec -- rm -rf ./node_modules",
13+
"clean": "lerna exec -- rm -rf ./node_modules ./dist && rm -R ./node_modules",
1414
"commit": "yarn git-cz",
1515
"prepare": "lerna run prepare",
1616
"lerna:publish": "lerna publish --conventional-commits",
@@ -68,6 +68,7 @@
6868
"eslint-plugin-vue": "^6.1.2",
6969
"husky": "^4.2.3",
7070
"lerna": "^3.20.2",
71+
"moment": "^2.24.0",
7172
"prettier": "^1.19.1",
7273
"rollup": "^2.0.6",
7374
"rollup-plugin-vue": "^5.1.6",

packages/graph2d/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ new Vue({
7979
});
8080
```
8181

82+
Additional info can be found on [Visjs Graph2d documentation](https://visjs.github.io/vis-timeline/docs/graph2d/)
83+
8284
Here is a basic working demo with item generation:
8385
[JS Fiddle Basic Demo](https://jsfiddle.net/alexkodo/ejdut8fm/)
8486

@@ -89,7 +91,7 @@ You can also create items or group labels as Vue Components:
8991

9092
### Component Events
9193

92-
By default all Vis events are emitted by your component. You can subscribe to a subset by passing an array in the prop `events` [Visjs event](http://visjs.org/docs/graph2d/#Events).
94+
By default all Vis events are emitted by your component. You can subscribe to a subset by passing an array in the prop `events` [Visjs event](https://visjs.github.io/vis-timeline/docs/graph2d/#Events).
9395

9496
```html
9597
<body>

packages/graph2d/examples/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
<script>
3737
import { Graph2d } from "@vue2vis/graph2d";
38+
import "vis-timeline/styles/vis-timeline-graph2d.css";
3839
3940
export default {
4041
components: {

packages/graph2d/lib/Graph2d.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { DataSet, DataView } from "vis-data/esnext";
77
import { Graph2d } from "vis-timeline/esnext";
88
import { mountVisData, translateEvent } from "@vue2vis/utils";
9-
import "vis-timeline/styles/vis-timeline-graph2d.css";
109
1110
export default {
1211
name: "graph2d",

packages/graph2d/package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,22 @@
3131
},
3232
"dependencies": {
3333
"@vue2vis/utils": "^1.0.0",
34-
"vis-timeline": "^7.2.1"
34+
"vis-timeline": "^7.3.4"
3535
},
3636
"peerDependencies": {
3737
"moment": "^2.24.0",
38-
"vis-data": "^6.3.0"
38+
"vis-data": "^6.5.1"
3939
},
4040
"devDependencies": {
4141
"@egjs/hammerjs": "^2.0.0",
42+
"@rollup/plugin-commonjs": "^11.0.2",
43+
"@rollup/plugin-node-resolve": "^7.1.1",
4244
"component-emitter": "^1.3.0",
4345
"keycharm": "^0.3.0",
44-
"moment": "^2.24.0",
4546
"propagating-hammerjs": "^1.4.0",
46-
"uuid": "^3.4.0"
47+
"rollup-plugin-node-externals": "^2.1.5",
48+
"rollup-plugin-node-polyfills": "^0.2.1",
49+
"uuid": "^7.0.0",
50+
"vis-util": "^4.0.0"
4751
}
4852
}

packages/graph2d/rollup.config.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import externals from "rollup-plugin-node-externals";
2+
import resolve from "@rollup/plugin-node-resolve";
3+
import commonjs from "@rollup/plugin-commonjs";
4+
import nodePolyfills from "rollup-plugin-node-polyfills";
15
import vue from "rollup-plugin-vue";
26

37
export default [
@@ -7,14 +11,34 @@ export default [
711
format: "esm",
812
file: "dist/graph2d.esm.js"
913
},
10-
plugins: [vue()]
14+
plugins: [
15+
externals(),
16+
nodePolyfills(),
17+
resolve({ browser: true }),
18+
commonjs({
19+
namedExports: {
20+
uuid: ["v4"]
21+
}
22+
}),
23+
vue()
24+
]
1125
},
1226
{
1327
input: "./lib/index.js",
1428
output: {
1529
format: "cjs",
1630
file: "dist/graph2d.cjs.js"
1731
},
18-
plugins: [vue()]
32+
plugins: [
33+
externals(),
34+
nodePolyfills(),
35+
resolve({ browser: true }),
36+
commonjs({
37+
namedExports: {
38+
uuid: ["v4"]
39+
}
40+
}),
41+
vue()
42+
]
1943
}
2044
];

packages/graph2d/yarn.lock

Lines changed: 0 additions & 35 deletions
This file was deleted.

packages/network/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ new Vue({
7777
});
7878
```
7979

80+
Additional info can be found on [Visjs Network documentation](https://visjs.github.io/vis-network/docs/network/)
81+
8082
Here is a basic working demo with item generation:
8183
[JS Fiddle Basic Demo](https://jsfiddle.net/alexkodo/ejdut8fm/)
8284

@@ -87,7 +89,7 @@ You can also create items or group labels as Vue Components:
8789

8890
### Component Events
8991

90-
By default all Vis events are emitted by your component. You can subscribe to a subset by passing an array in the prop `events` [Visjs event](http://visjs.org/docs/network/#Events).
92+
By default all Vis events are emitted by your component. You can subscribe to a subset by passing an array in the prop `events` [Visjs event](https://visjs.github.io/vis-network/docs/timeline/#Events).
9193

9294
```html
9395
<body>

packages/network/lib/Network.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { DataSet, DataView } from "vis-data/esnext";
77
import { Network } from "vis-network/esnext";
88
import { mountVisData, translateEvent } from "@vue2vis/utils";
9-
import "vis-network/styles/vis-network.css";
109
1110
export default {
1211
name: "network",

packages/network/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@
3535
},
3636
"peerDependencies": {
3737
"moment": "^2.24.0",
38-
"vis-data": "^6.5.0"
38+
"vis-data": "^6.5.1"
3939
},
4040
"devDependencies": {
4141
"@egjs/hammerjs": "^2.0.0",
42+
"@rollup/plugin-commonjs": "^11.0.2",
43+
"@rollup/plugin-node-resolve": "^7.1.1",
4244
"component-emitter": "^1.3.0",
4345
"keycharm": "^0.3.0",
44-
"moment": "^2.24.0",
46+
"rollup-plugin-node-externals": "^2.1.5",
47+
"rollup-plugin-node-polyfills": "^0.2.1",
4548
"timsort": "^0.3.0",
46-
"uuid": "^7.0.0"
49+
"uuid": "^7.0.0",
50+
"vis-util": "^4.0.0"
4751
}
4852
}

0 commit comments

Comments
 (0)