Comments (5)
We have made a lot of progress with regards to tree-shaking as well as using dynamic imports to reduce the bundle filesize. It would be helpful if you could provide a concrete example. Many code bundler are better or worse at tree-shaking. For instance, I found Parcel to be worse than Vite. Could you provide more specific about what you found?
That said, we do have a path for creating a composable versions of pixi.js (in v7 we had this tool https://pixijs.io/customize/) . We haven't fully creating tooling or guides around this for v8, but I know @Zyie is thinking about it. As a starting place, you can look at src/index.ts which is the default pixi.js
import. You could create your own version of this using imports to the pieces you need (e.g., pixi.js/accessibility
, pixi.js/culling
etc. ).
from pixijs.
So, 2 topics:
1/ Extensions (point raised in #10393)
Patching index.ts
isn't needed as it tree-shakes fine - it's just the library exports.
In reality, features like Event and Accessibility systems are initialized/wired explicitly in browserAll.ts
and the bundle.*
's which call the extensions' init.ts
.
Agreed though, it's simple enough to patch, if one is happy doing their own build of Pixi.
2/ Render pipeline (Graphics, Tiling...)
However that's not all, "renderables" have hard references in the render pipeline:
- https://github.com/pixijs/pixijs/blob/dev/src/prepare/PrepareQueue.ts#L58-L83
- https://github.com/pixijs/pixijs/blob/dev/src/prepare/PrepareUpload.ts#L40-L43
I appreciate how amazeball the vector graphics feature is, but we don't need and it represents ~20% of the library payload. I believe some decoupling/IoC could be done - and I'm confident it can be done without over-engineering.
from pixijs.
Hmm yeah no the GraphicsContext
is referenced all over the place. Difficult to tell quickly how it's used, e.g. for TextStyle
.
from pixijs.
Hey @elsassph you should be able to pass manageImports: false
in the init function to allow for things like events/accessibility to not be added automatically e.g.
const app = new Application();
await app.init({
manageImports: false
});
as for the imports you can also manually add the ones you want
// imported by default
import 'pixi.js/accessibility';
import 'pixi.js/app';
import 'pixi.js/events';
import 'pixi.js/filters';
import 'pixi.js/sprite-tiling';
import 'pixi.js/text';
import 'pixi.js/text-bitmap';
import 'pixi.js/text-html';
import 'pixi.js/graphics';
import 'pixi.js/mesh';
import 'pixi.js/sprite-nine-slice';
// not added by default, everyone needs to import these manually
import 'pixi.js/advanced-blend-modes';
import 'pixi.js/unsafe-eval';
import 'pixi.js/prepare';
import 'pixi.js/math-extras';
import 'pixi.js/dds';
import 'pixi.js/ktx';
import 'pixi.js/ktx2';
import 'pixi.js/basis';
from pixijs.
Related Issues (20)
- Feature Request: Put again sync methods in ExtractSystem
- Bug: requestVideoFrameCallback does not seem to be working as expected HOT 1
- Bug: v8.0.3+ addressMode is repeat by default HOT 1
- Feature Request: [v8] Support `breakWords: true` with Pixi.BitmapText HOT 4
- Bug: crash when WebGL2RenderingContext is not available HOT 8
- Feature Request: preventing loading / unloading systems HOT 2
- Bug: Assets.load for BitmapFonts broken ? HOT 4
- Bug: TexturePacker anchor point ignored HOT 3
- Bug: TypeError: Cannot read properties of null (reading 'structureDidChange') HOT 5
- Bug: ReferenceError: Can't find variable: WebGL2RenderingContext HOT 2
- Bug: TypeError: RendererClass is not a constructor HOT 3
- Bug: TypeError: Failed to execute 'shaderSource' on 'WebGL2RenderingContext': parameter 1 is not of type 'WebGLShader' HOT 1
- Bug: RangeError: Failed to execute 'createBuffer' on 'GPUDevice': createBuffer failed, size is too large for the implementation when mappedAtCreation == true HOT 1
- Bug: TypeError: Cannot read properties of null (reading 'uid') HOT 1
- Bug: The content of multiple texts overlaps with each other. HOT 17
- Bug: [v8] antialias=true drastically cuts performance even when idle HOT 3
- Bug: Arc line cap not re-rendered if graphics is cleared HOT 1
- Bug: v8 mask container bounds changes
- Bug: Unable to add a mask to the text HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pixijs.