| Summary: | Minified builds have "blank page syndrome" with RequireJS 2 | ||
|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Mark Macdonald <mamacdon> |
| Component: | Client | Assignee: | Mark Macdonald <mamacdon> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | blocker | ||
| Priority: | P3 | CC: | ken_walker, simon_kaegi |
| Version: | 3.0 | ||
| Target Milestone: | 3.0 M1 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
Mark Macdonald
Correction: none of the module's callbacks (factory functions) are ever called. I think [1] describes our problem. To quote: > So this is interesting: the data-main="index.js", but the module ID > for the main module is "index". With the new "only execute modules > that have been required" logic in 2.0[1], only a module called > 'index.js' is executed. > > (In requirejs 1.0, it would execute all define()s even if they were > not explicitly require()'d. The data-main processing is an implicit > require()) > > There is no define() with the the name 'index.js' after the build. > Before the build, since the define() in index.js is anonymous, it gets > the 'index.js' name, and it runs. > > The fix is to use data-main="index", then it works in both cases. [1] http://groups.google.com/group/requirejs/browse_thread/thread/e64a2817e7071495/6e5ad736e72a7c45 In Orion's case, "built-index.js" (the concatenated file) is the module that our page asks for: > <script> > require({ > /* .. */ > }); > > require(["built-index.js"]); // !! > </script> ... But if you look at the source of built-index.js, there is no module named "built-index.js", rather it's named "index.js": > /* .. */ > > define('index.js',['orion/bootstrap', 'domReady!'], function(mBootstrap) { > mBootstrap.startup().then(function(core) { > window.location = "navigate/table.html"; > }); > }); Nobody ever asks for "index.js", so the module is never loaded, and the page ultimately does nothing. The fix is to change the module name to built-index.js in the concatenated file: > define('built-index.js',['orion/bootstrap', 'domReady!'], function(mBootstrap) { > ^^^^^^^^^^^^^^ ^^ Like this, the page loads OK. Let's see how this fares http://git.eclipse.org/c/orion/org.eclipse.orion.server.git/commit/?id=398bfb43cef17e98eebce64b Fixed in build I20130405-1735 by these commits * http://git.eclipse.org/c/orion/org.eclipse.orion.server.git/commit/?id=94e11f4287e6926523a58bba98c9abc09fba7ff4 * http://git.eclipse.org/c/orion/org.eclipse.orion.server.git/commit/?id=5e836da3ddb617dcbd71cc2683177c5a4dc8ddb7 * http://git.eclipse.org/c/orion/org.eclipse.orion.server.git/commit/?id=9c14180531c97cd6646f85af616ab92f5ebc7b1e * http://git.eclipse.org/c/orion/org.eclipse.orion.server.git/commit/?id=25415125ea80e747cbda3d14ddd6cf43abce4b71 The fix is basically to find+replace the module name as explained in Comment 3. The build script now does this for us. This works but it's a fragile approach. Simon thinks that we should be moving our pages to the data-main="" style and using the `paths` option to sub in the optimized version of the page module. It might also be better to move more of the work currently done by Orion's Ant build script into our r.js build file. For example, r.js has API for processing an entire project that we should look into, rather than invoking r.js repeatedly from Ant. Apparently r.js can run in browsers now too. So the more work we can shift onto it (and ultimately the browser, at dev time) the better. |