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

matter-js can't find decomp when imported via ES6 #629

Closed
fiskhandlarn opened this issue Jun 10, 2018 · 1 comment
Closed

matter-js can't find decomp when imported via ES6 #629

fiskhandlarn opened this issue Jun 10, 2018 · 1 comment

Comments

@fiskhandlarn
Copy link

Since matter.js tries to evaluate windows.decomp directly when imported ...

var decomp = (typeof window !== "undefined" ? window['decomp'] : typeof global !== "undefined" ? global['decomp'] : null);

... and all imports are done before any other code is run, this (as implied by this example) didn't work for me:

import decomp from 'poly-decomp';

window.decomp = decomp;

import Matter from 'matter-js'; // eslint-disable-line import/first

matter-js was still evaluated before window.decomp = decomp, and thus var decomp would still be undefined.

This plugin should check for window.decomp first when it's needed (inside Bodies.fromVertices) or at least document this solution from @rykerrumsey.

@Qriva
Copy link
Contributor

Qriva commented Jun 10, 2018

I had the same problem but managed to resolved it by adding global decomp in webpack (the same as provided link). I also think it should be changed, back then I was very confused why my code does not work even after adding global decomp.

@liabru liabru closed this as completed in 0cf97f5 Jun 11, 2018
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