liabru / matter-attractors

an attractors plugin for matter.js
MIT License
149 stars 31 forks source link

NPM Package broken? #1

Closed voydz closed 7 years ago

voydz commented 7 years ago

Hi there,

I was playing around with matter and I am very impressed. So first of all, a big thank you for this.

So I tried to use the matter-attractor plugin in a webpack context. Using something like this:

import Matter from 'matter-js';
import MatterAttractor from 'matter-attractors';
Matter.use(MatterAttractor);

But webpack is throwing an error at me:

 ERROR  Failed to compile with 1 errors                                                                                                                                      

This dependency was not found:

* Matter in ./~/matter-attractors/build/matter-attractors.js

To install it, you can run: npm install --save Matter

So thats a little strange, since the Matter dependency is called matter-js. I checked the source and saw that under the build/directory there are some calls to require('Matter'). I decided to not mess around with that and as the index.js is using require('matter-js') my current workaround is something ugly like this:

import Matter from 'matter-js';
Matter.use(require('../../../../node_modules/matter-attractors/index'));

And its working just fine.

Hope you can fix the issue soon. Thanks in advance. :)

voydz commented 7 years ago

@liabru came up with a PR #2. Would appreciate if you take a moment to review. Thank you for your hard work on this!

liabru commented 7 years ago

Should be fixed as of 0.1.6 please try it out!

voydz commented 7 years ago

Besides matter-js telling me he loaded matter-js: ✅ matter-attractors@0.1.4 in console, I can confirm that everything runs perfect now! 👍

liabru commented 7 years ago

Great, since you're in node you might want to set Matter.Common.logLevel = 0; to prevent any messages.