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

Don't pass the whole Pixi object to the Pixi extension #2

Open
getkey opened this issue May 17, 2021 · 1 comment
Open

Don't pass the whole Pixi object to the Pixi extension #2

getkey opened this issue May 17, 2021 · 1 comment

Comments

@getkey
Copy link
Contributor

getkey commented May 17, 2021

stats.enableExtension('pixi', [PIXI, app]);

Doing this will prevent parts of Pixi from being tree-shaked when using a module bundler. It's a shame since not much from Pixi is needed, only this small enum https://github.com/pixijs/pixi.js/blob/e4d574395aeac5ba0a89b52a47528126bcba529f/packages/constants/src/index.ts#L173-L182

Some solutions:

  1. Adding @pixi/constants as a dependency. When I tried it, the whole dependency was imported (not only FORMATS). Pixi will need to add pure annotations to avoid that. In the meantime it would needlessly increase the size of this lib (perhaps terser could help though?).
  2. Adding @pixi/constants as an optional peer dependencies. It works well, however it breaks if the user is not using a bundler, as in the example.
  3. Inlining the enum from Pixi. It's barbaric but it works!
@ErikSom
Copy link
Owner

ErikSom commented Jun 20, 2022

I would say lets go with #3

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