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

Import PIXI instead of requiring it to exist globally. #104

Closed
monoclex opened this issue Oct 6, 2020 · 11 comments
Closed

Import PIXI instead of requiring it to exist globally. #104

monoclex opened this issue Oct 6, 2020 · 11 comments

Comments

@monoclex
Copy link

monoclex commented Oct 6, 2020

When including pixi-tilemap in a bundle, being forced to make sure that pixi,js is included before pixi-tilemap is very prone to errors. For me, my IDE automatically reorders the imports to be in reverse order, which would cause problems in the future. Whilst easily work-aroundable, it would be very nice if pixi-tilemap would not implicitly rely on the PIXI global existing, and rather import it.

@eranimo
Copy link

eranimo commented Nov 9, 2020

This is currently breaking the latest version of pixi-tilemap

@ivanpopelyshev
Copy link
Collaborator

@eranimo please elaborate, whats wrong there? i still cant figure out how to make all those modules

@martinemmert
Copy link

I think the package needs a bit of love to support the ES6 module system and CommonJS projects.
It is possible by having a correct set-up project and a package.json containing a proper exports config.

I am currently struggling with this issue as well, and there are many pitfalls regarding that. I might come up with a pull-request to solve that. But I cannot guarantee that old projects still work correctly since I ultimately would deprecate the global PIXI object.

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Nov 16, 2020

we are experimenting with pixi-tilemap, and new pixi.js 5.4 rc1 , im waiting for rc2. When one plugin will be ready - i'll move everything else

previously, when i tried to move to modules, it ended bad. several times. there's also something that is missing that's wasnt possible to do using es6 modules. The whole approach was fucked up because lack of necessary build tools.

How did I unfuck it: I invented "global mixins" approach and it will be posted in 5.4 rc2

@martinemmert
Copy link

Hm, I've yet to see a mixin solution that brings something good to the table.
Care to share?

@ivanpopelyshev
Copy link
Collaborator

@martinemmert
Copy link

martinemmert commented Nov 16, 2020

I skimmed the issues and PR's, but I can't see when or how these global mixins are introduced.
Even though it might be better to have this conversation somewhere else.

Anyway, I'll continue working on my fork and come up with a PR as soon as it is ready.

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Nov 16, 2020

Basically, we introduce interfaces in global scope, that we implement in PixiJS. That interface can be changed in other modules. To support this perversion and ensure correct generation of docs / types we had to experiment. a lot.

@martinemmert
Copy link

Sounds interesting. Hopefully, it works out as planned. 👍
I've added my proposal to solve the module compatibility issues as PR, tested it locally with the examples and my current project. It seems to be working without any issues so far.

@spassvogel
Copy link
Contributor

@ivanpopelyshev for the health and longevity for pixijs and its plugins I believe it would be really good to have this. I think a lot lof developers will be initially put off by some of these old school javascript paradigms and the hacks you have to apply to get it to work in a modern setup.

@ShukantPal
Copy link
Member

#110 fixes the global PIXI problem

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

6 participants