Hi Chris,
as far as I know there are only two options to configure require.js, but
both won't do it globally:
- configure requirejs in your module/shim JS/Coffee code
- use a ModuleConfigurationCallback
We had timeout issues in the past, but only with a few scripts, like the
Monaco editor, so we added the configuration right into the module/shim:
require.config({
waitSeconds: 30,
paths: {
vs: 'monaco/0.47.0'
}
});
define(['jquery', 'vs/editor/editor.main'], function($) {
// ...
});
The other option is the ModuleConfigurationCallback
https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/ModuleConfigurationCallback.java
See this integration test on how to use it:
https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ModuleConfigurationCallbackDemo.java
Maybe it would work globally if added to the layout component?
Alternatively, you could override the MarkupRendererFilter for the
DocumentLinker to add the ModuleCallback before rendering the markup:
https://github.com/apache/tapestry-5/blob/8d31a99d480c3295e7ad6a21f1f48eb0138465df/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java#L1824
https://github.com/apache/tapestry-5/blob/8d31a99d480c3295e7ad6a21f1f48eb0138465df/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java#L1897
The code is from the latest version, but it hasn't changed from 5.4, just
moved a little.
Cheers
Ben
On Tue, Sep 17, 2024 at 12:50 AM Christopher Dodunski (Tapestry) <
[email protected]> wrote:
> Hi team,
>
> Starting with version 5.4, Tapestry uses RequireJS modules internally,
> and provides support for using RequireJS modules in our own Tapestry
> applications. I'm wondering whether there is a mechanism in place for
> configuring RequireJS from my AppModule?
>
> On networks with slow internet access users are encountering an endless
> spinning circle, even after images etc beneath have finished loading.
> I'm able to replicate this issue by throttling my browser to 3G speed or
> slower.
>
> The error displayed in the browser's console:
>
> core.js:452:339
>
> RequireJS error: timeout: Load timeout for modules:
> https://code.jquery.com/jquery-3.3.1.slim.min.js
> http://requirejs.org/docs/errors.html#timeout, modules
> https://code.jquery.com/jquery-3.3.1.slim.min.js,
> https://www.[hidden].com/harbour/assets/stack/z5f50bb4/en/core.js, line
> 29, line 89
>
> My thoughts are to disable RequireJS's timeout attribute. This could
> possibly be achieved by embedding the below into the TML of the page
> concerned, but using AppModule would be a cleaner solution.
>
> <script>var requirejs = { waitSeconds: 0 }</script>
> <script src="./path/to/require.js" data-main="main"></script>
>
> Thank you in advance for any pointers.
>
> Kind regards,
>
> Chris.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>