3

CoffeeScript doesn't support ES6 import yet. (See https://github.com/jashkenas/coffeescript/issues/3162)

I tried to use the following syntax as explained in the link:

`import { createAction, handleAction, handleActions } from 'redux-actions'`

But Browserify throws the following error:

Browerify { err: 
   { [Error: Parsing file: 'import' and 'export' may only appear at the top level (2:0)]

So, I'm currently stuck with the old traditional way:

reduxActions = require 'redux-actions'
console.log reduxActions.createAction

Which works fine but force me to either use reduxActions.createAction or to manually define createAction = reduxActions.createAction in each file were I need it. I'm looking for a better way of doing this, if any.

1 Answer 1

4

A collegue of mine found a solution:

{ createAction, handleAction, handleActions } = require 'redux-actions'

It's the best way of doing this I've found so far, looks like ES6.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.