Skip to content

Commit e122c44

Browse files
committed
build: improving load functions code
1 parent d2a34e9 commit e122c44

2 files changed

Lines changed: 97 additions & 95 deletions

File tree

bundles/fireworks/src/fireworks.ts

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -77,38 +77,39 @@ async function initPlugins(engine: Engine): Promise<void> {
7777

7878
await engine.pluginManager.register(async e => {
7979
const [
80-
{ loadBasic },
81-
{ loadLineShape },
82-
{ loadBlendPlugin },
83-
{ loadEmittersPluginSimple },
84-
{ loadEmittersShapeSquare },
85-
{ loadSoundsPlugin },
86-
{ loadRotateUpdater },
87-
{ loadDestroyUpdater },
88-
{ loadLifeUpdater },
89-
{ loadPaintUpdater },
90-
] = await Promise.all([
91-
import("@tsparticles/basic"),
92-
import("@tsparticles/shape-line"),
93-
import("@tsparticles/plugin-blend"),
94-
import("@tsparticles/plugin-emitters/plugin"),
95-
import("@tsparticles/plugin-emitters-shape-square"),
96-
import("@tsparticles/plugin-sounds"),
97-
import("@tsparticles/updater-rotate"),
98-
import("@tsparticles/updater-destroy"),
99-
import("@tsparticles/updater-life"),
100-
import("@tsparticles/updater-paint"),
101-
]);
80+
{ loadBasic },
81+
{ loadLineShape },
82+
{ loadBlendPlugin },
83+
{ loadEmittersPluginSimple },
84+
{ loadEmittersShapeSquare },
85+
{ loadSoundsPlugin },
86+
{ loadRotateUpdater },
87+
{ loadDestroyUpdater },
88+
{ loadLifeUpdater },
89+
{ loadPaintUpdater },
90+
] = await Promise.all([
91+
import("@tsparticles/basic"),
92+
import("@tsparticles/shape-line"),
93+
import("@tsparticles/plugin-blend"),
94+
import("@tsparticles/plugin-emitters/plugin"),
95+
import("@tsparticles/plugin-emitters-shape-square"),
96+
import("@tsparticles/plugin-sounds"),
97+
import("@tsparticles/updater-rotate"),
98+
import("@tsparticles/updater-destroy"),
99+
import("@tsparticles/updater-life"),
100+
import("@tsparticles/updater-paint"),
101+
]),
102+
loadEmittersForFireworks = async (e: Engine): Promise<void> => {
103+
await loadEmittersPluginSimple(e);
104+
105+
await loadEmittersShapeSquare(e);
106+
};
102107

103108
await Promise.all([
104109
loadBasic(e),
105110
loadLineShape(e),
106111
loadBlendPlugin(e),
107-
(async (): Promise<void> => {
108-
await loadEmittersPluginSimple(e);
109-
110-
await loadEmittersShapeSquare(e);
111-
})(),
112+
loadEmittersForFireworks(e),
112113
loadSoundsPlugin(e),
113114
loadRotateUpdater(e),
114115
loadDestroyUpdater(e),

bundles/slim/src/index.ts

Lines changed: 69 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -15,73 +15,69 @@ export async function loadSlim(engine: Engine): Promise<void> {
1515

1616
await engine.pluginManager.register(async e => {
1717
const [
18-
{ loadBasic },
19-
20-
{ loadExternalParallaxInteraction },
21-
{ loadExternalAttractInteraction },
22-
{ loadExternalBounceInteraction },
23-
{ loadExternalBubbleInteraction },
24-
{ loadExternalConnectInteraction },
25-
{ loadExternalGrabInteraction },
26-
{ loadExternalPauseInteraction },
27-
{ loadExternalPushInteraction },
28-
{ loadExternalRemoveInteraction },
29-
{ loadExternalRepulseInteraction },
30-
{ loadExternalSlowInteraction },
31-
{ loadParticlesAttractInteraction },
32-
{ loadParticlesCollisionsInteraction },
33-
{ loadParticlesLinksInteraction },
34-
35-
{ loadEasingQuadPlugin },
36-
{ loadInteractivityPlugin },
37-
38-
{ loadEmojiShape },
39-
{ loadImageShape },
40-
{ loadLineShape },
41-
{ loadPolygonShape },
42-
{ loadSquareShape },
43-
{ loadStarShape },
44-
45-
{ loadLifeUpdater },
46-
{ loadPaintUpdater },
47-
{ loadRotateUpdater },
48-
] = await Promise.all([
49-
import("@tsparticles/basic"),
50-
51-
import("@tsparticles/interaction-external-parallax"),
52-
import("@tsparticles/interaction-external-attract"),
53-
import("@tsparticles/interaction-external-bounce"),
54-
import("@tsparticles/interaction-external-bubble"),
55-
import("@tsparticles/interaction-external-connect"),
56-
import("@tsparticles/interaction-external-grab"),
57-
import("@tsparticles/interaction-external-pause"),
58-
import("@tsparticles/interaction-external-push"),
59-
import("@tsparticles/interaction-external-remove"),
60-
import("@tsparticles/interaction-external-repulse"),
61-
import("@tsparticles/interaction-external-slow"),
62-
import("@tsparticles/interaction-particles-attract"),
63-
import("@tsparticles/interaction-particles-collisions"),
64-
import("@tsparticles/interaction-particles-links"),
65-
66-
import("@tsparticles/plugin-easing-quad"),
67-
import("@tsparticles/plugin-interactivity"),
68-
69-
import("@tsparticles/shape-emoji"),
70-
import("@tsparticles/shape-image"),
71-
import("@tsparticles/shape-line"),
72-
import("@tsparticles/shape-polygon"),
73-
import("@tsparticles/shape-square"),
74-
import("@tsparticles/shape-star"),
75-
76-
import("@tsparticles/updater-life"),
77-
import("@tsparticles/updater-paint"),
78-
import("@tsparticles/updater-rotate"),
79-
]);
80-
81-
await Promise.all([
82-
loadBasic(e),
83-
84-
(async (): Promise<void> => {
18+
{ loadBasic },
19+
20+
{ loadExternalParallaxInteraction },
21+
{ loadExternalAttractInteraction },
22+
{ loadExternalBounceInteraction },
23+
{ loadExternalBubbleInteraction },
24+
{ loadExternalConnectInteraction },
25+
{ loadExternalGrabInteraction },
26+
{ loadExternalPauseInteraction },
27+
{ loadExternalPushInteraction },
28+
{ loadExternalRemoveInteraction },
29+
{ loadExternalRepulseInteraction },
30+
{ loadExternalSlowInteraction },
31+
{ loadParticlesAttractInteraction },
32+
{ loadParticlesCollisionsInteraction },
33+
{ loadParticlesLinksInteraction },
34+
35+
{ loadEasingQuadPlugin },
36+
{ loadInteractivityPlugin },
37+
38+
{ loadEmojiShape },
39+
{ loadImageShape },
40+
{ loadLineShape },
41+
{ loadPolygonShape },
42+
{ loadSquareShape },
43+
{ loadStarShape },
44+
45+
{ loadLifeUpdater },
46+
{ loadPaintUpdater },
47+
{ loadRotateUpdater },
48+
] = await Promise.all([
49+
import("@tsparticles/basic"),
50+
51+
import("@tsparticles/interaction-external-parallax"),
52+
import("@tsparticles/interaction-external-attract"),
53+
import("@tsparticles/interaction-external-bounce"),
54+
import("@tsparticles/interaction-external-bubble"),
55+
import("@tsparticles/interaction-external-connect"),
56+
import("@tsparticles/interaction-external-grab"),
57+
import("@tsparticles/interaction-external-pause"),
58+
import("@tsparticles/interaction-external-push"),
59+
import("@tsparticles/interaction-external-remove"),
60+
import("@tsparticles/interaction-external-repulse"),
61+
import("@tsparticles/interaction-external-slow"),
62+
import("@tsparticles/interaction-particles-attract"),
63+
import("@tsparticles/interaction-particles-collisions"),
64+
import("@tsparticles/interaction-particles-links"),
65+
66+
import("@tsparticles/plugin-easing-quad"),
67+
import("@tsparticles/plugin-interactivity"),
68+
69+
import("@tsparticles/shape-emoji"),
70+
import("@tsparticles/shape-image"),
71+
import("@tsparticles/shape-line"),
72+
import("@tsparticles/shape-polygon"),
73+
import("@tsparticles/shape-square"),
74+
import("@tsparticles/shape-star"),
75+
76+
import("@tsparticles/updater-life"),
77+
import("@tsparticles/updater-paint"),
78+
import("@tsparticles/updater-rotate"),
79+
]),
80+
loadInteractivityForSlim = async (e: Engine): Promise<void> => {
8581
await loadInteractivityPlugin(e);
8682

8783
await Promise.all([
@@ -101,7 +97,12 @@ export async function loadSlim(engine: Engine): Promise<void> {
10197
loadParticlesCollisionsInteraction(e),
10298
loadParticlesLinksInteraction(e),
10399
]);
104-
})(),
100+
};
101+
102+
await Promise.all([
103+
loadBasic(e),
104+
105+
loadInteractivityForSlim(e),
105106

106107
loadEasingQuadPlugin(e),
107108

0 commit comments

Comments
 (0)