Note that there are some explanatory texts on larger screens.

plurals
  1. POrequirejs r.js optimized builds of components over a main library
    primarykey
    data
    text
    <p>I'd like to get some best practice advice on componetising sub modules into a larger project. In development mode, it works fine as require resolves all deps on the fly - but it needs to be produced for a GWT app now that apparently has difficulty consuming async stuff via callbacks.</p> <p>Structure is as follows (this builds fine individually and creates the files as required):</p> <ul> <li>main (builds all shared libs resources etc) <ul> <li>component A (requires main to be there but excluded in own build)</li> <li>... component N </li> </ul></li> </ul> <p>To be used in an app that loads like so:</p> <pre><code>&lt;script src='require.js'&gt;&lt;/script&gt; &lt;script src='main-lib-min.js'&gt;&lt;/script&gt; &lt;script src='component-a-min.js'&gt;&lt;/script&gt; &lt;script src='component-n-min.js'&gt;&lt;/script&gt; &lt;!-- client to all these files is a single app to kick off: --&gt; &lt;script src='app.js'&gt;&lt;/script&gt; </code></pre> <p>main is defined as a require wrap and fires an event when done. components are a collection of modules in a <code>define()</code> wrap.</p> <p>the problem is, <code>app.js</code> should not reference anything until all references have been resolved. and <code>component-A</code> may have references to exports of <code>main-lib</code> so it should not be evaluated before the previous script has loaded.</p> <p>in chrome, we are seeing parallel downloading and reference errors. need that to be blocking instead. since the <code>r.js</code> build has pre-packaged everything, the factory should be able to just return any module defined above it.</p> <p>i.e. doing:</p> <p><code>var foo = require('foo');</code> ought to be fine. </p> <p>if app.js is created as:</p> <pre><code>require(['foo'], function(foo){ }); </code></pre> <p>then it works. </p> <p>does anyone have experience in producing this kind of a component build / module pattern? would you include all modules from the main-lib build config as <code>modules: []</code> so they wait for each other? what if you want the client (i.e. the html file) to be the one adding the modules? </p> <p>would you change the loading? is there a GWT loader that will be more appropriate to ensure sync-like behaviour? performance is not an issue. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload