Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

0.5.0pr1

Pre-release
Pre-release
Compare
Choose a tag to compare
@drewfish drewfish released this 06 Aug 23:31
· 2815 commits to develop since this release

This is a special preview release of Mojito 0.5.0. It incorporates some significant re-architecting for performance. There are a few significant backwards-compatibility breaking changes, details below.

!!! NOTE !!! This release DOES NOT pass our functional tests. This started as a rough prototype, and we're slowly cleaning it up.

Backwards Compatibility Changes

1. Addons should be required

In the past, a subset of the addons provided by Mojito framework were attached on every ActionContext object (which are created per request, per mojit instance in the page). The specific list was ['mojito-config-addon', 'mojito-url-addon', 'mojito-assets-addon', 'mojito-cookie-addon', 'mojito-params-addon', 'mojito-composite-addon']. This resulted in overhead for every mojit in the page. As part of this release, all requirements have to be specified in the controller definition. e.g:

    YUI.add('Foo', function(Y, NAME) {

        Y.namespace('mojito.controllers')[NAME] = {

            index: function(ac) {
                // ac.params.* is now available
            }

        };

    }, '0.0.1', {requires: ['mojito', 'mojito-params-addon']});

In this release, no addon is attached unless it is required. The only public members of ActionContent object are ac.done, ac.error, and ac.flush.

Recommendations to upgrade:

  • check every controller in your app, and check if it is using ac.*, and add the corresponding requirements.
  • the most common addons are: config, params, url, assets.

2. Introducing Model Factory

Models are no longer computed and attached to ActionContext by default. In other words, ac.models.foo is no longer a valid way to access a model. Computing and attaching models automatically, even when they were not really needed, added overhead during the page rendering process. Instead, we want Mojito to be more strict in defining and exposing structures automatically.

In this new version, if you need to use a model in a controller (defined at the mojit level, or at the application level), you need to:

  • require a new addon called mojito-models-addon in your controller.
  • require the module in your controller.
  • use ac.models.get('foo') to get a reference of the model.

Here is an example:

    YUI.add('DemoModelFoo', function(Y, NAME) {
        Y.namespace('mojito.models')[NAME] = {
            init: function(config) {
                this.config = config;
            },
            getData: function(callback) {}
        };
    }, '0.0.1', {requires: []});
    YUI.add('Foo', function(Y, NAME) {
        Y.namespace('mojito.controllers')[NAME] = {
            index: function(ac) {
                ac.models.get('DemoModelFoo').getData(function (data) {
                    // data from model available here
                });
            }
        };

    }, '0.0.1', {requires: ['mojito', 'mojito-models-addon', 'DemoModelFoo']});

Note: the model name doesn't have to match the yui module name for the model anymore.

3. Removing init method from controllers

The init method on the controller is now deprecated and should be removed. In many cases, the init method was just storing a reference of the config parameter to use it later on. This is no longer available, and the init method will not be executed. If you need to access the mojit config in an actions, you should:

  • require mojito-config-addon in the controller.
  • use ac.config.get() to get the config

Note: do not try to store a reference of that config, as it is not safe, More details below.

4. Controllers are now singletons

Each controller is now a singleton object, and it stays alive between requests and mojit instances. As a result, you should no longer do this.foo = something; within an action, or any other method in a controller. Instead, you should rely more on the ActionContext (ac object) which is unique per request and per mojit instance. E.g:

    YUI.add('Foo', function(Y, NAME) {

        Y.namespace('mojito.controllers')[NAME] = {

            index: function(ac) {
                // ac.myCustomAddon.* provides a nice mechanism to store data.
            }

        };

    }, '0.0.1', {requires: ['mojito', 'my-custom-addon']});

Note: we will re-evaluating this feature in the upcoming release, but for now, it is not safe to be used.

5. New routine to boot the app

As part of the effort to allow Mojito applications to run in 3rd party hosting environments, we have changed the way the application will resolve the port. If you want to application to be compatible with 0.4.x, you can change server.js to export app.start() or app conditionally. Here is an example:

   var Mojito = require('mojito');
   var app = Mojito.createServer({
       context: {}
   });
   // Mojito 0.4 and 0.5 compatibility...
   module.exports = app.start ? app.start() : app;

Fixes

  • #478 updated perf marks/timelines
  • #481 controller only gets what is -explicitely- listed in it's "requires"
  • #483 adding store:getMojitTypeDetails metric
  • #484 adding cache for getRoutes function (resourceStore)
  • #485 adding support for perf.log
  • #486 Removed unneeded YUI instances
  • #489 Fixes to middleware (contextualizer, router) and route-maker
  • #491 Adding cache and freeze to getAppConfig + removed unnecessary validatedContext
  • #492 removed unnecessary validateContext
  • #494 Large changes
  • #497 Fixes based on Ric's changes
  • #499 first version of tool to turn perf.log into a graph
  • #500 feature: models are optional for perf reasons
  • #501 Bug fixes in simple examples replacing "mojit_guid" with "mojit_view_id"
  • #502 use an AC addon for accessing the config
  • #503 updated TODO
  • #504 re-enabling the perf metrics
  • #505 removing the qeperf logs
  • #506 Added YUI cache per req context
  • #511 More search-perf fixes
  • #517 more cache changes
  • #518 enhancement for perf and profiler
  • #521 Replace Y.JSON.xxx with JSON.xxx for server affinities (faster)
  • #524 delinted
  • #527 Fix action-context tests
  • #528 adding metric for the handlebars renderer engine
  • #531 fix some store unit tests in develop-perf
  • #532 need to do a recursive merge
  • #534 Cleaned up renderers cache and added unit tests
  • #538 fixed middleware unit tests
  • #539 Fixed Dispatcher unit tests and interfaces.
  • #540 Fixed mojito-mu and output-adapter-addon tests
  • #553 Fixed for routemaker and middleware router
  • #557 better use of store.validateContext()
  • #560 Removed references to app.config in output-adapter addon
  • #569 no longer use resource store adapter
  • #572 Fix broken test due to buildUrl reference rather than _buildUrl.
  • #573 attaching required ac addons
  • #574 use POSL and lang instead of context for the cache key in store.expandInstanceForEnv()
  • #575 Fixed arrow unit tests for output-adapter
  • #576 Perf refactor
  • #578 adding some guarding in case perf is not enabled, in which case we do no...
  • #579 Fix func tests - phase one
  • #586 AC addon namespace should match the ac filename
  • #588 more careful about use of Y.Loader
  • #590 better handling of shared/global language bundles
  • #593 Merge assets from config.assets to meta
  • #595 much better about YUI module dependencies when calculating for the client

Acknowledgements

Special thanks to the Yahoo! Search team for inspiring the work and contributing a great deal to Mojito.