Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 402976 - Upgrade require.js to 2.x
Summary: Upgrade require.js to 2.x
Status: RESOLVED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Client (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.0 M1   Edit
Assignee: Mark Macdonald CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-11 17:57 EDT by Mark Macdonald CLA
Modified: 2013-04-03 12:51 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Macdonald CLA 2013-03-11 17:57:56 EDT
Is there any reason we haven't upgraded Orion's requirejs library to 2.x yet? We are currently at 1.0.7.
Comment 1 Mark Macdonald CLA 2013-03-11 18:06:43 EDT
Well to answer my own question...

I tested 2.1.5 locally to take advantage of some new features. So far I found one issue, it seems the behavior of require.toUrl() has changed in a way that breaks the banner nav links.

This code in /orion/PageLinks.js:

In 1.0.7
> require.toUrl(".")   // "../orion"
> new URL(require.toUrl("."), window.location).href.slice(0,-1); // "http://localhost:8080/orio"

In 2.1.5:
> require.toUrl(".")   // "../."
> new URL(require.toUrl("."), window.location).href.slice(0,-1); // "http://localhost:8080/"
Comment 2 Mark Macdonald CLA 2013-03-11 21:17:35 EDT
Those labels got reversed. I meant to say:

In 1.0.7:
> require.toUrl(".")   // ../.
> new URL(require.toUrl("."), window.location).href.slice(0,-1); // http://localhost:8080

In 2.1.5:
> require.toUrl(".")   // ../orion
> new URL(require.toUrl("."), window.location).href.slice(0,-1); // http://localhost:8080/orio
Comment 3 Mark Macdonald CLA 2013-03-12 12:01:02 EDT
(In reply to comment #2)
It sounds like toUrl(".") may've been a misuse of this API. It now claims to only work on "[module path] + .fileextension" [1][2]. I did find that we can call toUrl("") in 2.x to get the result that our code expects, but perhaps that's bad also? I don't get it.

> require.toUrl(".")  // "../orion"
> require.toUrl("")   // "../"

Also, making the toUrl("") fix throughout the codebase fixes many hrefs, but there remains a problem where the Page links and Related links in the banner are missing: they don't get rendered at all. The rendering is async and should happen once the message bundles need by all the page links have loaded. For some reason it hangs on the bundle-loading step and never resolves. Didn't debug any further.

[1] http://requirejs.org/docs/api.html#modulenotes-urls
[2] https://github.com/jrburke/requirejs/issues/515
Comment 4 Mark Macdonald CLA 2013-03-12 12:48:08 EDT
Opened bug 403082 for the banner links not rendering
Comment 5 Mark Macdonald CLA 2013-03-15 17:14:48 EDT
Added remarks to bug 373450 about the toUrl() issue mentioned in Comment 2 and Comment 3. I think the way we're calculating OrionHome is wrong.
Comment 6 Mark Macdonald CLA 2013-03-25 12:19:58 EDT
I refactored all the places that perform OrionHome calculation into a single 'getOrionHome()' function in PageLinks.js:
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=df766dfd06b8fe6521c84a83386dc63b6474869a

Also opened a CQ requesting legal approval for RequireJS 2.1.5. Once approved, getOrionHome() needs to be updated to work with RequireJS 2 (per Comment 2 and Comment 3). Then this bug can be closed.
Comment 7 Mark Macdonald CLA 2013-04-03 12:51:04 EDT
CQ got approved for parallel IP. 

Here's the checkin of RequireJS 2.1.5:
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=876a2469ae287b63f267ef022a6baff4c23a6040

Also had to change the implementation of PageLinks#getOrionHome():
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=617b20a196364346205a494f