abc123s / redux-batch-enhancer

Batch subscriber notification for an array of actions (including complex actions, e.g. thunks).
25 stars 8 forks source link

Error building with babel #1

Closed jonashartwig closed 8 years ago

jonashartwig commented 8 years ago

We use babel with presets: "es2015", "react", "stage-2"

ERROR in ./~/redux-batch-enhancer/index.js Module parse failed: /Users/ejashig/Documents/workspace/insight-new/node_modules/redux-batch-enhancer/index.js Unexpected token (92:6) You may need an appropriate loader to handle this file type. SyntaxError: Unexpected token (92:6) at Parser.pp.raise (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:923:13) at Parser.pp.unexpected (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:1490:8) at Parser.pp.parseIdent (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:680:10) at Parser.pp.parsePropertyName (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:556:127) at Parser.pp.parseObj (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:502:10) at Parser.pp.parseExprAtom (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:316:19) at Parser.pp.parseExprSubscripts (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:228:19) at Parser.pp.parseMaybeUnary (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:207:17) at Parser.pp.parseExprOps (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:154:19) at Parser.pp.parseMaybeConditional (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:136:19) at Parser.pp.parseMaybeAssign (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:112:19) at Parser.pp.parseExpression (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:88:19) at Parser.pp.parseReturnStatement (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:1872:26) at Parser.pp.parseStatement (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:1737:19) at Parser.pp.parseBlock (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:2009:21) at Parser.pp.parseFunctionBody (/Users/ejashig/Documents/workspace/insight-new/node_modules/webpack/node_modules/acorn/dist/acorn.js:610:22) @ ./src/actions/DashboardActions.js 56:26-57

my proposal:

return Object.assign({}, store, {
    dispatch,
    subscribe,
    subscribeImmediate
});
/*return {
  ...store,
  dispatch,
  subscribe,
  subscribeImmediate
};*/

I assume I am doing something wrong in general. After building i get a JS error in console: Unexpected token export. Somehow this needs to converted so the browser understands it, right?

abc123s commented 8 years ago

I'm also using the object spread operator, so you'll need to install the babel-plugin-transform-object-rest-spread plugin. I'll reorganize the code to include the necessary babel presets and plugins later this week or early next week.

More info here: http://redux.js.org/docs/recipes/UsingObjectSpreadOperator.html

Alternatively, your proposed change that removes the usage of the object spread operator is fine too; I'm not sure why you're you're getting the error Unexpected token export - I thought export was was included in the es2015 preset.

jonashartwig commented 8 years ago

Hi,

I understand. Unfortunately, the project is set-up that all babel imports ignore node_modules. There is so many stuffs included that building would take too long time.

Any other idea on how this could be fixed?

Regards

abc123s commented 8 years ago

Sorry for the delay... looks like Olslash fixed the issue - the latest version on npm should be compatible with vanilla js.

Let me know if you're still having any issues!

jonashartwig commented 8 years ago

Thanks!