Skip to content

Commit d62dda0

Browse files
committed
Add ES6 module build
1 parent 79bf4b7 commit d62dda0

File tree

3 files changed

+73
-11
lines changed

3 files changed

+73
-11
lines changed

bundle.es.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
2+
3+
var index = {
4+
props: {
5+
mapDispatchToProps: {
6+
required: false,
7+
default: () => ({}),
8+
type: Function
9+
},
10+
11+
mapStateToProps: {
12+
required: false,
13+
default: () => ({}),
14+
type: Function
15+
},
16+
17+
store: {
18+
required: true,
19+
type: Object
20+
}
21+
},
22+
23+
data: ctx => ({
24+
state: ctx.store.getState()
25+
}),
26+
27+
created() {
28+
this.unsubscribe = this.store.subscribe(() => {
29+
this.state = this.store.getState();
30+
});
31+
},
32+
33+
destroyed() {
34+
this.unsubscribe();
35+
},
36+
37+
render() {
38+
const nodes = this.$scopedSlots.default(_extends({}, this.mapDispatchToProps(this.store.dispatch), this.mapStateToProps(this.state)));
39+
if (Array.isArray(nodes)) {
40+
return nodes[0];
41+
} else {
42+
return nodes;
43+
}
44+
}
45+
};
46+
47+
export default index;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"description": "Simple but functional binding between vuejs and redux",
1414
"main": "bundle.js",
15+
"module": "bundle.es.js",
1516
"repository": "https://github.com/titouancreach/redux-vuejs",
1617
"author": "Titouan CREACH <[email protected]>",
1718
"license": "MIT",

rollup.config.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
import babel from 'rollup-plugin-babel'
22

3-
export default {
4-
input: 'index.js',
5-
output: {
6-
file: 'bundle.js',
7-
format: 'cjs',
3+
export default [
4+
{
5+
input: 'index.js',
6+
output: {
7+
file: 'bundle.js',
8+
format: 'cjs',
9+
},
10+
plugins: [
11+
babel({
12+
exclude: 'node_modules/**',
13+
}),
14+
],
815
},
9-
plugins: [
10-
babel({
11-
exclude: 'node_modules/**',
12-
}),
13-
],
14-
}
16+
{
17+
input: 'index.js',
18+
output: {
19+
file: 'bundle.es.js',
20+
format: 'es',
21+
},
22+
plugins: [
23+
babel({
24+
exclude: 'node_modules/**',
25+
}),
26+
],
27+
}
28+
]

0 commit comments

Comments
 (0)