rexrainbow / phaser3-rex-notes

Notes of phaser3 engine
MIT License
1.18k stars 259 forks source link

Does UI component support on-demand introduction? #421

Closed cy920820 closed 3 months ago

rexrainbow commented 3 months ago

Do you mean that importing class directly, without using factory (scene.rexUI.add.xxx)? Yes, it has. For example, import Label class. (More classes...)

cy920820 commented 3 months ago

Will unused components be packaged into the project, eventually increasing the size of the application?

rexrainbow commented 3 months ago

It depends on bundle tool like rollup, or webpack. Usually they can include imported module/class only. BTW, factory (scene.rexUI.add.xxx) solution will include all of them in rexui plugin.

cy920820 commented 3 months ago

I just want to package the UI components used to prevent the project volume from increasing

rexrainbow commented 3 months ago

You can import class directly like

import { Label } from 'phaser3-rex-plugins/templates/ui/ui-components.js';
cy920820 commented 3 months ago

thanks bro

cy920820 commented 2 months ago

You can import class directly like

import { Label } from 'phaser3-rex-plugins/templates/ui/ui-components.js';

I am using the vite build tool, so I think it should be dynamic import

const { Label } = await import('phaser3-rex-plugins/templates/ui/ui-components.js');

Is that so?

rexrainbow commented 2 months ago

I did not use await import(...) in my test environment, sorry can't help you.