[ 
https://issues.apache.org/jira/browse/TAP5-2350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14084382#comment-14084382
 ] 

Jochen Kemnade commented on TAP5-2350:
--------------------------------------

Well, the only relevant code would be 
{code}
public static void contributeCoreJavaScriptStack(final 
OrderedConfiguration<StackExtension> configuration) {
  configuration.add("bootstrap/dropdown", 
StackExtension.module("bootstrap/dropdown"));
}
{code}
and in a component:
{code:javascript}
require(['bootstrap/dropdown'], function(){
  
});
{code}
The page will load in the browser, that loads the core stack by default. The 
stack is processed by the browser and the included modules are evaluated. 
However, as  {{bootstrap/dropdown}} is not a proper AMD module, it is not 
defined within a call to {{define}}, so its code is evaluated, but RequireJS 
doesn't "know" about it.
So the {{require(['bootstrap/dropdown']...}} from the component module will 
load and, above all, evaluate the library again.
The {{AMDWrapper}} class works around that problem by creating real AMD modules 
with {{define}} calls instead of shim configurations.

> JavaScript library with module shim config is loaded twice if module is added 
> to a stack
> ----------------------------------------------------------------------------------------
>
>                 Key: TAP5-2350
>                 URL: https://issues.apache.org/jira/browse/TAP5-2350
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.4
>            Reporter: Jochen Kemnade
>              Labels: javascript, stack
>
> When a shim config is defined for a JavaScript library and the resulting 
> "module" is added to a JavaScript stack, the raw library will be added to the 
> stack resource (without a define statement). But under normal circumstances, 
> it will never be used as it is added without any module wrapper code.
> When the library is required (via the shim module) from another module, 
> requirejs loads it again.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to