How to prevent Angular2 core making dozens of HTTP requests on page load?

前端 未结 2 1265
一向
一向 2020-12-18 01:18

So I\'m developing an Angular2 application, and just by bootstrapping Angular2, I\'m sent over 250 requests for nearly every js file present in the @angular/core

2条回答
  •  被撕碎了的回忆
    2020-12-18 01:54

    There is new systemjs config in official quickstart https://angular.io/guide/quickstart

    Here is the copy

    // Add package entries for angular packages
      ngPackageNames.forEach(function(pkgName) {
        packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
      });
    

    So we can use their UMD bundle, and I tried it, from ~400 requests to about ~60 requests.

提交回复
热议问题