danawoodman / react-fontawesome

A React Font Awesome component.
https://www.npmjs.com/package/react-fontawesome
MIT License
667 stars 72 forks source link

Unable to use this #15

Closed csterritt closed 8 years ago

csterritt commented 8 years ago

Hi -- Thanks for doing this, it looks great.

However, I'm getting the following error when I try to use it:

Module build failed: ReferenceError: Unknown plugin "add-module-exports" specified in "/Users/chris/hacks/notomatic/front_end/node_modules/react-fontawesome/.babelrc" at 0, attempted to resolve relative to "/Users/chris/hacks/notomatic/front_end/node_modules/react-fontawesome"

Any clues appreciated.

csterritt commented 8 years ago

Fixed!

First, I did:

npm install babel-plugin-add-module-exports --save-dev

Then, set up my web pack.config.json to change the following part from:

    module: {
        loaders: [
            { test: /\.css$/, loader: "style!css" },
            {
              test: /\.js$/,
              loader: 'babel-loader',
              query: {
                presets: ['es2015', 'react']
              }
            }
        ]
    },

to

    module: {
        loaders: [
            { test: /\.css$/, loader: "style!css" },
            {
              test: /\.js$/,
              loader: 'babel-loader',
              query: {
                presets: ['es2015', 'react'],
                plugins: ["add-module-exports"]
              }
            }
        ]
    },
danawoodman commented 8 years ago

Hi @csterritt sorry for long delay in replying, must have missed this! Glad you figured it out but it is strange that you got that issue. Can you check to see if it is still a problem for you and reopen if so?

naldir commented 7 years ago

I had the same issue today. The solution proposed worked for me too

olegstepura commented 7 years ago

With webpack2 it's inappropriate solution. @see https://gist.github.com/iamakulov/966b91c0fc6363a16ff0650b51fb991b

@danawoodman Will you get rid of this?

danawoodman commented 7 years ago

@olegstepura it would be an issue I would need to address if I upgrade to WebPack 2 but I don't think it should be an issue for consumers of this library. Am I wrong?

olegstepura commented 7 years ago

It is an issue. I'm using webpack 2. And after importing anything from this lib I get the error mentioned above. This stops build, I cannot proceed. But I cannot install add-module-exports since it's incompatible with webpack 2. So ignoring this will only lead to not using this lib.

danawoodman commented 7 years ago

@olegstepura I am using WebPack 2 and do not get this error. Can you post your WebPack config?

olegstepura commented 7 years ago

Sure. It's the same as here: https://github.com/olegstepura/postcss-loader-test/blob/master/webpack.config.js

Actually whole config including package.json is almost the same in that test project.

danawoodman commented 7 years ago

@olegstepura perhaps you could put together a minimal test case where this fails? That config is a bit complex and hard to know what is triggering the issue

olegstepura commented 7 years ago

Please read this: https://github.com/brigade/react-waypoint/issues/186

That issue is about the same thing. There is my comment on how it was temporarily solved and how to possibly proceed by library author

danawoodman commented 7 years ago

So from what I can tell @olegstepura is that you are including react-fontawesome in WebPack. Why not exclude it just as you mentioned in the comment thread?

olegstepura commented 7 years ago

Because that is not a plug-and-play solution.

danawoodman commented 7 years ago

@olegstepura It seems typical to me for people to exclude the node_modules folder. In fact, it seems like a best practice to do so otherwise you're parsing all your node_modules which is incredibly slow and unnecessary. I don't see a compelling reason to change the current behavior at this point

olegstepura commented 7 years ago

@danawoodman Thanks a lot! That was a reasonable comment. I will try to use only compiled versions of all the stuff, excluding node_modules completely. But I think it will be good for any library including yours to hanle such situations as well (maybe using js:next)

danawoodman commented 7 years ago

@olegstepura no problem 👍 I'll consider it in the future as the WebPack 2 landscape changes 😄

Nisharunnisaa commented 6 years ago

I am facing the same error as @csterritt tried the solution proposed by him but still getting the same error..can anyone suggest me what to do resolve the issue?

danawoodman commented 6 years ago

@Nisharunnisaa you excluded node_modules folder?

Nisharunnisaa commented 6 years ago

No i didn't excluded node_modules folder but still facing the issue. is There any alternative @danawoodman ? Help me with the solution

Thanks in Advance

danawoodman commented 6 years ago

Exclude node_modules and see if that fixes it