1

J2EE 응용 프로그램 (Spring MVC)에 Angular2를 사용하고 있습니다. 지연로드을 구현했으나 처음에는 더 많은 시간 (약 2 분 !!!)이 걸립니다.
typescript.js : 4.75 MB
compiler.umd.js :Angular2 Application 초기로드 문제. typescript.js 파일은 4.75MB입니다.

는 두 개의 큰 크기의 파일이로드가이 0.98 MB

을 그리고 typescript.js 파일이 캐시되지 않습니다. 모든 다운로드가 다시로드됩니다.

내 systemjs.config.js 파일은 다음과 같습니다이 두 파일 (typescript.js, compiler.umd.js)의 크기를 줄일 수있는 방법이

System 
     .config({ 
      transpiler : 'ts', 
      typescriptOptions : { 
       "target" : "es5", 
       "module" : "commonjs", 
       "moduleResolution" : "node", 
       "sourceMap" : true, 
       "emitDecoratorMetadata" : true, 
       "experimentalDecorators" : true, 
       "lib" : [ "es2015", "dom" ], 
       "noImplicitAny" : true, 
       "suppressImplicitAnyIndexErrors" : true 
      }, 
      meta : { 
       'typescript' : { 
        "exports" : "ts" 
       } 
      }, 
      paths : { 
       'npm:' : 'uploads/node_modules/' 
      }, 
      map : { 
       'app' : 'app', 
       '@angular/animations' : 'npm:@angular/animations/bundles/animations.umd.js', 
       '@angular/animations/browser' : 'npm:@angular/animations/bundles/animations-browser.umd.js', 
       '@angular/core' : 'npm:@angular/core/bundles/core.umd.js', 
       '@angular/common' : 'npm:@angular/common/bundles/common.umd.js', 
       '@angular/compiler' : 'npm:@angular/compiler/bundles/compiler.umd.js', 
       '@angular/platform-browser' : 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', 
       '@angular/platform-browser/animations' : 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js', 
       '@angular/platform-browser-dynamic' : 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', 
       '@angular/http' : 'npm:@angular/http/bundles/http.umd.js', 
       '@angular/router' : 'npm:@angular/router/bundles/router.umd.js', 
       '@angular/router/upgrade' : 'npm:@angular/router/bundles/router-upgrade.umd.js', 
       '@angular/forms' : 'npm:@angular/forms/bundles/forms.umd.js', 
       '@angular/upgrade' : 'npm:@angular/upgrade/bundles/upgrade.umd.js', 
       '@angular/upgrade/static' : 'npm:@angular/upgrade/bundles/upgrade-static.umd.js', 


       // other libraries using node_modules 
       'rxjs' : 'npm:rxjs', 
       'angular-in-memory-web-api' : 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js', 
       'ts' : 'npm:plugin-typescript/lib/plugin.js', 
       'typescript' : 'npm:typescript/lib/typescript.js', 
       'angular2-datatable' : 'npm:angular2-datatable', 
       'lodash' : 'npm:lodash/lodash.js', 
       'angular2-datatable-pagination' : 'npm:angular2-datatable-pagination', 
       'jquery' : 'lib/jquery/jquery-3.2.0.min.js', 
       'ngx-pagination' : 'lib/ngxpagination/ngx-pagination.js', 

      }, 
      packages : { 
       app : { 
        defaultExtension : 'ts' 
       }, 
       rxjs : { 
        defaultExtension : 'js' 
       }, 
       'angular2-datatable' : { 
        main : 'index.js', 
        defaultExtension : 'js' 
       } 
      }, 
      "scripts" : [ "lib/jquery/jquery-3.2.0.min.js" ] 
     }); 

있습니까?

전자 상거래 응용 프로그램입니다. 그래서이 문제를 해결해야합니다. 이 문제에 대한 해결책을 알려주십시오.

당신은

+0

당신은 그것을 캐싱 아니에요 말했다, 그것은 선택에 의한 것일까 요? 아니면 고객이 물어 본 것입니까? 캐싱하면 속도가 빨라질 수 있습니다. – kazu

+0

답장을 보내 주셔서 감사합니다. 고객이 문제로보고했습니다. 캐싱은 내 문제를 해결하지 못합니다. 2 분 정도 걸립니다. typescript.js 파일의 크기를 줄일 수있는 방법이 있습니까? –

답변

2

난 강력하게 당신이 각도 4 프로젝트에 각도이 프로젝트를 업데이트 할 것을 제안드립니다. Angular 4의 특징 중 하나는 최대 60 % 작아집니다. 각도 2와 4는 호환 가능합니다. typeScript와 rxjs와 같이 깨질 수있는 몇 가지 사항이 있습니다. 이 작업을 완료하는 데 약 2 ~ 3 시간이 소요됩니다.

Ahead Of Time Compiler을 사용하여 컴파일 할 수도 있습니다. 그러면 속도가 약간 향상됩니다.

Here is an article to update to angular 4 기사가 말했듯이, 당신이 명령을 실행 할 수 있습니다

(윈도우)

NPM은 각도/일반 @ 각도/컴파일러 @ 최신 각도 @ 최신 @ /compiler- @ 설치를 최신 @ 각도/플랫폼 @ 최신 @ 각도/양식 @ 최신 @ 각도/http @ 최신 @ 각도/플랫폼 브라우저 @ 최신 @ 각도/플랫폼 브라우저 - 동적 @ 최신 @ angular/platform-server @ 최신 @ 각도/라우터 @ 최신각 @/애니메이션 @ 최신 타이프 @ 최신 --save

(리눅스)

NPM은 각도/{일반, 컴파일러, 컴파일러 CLI 코어, 양식 @ 설치, HTTP, 플랫폼에 브라우저, 플랫폼 - 브라우저 - 동적, 플랫폼 서버, 라우터, 애니메이션} @latest typescript @ latest --save

모두 최고!

+0

KeaganFouche 정말 고마워요. –

+0

오신 것을 환영합니다! – KeaganFouche

0

글쎄, 내가 아는 한, 당신은 TypeScript를 축소 할 수 없다.당신이 여기에서 찾을 수 있습니다하지만 몇 가지 다른 솔루션이있다 :

Is it possible to compile typescript into minified code?

하지만 당신은 또한 당신의 코드를 확인해야하고, 청소가되지 않는 모든 방법, 수입, ...

+0

확인. 고마워. –