Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

We are in process of splitting our large ember app into logical chunks and delay load few of the modules to improve performance.

We have an entry which in turn recursively includes all dependencies and creates one big rjs optimized file during build process. We want to load few core components and the routes during initial load and delay load everything else.

We want to nest our require calls inside route and use beforeModelHook to load dependent controllers, templates, components as specified in this guide http://toranbillups.com/blog/archive/2014/10/02/Lazy-loading-es6-modules-with-emberjs/

Now the problem is if we skip import statement

import mycontroller = require("mycontroller")

and use nested require

beforeModel() {
   require(["mycontroller"])
   ...
}

typescript fails to list mycontroller as dependency when compiled. How to resolve this issue?

What are other ways of achieving improving performance?

share|improve this question
up vote 1 down vote accepted

typescript fails to list mycontroller as dependency when compiled. How to resolve this issue

You need to use the imported type for your file to have a run-time dependency on the module. This is specifically designed to support lazy loading scenarios

Docs

This is covered here : https://basarat.gitbooks.io/typescript/content/docs/project/external-modules.html

share|improve this answer
    
This is exactly what I was looking for. Thank you – user103054 Apr 19 at 5:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.