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

[5.3] MSTR-275: do not require sub module, let core handle it #522

Merged
merged 1 commit into from
Dec 19, 2023

Conversation

icehess
Copy link
Contributor

@icehess icehess commented Dec 12, 2023

If the app assets is loading from external source_url, if the app tries to require its sub modules directly it will fail and the app won't load at all.

Changing the module name to its external source_url as what Monster UI core was previously doing won't always work in case the sub modules were small enough and optimized away in a single file as app.js. This has been observed with branding and call-recording apps so far.

Instead we can explicitly config the paths for sub module and its external source url for requirejs to load it, if it is not already optimized in the app.js.

Without this change, because app.js is requiring the submodules, this URL will be used instead of external source_url:

http://{monster_ui_url}/apps/:appname/submodules/{submodule}/{submodule}.js

requireSubModule from monster.apps.js will require all submodules defined on the app and can adds external source_url of the sub module in requirejs config so the correct URL will be used for fetch if it is needed:

http://{app_metadata.source_url}/submodules/{submodule}/{submodule}.js

Read more: https://requirejs.org/docs/jquery.html#modulename

guillegr123
guillegr123 previously approved these changes Dec 16, 2023
If the app assets is loading from external `source_url`, if the app tries to require its
sub modules directly it will fail and the app won't load at all.

Changing the module name to its external `source_url` as what Monster UI core was
previously doing won't always work in case the sub modules were small enough and optimized
away in a single file as `app.js`. This has been observed with `branding` and
`call-recording` apps so far.

Instead we can explicitly config the paths for sub module and its external source url for
`requirejs` to load it, if it is not already optimized in the `app.js`.

Without this change, because `app.js` is requiring the submodules, this URL will be used
instead of external source_url:

```
http://{monster_ui_url}/apps/:appname/submodules/{submodule}/{submodule}.js
```

`requireSubModule` from `monster.apps.js` will require all submodules
defined on the app and can adds external `source_url` of the sub module in requirejs
config so the correct URL will be used for fetch if it is needed:

```
http://{app_metadata.source_url}/submodules/{submodule}/{submodule}.js
```

Read more: https://requirejs.org/docs/jquery.html#modulename
@icehess icehess merged commit 4c6a2f6 into 5.3 Dec 19, 2023
1 check passed
@icehess icehess deleted the MSTR-275-5.3 branch December 19, 2023 21:46
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

Successfully merging this pull request may close these issues.

2 participants