Commit b49d87b
committed
bug #81 [Bug] Removing unnecessary Promise in object of controllers to be loaded (weaverryan)
This PR was squashed before being merged into the main branch.
Discussion
----------
[Bug] Removing unnecessary Promise in object of controllers to be loaded
Hi!
Subtle change. Previously, the webpack loader parsed `controllers.json` (which eventually becomes the `symfonyControllers` variable in `index.ts`) into something that exported an object where each key was a promise - something like:
```js
export default {
'symfony--ux-autocomplete--autocomplete': import(/* webpackMode: \"eager\" */ '`@symfony`/ux-autocomplete/dist/controller.js')
}
```
Then, in `startStimulusApp()`, we called used `.then()` to wait for that promise to resolve then registered its resolved value:
```js
symfonyControllers[controllerName].then((module) => {
application.register(controllerName, module.default);
});
```
This is totally unnecessary and a relic of how this library was originally built. It also causes the UX controllers to be registered *late*. It's barely noticeable, but in practice, instead of the UX controllers being registered BEFORE the DOM is ready, they are registered after. This actually causes a problem with a new feature from LiveComponents.
The new parsed version of `controllers.json` from the loader looks much simpler:
```diff
+ import controller_0 from '`@symfony`/ux-autocomplete/dist/controller.js';
export default {
- 'symfony--ux-autocomplete--autocomplete': import(/* webpackMode: \"eager\" */ '`@symfony`/ux-autocomplete/dist/controller.js')
+ 'symfony--ux-autocomplete--autocomplete': controller_0,
}
```
(I don't show it here, but lazy controllers have a similar simplification).
In short: it's a bug fix & an easy win. Controllers will load slightly earlier as a result.
Thanks!
Commits
-------
0d77e41 [Bug] Removing unnecessary Promise in object of controllers to be loadedFile tree
11 files changed
+113
-166
lines changed- dist
- webpack
- src
- webpack
- test
- fixtures
- webpack
11 files changed
+113
-166
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 44 | + | |
47 | 45 | | |
48 | 46 | | |
49 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
48 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
49 | 47 | | |
50 | | - | |
| 48 | + | |
51 | 49 | | |
52 | 50 | | |
53 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
26 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
27 | 25 | | |
28 | | - | |
| 26 | + | |
29 | 27 | | |
30 | 28 | | |
31 | 29 | | |
32 | 30 | | |
33 | | - | |
| 31 | + | |
34 | 32 | | |
35 | | - | |
36 | 33 | | |
37 | 34 | | |
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
41 | 38 | | |
| 39 | + | |
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
| |||
58 | 56 | | |
59 | 57 | | |
60 | 58 | | |
61 | | - | |
62 | | - | |
63 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
64 | 65 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 66 | + | |
73 | 67 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
79 | 72 | | |
80 | 73 | | |
81 | 74 | | |
| |||
87 | 80 | | |
88 | 81 | | |
89 | 82 | | |
90 | | - | |
| 83 | + | |
91 | 84 | | |
92 | 85 | | |
93 | 86 | | |
| |||
96 | 89 | | |
97 | 90 | | |
98 | 91 | | |
99 | | - | |
100 | | - | |
| 92 | + | |
| 93 | + | |
101 | 94 | | |
102 | 95 | | |
103 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
| 37 | + | |
40 | 38 | | |
41 | 39 | | |
42 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
75 | 64 | | |
76 | | - | |
77 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
78 | 68 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
84 | 72 | | |
85 | 73 | | |
86 | 74 | | |
| |||
97 | 85 | | |
98 | 86 | | |
99 | 87 | | |
100 | | - | |
| 88 | + | |
101 | 89 | | |
102 | 90 | | |
103 | 91 | | |
| |||
108 | 96 | | |
109 | 97 | | |
110 | 98 | | |
111 | | - | |
112 | | - | |
| 99 | + | |
| 100 | + | |
113 | 101 | | |
114 | 102 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
36 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
37 | 35 | | |
38 | | - | |
| 36 | + | |
39 | 37 | | |
This file was deleted.
0 commit comments