diff --git a/MapStore2 b/MapStore2 index 6d55e7d..b697b85 160000 --- a/MapStore2 +++ b/MapStore2 @@ -1 +1 @@ -Subproject commit 6d55e7df42718917fe23219a2c42c92d35994a9b +Subproject commit b697b8522e7fb1ea9a705ab687b3e4961ef0458d diff --git a/js/extension/plugins/Extension.jsx b/js/extension/plugins/Extension.jsx index fb6e42c..887f8c0 100644 --- a/js/extension/plugins/Extension.jsx +++ b/js/extension/plugins/Extension.jsx @@ -1,50 +1,4 @@ -import {connect} from "react-redux"; -import { name } from '../../../config'; +import {toModulePlugin} from "@mapstore/utils/ModulePluginsUtils"; +import {name} from "../../../config"; -import ExtensionComponent from "../components/Component"; -import Rx from "rxjs"; -import { changeZoomLevel } from "@mapstore/actions/map"; - -import '../assets/style.css'; -export default { - name, - component: connect(state => ({ - value: state.sampleExtension && state.sampleExtension.value - }), { - onIncrease: () => { - return { - type: 'INCREASE_COUNTER' - }; - }, changeZoomLevel - })(ExtensionComponent), - reducers: { - sampleExtension: (state = { value: 1 }, action) => { - if (action.type === 'INCREASE_COUNTER') { - return { value: state.value + 1 }; - } - return state; - } - }, - epics: { - logCounterValue: (action$, store) => action$.ofType('INCREASE_COUNTER').switchMap(() => { - /* eslint-disable */ - console.log('CURRENT VALUE: ' + store.getState().sampleExtension.value); - /* eslint-enable */ - return Rx.Observable.empty(); - }) - }, - containers: { - Toolbar: { - name: "sampleExtension", - position: 10, - text: "INC", - doNotHide: true, - action: () => { - return { - type: 'INCREASE_COUNTER' - }; - }, - priority: 1 - } - } -}; +export default toModulePlugin(name, () => import(/* webpackChunkName: 'extension' */ './Module')); diff --git a/js/extension/plugins/Module.jsx b/js/extension/plugins/Module.jsx new file mode 100644 index 0000000..fcf61ae --- /dev/null +++ b/js/extension/plugins/Module.jsx @@ -0,0 +1,51 @@ +import {connect} from "react-redux"; +import { name } from '../../../config'; + +import {createPlugin} from "@mapstore/utils/PluginsUtils"; +import ExtensionComponent from "../components/Component"; +import Rx from "rxjs"; + +import { changeZoomLevel } from "@mapstore/actions/map"; +import '../assets/style.css'; + +export default createPlugin(name, { + component: connect(state => ({ + value: state.sampleExtension && state.sampleExtension.value + }), { + onIncrease: () => { + return { + type: 'INCREASE_COUNTER' + }; + }, changeZoomLevel + })(ExtensionComponent), + reducers: { + sampleExtension: (state = { value: 1 }, action) => { + if (action.type === 'INCREASE_COUNTER') { + return { value: state.value + 1 }; + } + return state; + } + }, + epics: { + logCounterValue: (action$, store) => action$.ofType('INCREASE_COUNTER').switchMap(() => { + /* eslint-disable */ + console.log('CURRENT VALUE: ' + store.getState().sampleExtension.value); + /* eslint-enable */ + return Rx.Observable.empty(); + }) + }, + containers: { + Toolbar: { + name: "sampleExtension", + position: 10, + text: "INC", + doNotHide: true, + action: () => { + return { + type: 'INCREASE_COUNTER' + }; + }, + priority: 1 + } + } +}); diff --git a/js/extensions.js b/js/extensions.js index 49fbc92..29c4aff 100644 --- a/js/extensions.js +++ b/js/extensions.js @@ -6,11 +6,10 @@ * LICENSE file in the root directory of this source tree. */ -import { createPlugin } from "@mapstore/utils/PluginsUtils"; import Extension from './extension/plugins/Extension'; import { name } from '../config'; export default { - [name]: createPlugin(name, Extension) + [name]: Extension };