Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to lazyload typescirpt modules with oclazyload in AndularJs 1.5+ and ui-router? #436

Open
duruofei930704 opened this issue Jan 24, 2020 · 0 comments

Comments

@duruofei930704
Copy link

I am trying to lazyload some modules only when a page is visited because my main.js file is too big (3.4MB).
I am using AngularJs 1.6 (typescript), webpack, ui-router, and oclazyload.
oclazyload works for me when I use it for js libraries:

   resolve: {
      deps: ['$ocLazyLoad',
        function( $ocLazyLoad ){
          return $ocLazyLoad.load([ './ckeditor/ckeditor.js']).then(function(){
             $ocLazyLoad.load(['./ckeditor/config.js', './ckeditor/styles.js'])
          });
      }]
    },

but it does not work well when I use it for module.ts files:

  resolve: {
       deps: ['$ocLazyLoad',
         function( $ocLazyLoad, $state ){
           (async () => {
             await import('../dashboard/lcses/lcses.module').then((promise)=>{
               $ocLazyLoad.inject([promise.LcsesModule]);
             });
           })();
           return;
        }]
      },

this code runs, but the the main.js file is still 3.4 MB, and it does not inject that module at the first time you visit.

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant