Ember Cli Lazy Load supports lazily loading your Ember application, by splitting the app up into bundles. It comes with a dummy app that implements a basic lazy loading scenario.
Requirements: ember-cli
== 2.2.0
Whenever ember-engines land their version of lazy loading, this add-on will be deprecated.
ember install ember-cli-lazy-load
index: {
//Minisearch file patterns for the content of the bundle
files: [
"**/templates/index.js",
"**/controllers/index.js",
"**/components/my-cat/**.js"
],
//The name of the routes if you are using the lazy-route mixin, no minisearch expressions are allowed here.
routes: ["index", "..."]
//The dependencies for this bundle. They will loaded in the same batch as the actual bundle
dependencies: ["about"],
},
about: {
files: [
"**/templates/about.js",
"**/controllers/about.js",
"**/components/my-item/**.js"
],
routes: ["about", "more routes for this bundle "]
}
var bundles = require("./bundles");
module.exports = function(environment) {
var ENV = {
bundles: bundles(environment),
var EmberApp = require("ember-cli-lazy-load/ember-app");
var bundles = require("./config/bundles")();
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
// Add options here
bundles: bundles
}
import Ember from "ember";
import LazyRouteMixin from 'ember-cli-lazy-load/mixins/lazy-route';
export default Ember.Route.extend(LazyRouteMixin, {});
if you already override beforeModel
, ensure that you execute and await the super call:
import Ember from "ember";
import LazyRouteMixin from 'ember-cli-lazy-load/mixins/lazy-route';
export default Ember.Route.extend(LazyRouteMixin,{
beforeModel: function(transition, queryParams){
return this._super(transition,queryParams).then(()=>{
// do the other beforeModel operations
});
}
});
ember server
- Visit your app at http://localhost:4200.
npm test
(Runsember try:testall
to test your addon against multiple Ember versions)ember test
ember test --server