Open zjeff222 opened 3 years ago
Might be related to this: https://github.com/webpack/webpack/issues/6525
Just to be clear, I was talking about the webpack code embeded in planck.js. So I edited line 34 of the planck.js file. Patching the library will do for me for now. It's great to have box2d on javascript by the way :)
If I understand, this would be a solution where I am to use webpack. I'm not using webpack. So if I do understand, some webpack code is added to planck.js to make it better for those who use webpack ? I only used 2-3 libraries up to now and it's the first one I see with embeded webpack code. (I'm new to js)
Webpack combines source files and generates files like planck.js
file, Planck distribution files are built with webpack. We need to configure webpack to fix the issue that you reported in the build file.
Oh, what I meant by asking if that solution works for you was that if rebuilding planck with that solution will solve the problem. I did not mean to use that solution in your project.
Sorry, I don't want to learn how to build a js library at this time. If you want to reproduce the problem, you only have to call a worker with myWorker = new Worker('./worker.js');
and in the worker.js import planck: importScripts('../../lib/planck.min.js');
Makes sense, no worries; if you need to build it for any other reason here are the commands (assuming git and npm are already installed):
git clone git@github.com:shakiba/planck.js.git
cd planck.js
npm install
npm run build
I don't know anything about webpack but it seams to be blocking planck from loading into a web worker. There is an access to the window element, which is not defined in a worker, and it really seams to be webpack related.
So I replaced the "window" reference to "this" and it works, but I really don't know what I'm doing!