Skip to content

Commit

Permalink
Fixes #3122: should fix plugins example build time and reduce the rel…
Browse files Browse the repository at this point in the history
…ated bundle size (#3128)
  • Loading branch information
mbarto authored and offtherailz committed Jul 31, 2018
1 parent 5ebaaf0 commit 6727203
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions web/client/examples/plugins/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ const startApp = () => {

let customReducers;

const context = require('./context');

const customReducer = (state = {}, action) => {
if (customReducers) {
const newState = assign({}, state);
Expand Down Expand Up @@ -127,12 +125,11 @@ const startApp = () => {
applyStyle(theme, callback);
};

const customPlugin = (callback, code) => {
const customPluginApply = (callback, code, context) => {
/*eslint-disable */
const require = context;
try {
customReducers = eval(Babel.transform(code, { presets: ['es2015', 'react', 'stage-0'] }).code).reducers || null;

/*eslint-enable */
userPlugin = connect(() => ({
template: code,
Expand All @@ -154,6 +151,13 @@ const startApp = () => {
}
};

const customPlugin = (callback, code) => {
require.ensure(['./context'], (require) => {
const context = require('./context');
customPluginApply(callback, code, context);
});
};

const PluginConfigurator = require('./components/PluginConfigurator');

const PluginCreator = connect((state) => ({
Expand Down

0 comments on commit 6727203

Please sign in to comment.