Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[orion-dev] RequireJS adoption thoughts (reposting to orion list and adding a little more detail)

I have already posted this on the old list but thought it would be good to repost and also add a little more detail

Here are some thoughts on how we could approach adopting RequireJS :

  • For the short-term use dojo as-is. We should be able to continue to load and reference dojo as we do today from code that is using RequireJS. Dojo will continue to be in the global namespace.
  • Also leave our current dojo widgets as is too (which looks to be just the contents of /org.eclipse.e4.webide/static/js/widgets).
  • Convert other modules (basically everything else) over to using AMD API.
  • Stop using the eclipse namespace in these modules. When a given module needs to use another declare a dependency on it and use the passed-in argument to the factory function declared in the define call.
  • While we will stop using the eclipse global in the modules themselves they will live in a directory structure that follows a preferred namespace. e.g place modules in a "orion" directory + other nested directories as need be.
  • The path to the module will be used when declaring the dependency. e.g "orion/registry/Registry".
  • Move the existing Service Registry code in a "orion/registry" directory structure renaming and splitting so there is one module per js file. Create a RegistryInstance module that can be used for singleton access.
  • Move existing local services to a "orion/service" directory structure renaming and splitting so there is one module per js file
  • With both the above applied the structure would be like this :
  • We have quite a few places where current code uses dojo.addOnLoad. While this api can still be continued to be used we should consider consolidating them all into a single instance and reference that.

More long term adoption for using dojo via AMD.
  • Either adopt Dojo 1.6 which will be AMD compliant (dojo and dijit have been converted, dojox will probably need manual conversion). The Dojo 1.6 beta should be out any day now according to the dojo-contributors mailing list.
  • Do a conversion on Dojo 1.5 ourselves. RequireJS has conversion tools although the are currently outdated and don't work.

Richard

JPEG image


Back to the top