Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use react-magic-move with webpack #7

Open
hugooliveirad opened this issue Mar 5, 2015 · 2 comments
Open

Use react-magic-move with webpack #7

hugooliveirad opened this issue Mar 5, 2015 · 2 comments

Comments

@hugooliveirad
Copy link

Hi! I want to use react-magic-move in my app. The catch is that I'm compiling everything with webpack and using the exclude option to prevent compiling every dependency.

My webpack.config.js looks like this:

module: {
    loaders: [
      { test: /\.js$/, loaders: ['react-hot', 'babel?experimental'], exclude: /node_modules/ }
    ]
}

When I try to build a file with require('react-magic-move') I get this error:

ERROR in ./~/react-magic-move/modules/components/MagicMove.js
Module parse failed: /Users/hugo.bessa/Sites/copag-cartas/node_modules/react-magic-move/modules/components/MagicMove.js Line 8: Unexpected token (
You may need an appropriate loader to handle this file type.
|   displayName: 'MagicMoveClones',
|
|   childrenWithPositions () {
|     var children = [];
|     React.Children.forEach(this.props.children, (child) => {
 @ ./~/react-magic-move/modules/index.js 1:17-50

As I'm excluding my dependencies from the build step, and react-magic-move is exporting an ES6 module, the build step is failing.

Can react-magic-move export an ES5 CommonJS bundle or should I change my webpack configs?

@beeant
Copy link

beeant commented Apr 5, 2015

Correct me if I'm wrong,

You need to add loader for jsx-loader?harmony transformer
For me, I have something like this: (I'm using react-jade for my React components in public folder)

loaders: [
  { test: /\.js$/, exclude: /node_modules/, loader: "transform?react-jade" },
  { test: /\.js$/, exclude: /public/, loader: 'jsx-loader?harmony' },
]

don't forget to npm install jsx-loader

@hugooliveirad
Copy link
Author

Hey @beeant I missed your comment. Thanks for the help, I'll see if this fixes my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants